aports/main/llvm17/0001-Revert-Pseudo-Probe-Make-.pseudo_probe-GC-able.patch
Natanael Copa da65c809d9 main/llvm17: add llvm17
Add patch from upstream PR for Hexagon tests
ref: https://github.com/llvm/llvm-project/pull/66785

Revert commit that makes x86_64 test fail
ref: https://github.com/llvm/llvm-project/issues/66776

Add workaround for miscompile(?) on armv 32 bit.
https://github.com/llvm/llvm-project/issues/62195
2023-10-20 13:12:07 +00:00

132 lines
5.7 KiB
Diff

From 2ddc4203c63972ec58b6118a6c55b0c7e0e087c0 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Wed, 27 Sep 2023 09:07:58 +0200
Subject: [PATCH] Revert "[Pseudo Probe] Make .pseudo_probe GC-able"
This reverts commit 62d861422317b3e94a97706f07e8f1abce9a8135.
ref: https://github.com/llvm/llvm-project/issues/66776#issuecomment-1737051566
---
llvm/lib/MC/MCObjectFileInfo.cpp | 24 ++++-----
.../SampleProfile/pseudo-probe-emit.ll | 54 ++-----------------
2 files changed, 16 insertions(+), 62 deletions(-)
diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp
index 0b5109e41e71..7911e0c8c381 100644
--- a/llvm/lib/MC/MCObjectFileInfo.cpp
+++ b/llvm/lib/MC/MCObjectFileInfo.cpp
@@ -1172,20 +1172,18 @@ MCObjectFileInfo::getKCFITrapSection(const MCSection &TextSec) const {
MCSection *
MCObjectFileInfo::getPseudoProbeSection(const MCSection &TextSec) const {
- if (Ctx->getObjectFileType() != MCContext::IsELF)
- return PseudoProbeSection;
-
- const auto &ElfSec = static_cast<const MCSectionELF &>(TextSec);
- unsigned Flags = ELF::SHF_LINK_ORDER;
- StringRef GroupName;
- if (const MCSymbol *Group = ElfSec.getGroup()) {
- GroupName = Group->getName();
- Flags |= ELF::SHF_GROUP;
+ if (Ctx->getObjectFileType() == MCContext::IsELF) {
+ const auto &ElfSec = static_cast<const MCSectionELF &>(TextSec);
+ // Create a separate section for probes that comes with a comdat function.
+ if (const MCSymbol *Group = ElfSec.getGroup()) {
+ auto *S = static_cast<MCSectionELF *>(PseudoProbeSection);
+ auto Flags = S->getFlags() | ELF::SHF_GROUP;
+ return Ctx->getELFSection(S->getName(), S->getType(), Flags,
+ S->getEntrySize(), Group->getName(),
+ /*IsComdat=*/true);
+ }
}
-
- return Ctx->getELFSection(PseudoProbeSection->getName(), ELF::SHT_PROGBITS,
- Flags, 0, GroupName, true, ElfSec.getUniqueID(),
- cast<MCSymbolELF>(TextSec.getBeginSymbol()));
+ return PseudoProbeSection;
}
MCSection *
diff --git a/llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll b/llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll
index 13cfd820ae82..e56431b5abd1 100644
--- a/llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll
+++ b/llvm/test/Transforms/SampleProfile/pseudo-probe-emit.ll
@@ -5,12 +5,9 @@
; RUN: llc %t -function-sections -filetype=asm -o %t1
; RUN: FileCheck %s < %t1 --check-prefix=CHECK-ASM
; RUN: llc %t -function-sections -filetype=obj -o %t2
-; RUN: llvm-readelf -S -g %t2 | FileCheck %s --check-prefix=CHECK-SEC
+; RUN: llvm-objdump --section-headers %t2 | FileCheck %s --check-prefix=CHECK-OBJ
; RUN: llvm-mc %t1 -filetype=obj -o %t3
-; RUN: llvm-readelf -S -g %t3 | FileCheck %s --check-prefix=CHECK-SEC
-
-; RUN: llc %t -function-sections -unique-section-names=0 -filetype=obj -o %t4
-; RUN: llvm-readelf -S %t4 | FileCheck %s --check-prefix=CHECK-SEC2
+; RUN: llvm-objdump --section-headers %t3 | FileCheck %s --check-prefix=CHECK-OBJ
;; Check the generation of pseudoprobe intrinsic call.
@@ -69,13 +66,6 @@ entry:
ret void
}
-$foo3 = comdat any
-
-define void @foo3(i32 %x) comdat {
-entry:
- ret void
-}
-
; CHECK-IL: Function Attrs: nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: readwrite)
; CHECK-IL-NEXT: declare void @llvm.pseudoprobe(i64, i64, i32, i64)
@@ -104,43 +94,9 @@ entry:
; CHECK-ASM-NEXT: .byte 4
; CHECK-ASM-NEXT: .ascii "foo2"
-; CHECK-SEC: [Nr] Name Type {{.*}} ES Flg Lk Inf Al
-; CHECK-SEC: [ 3] .text.foo PROGBITS {{.*}} 00 AX 0 0 16
-; CHECK-SEC: [ 5] .text.foo2 PROGBITS {{.*}} 00 AX 0 0 16
-; CHECK-SEC: [ 8] .text.foo3 PROGBITS {{.*}} 00 AXG 0 0 16
-; CHECK-SEC-COUNT-3: .pseudo_probe_desc PROGBITS
-; CHECK-SEC: .pseudo_probe PROGBITS {{.*}} 00 L 3 0 1
-; CHECK-SEC-NEXT: .pseudo_probe PROGBITS {{.*}} 00 L 5 0 1
-; CHECK-SEC-NEXT: .pseudo_probe PROGBITS {{.*}} 00 LG 8 0 1
-; CHECK-SEC-NOT: .rela.pseudo_probe
-
-; CHECK-SEC: COMDAT group section [ 7] `.group' [foo3] contains 2 sections:
-; CHECK-SEC-NEXT: [Index] Name
-; CHECK-SEC-NEXT: [ 8] .text.foo3
-; CHECK-SEC-NEXT: [ 21] .pseudo_probe
-; CHECK-SEC-EMPTY:
-; CHECK-SEC-NEXT: COMDAT group section [ 10] `.group' [.pseudo_probe_desc_foo] contains 1 sections:
-; CHECK-SEC-NEXT: [Index] Name
-; CHECK-SEC-NEXT: [ 11] .pseudo_probe_desc
-; CHECK-SEC-EMPTY:
-; CHECK-SEC-NEXT: COMDAT group section [ 12] `.group' [.pseudo_probe_desc_foo2] contains 1 sections:
-; CHECK-SEC-NEXT: [Index] Name
-; CHECK-SEC-NEXT: [ 13] .pseudo_probe_desc
-; CHECK-SEC-EMPTY:
-; CHECK-SEC-NEXT: COMDAT group section [ 14] `.group' [.pseudo_probe_desc_foo3] contains 1 sections:
-; CHECK-SEC-NEXT: [Index] Name
-; CHECK-SEC-NEXT: [ 15] .pseudo_probe_desc
-
-
-; CHECK-SEC2: [Nr] Name Type {{.*}} ES Flg Lk Inf Al
-; CHECK-SEC2: [ 3] .text PROGBITS {{.*}} 00 AX 0 0 16
-; CHECK-SEC2: [ 5] .text PROGBITS {{.*}} 00 AX 0 0 16
-; CHECK-SEC2: [ 8] .text PROGBITS {{.*}} 00 AXG 0 0 16
-; CHECK-SEC2-COUNT-3: .pseudo_probe_desc PROGBITS
-; CHECK-SEC2: .pseudo_probe PROGBITS {{.*}} 00 L 3 0 1
-; CHECK-SEC2-NEXT: .pseudo_probe PROGBITS {{.*}} 00 L 5 0 1
-; CHECK-SEC2-NEXT: .pseudo_probe PROGBITS {{.*}} 00 LG 8 0 1
-; CHECK-SEC2-NOT: .rela.pseudo_probe
+; CHECK-OBJ-COUNT-2: .pseudo_probe_desc
+; CHECK-OBJ: .pseudo_probe
+; CHECK-OBJ-NOT: .rela.pseudo_probe
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!9, !10}
--
2.42.0