[llvm] b9a134a - [XRay] Mark Mach-O xray_instr_map and xray_fn_idx as S_ATTR_LIVE_SUPPORT
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 18 19:30:21 PDT 2023
Author: Fangrui Song
Date: 2023-06-18T19:30:16-07:00
New Revision: b9a134aa629de23a1dcf4be32e946e4e308fc64d
URL: https://github.com/llvm/llvm-project/commit/b9a134aa629de23a1dcf4be32e946e4e308fc64d
DIFF: https://github.com/llvm/llvm-project/commit/b9a134aa629de23a1dcf4be32e946e4e308fc64d.diff
LOG: [XRay] Mark Mach-O xray_instr_map and xray_fn_idx as S_ATTR_LIVE_SUPPORT
Add the `S_ATTR_LIVE_SUPPORT` attribute to the sections so that `ld -dead_strip`
will retain subsections that reference live functions, once we we add linker
private "l" symbols as atoms.
Added:
Modified:
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/test/CodeGen/AArch64/xray-attribute-instrumentation.ll
llvm/test/CodeGen/AArch64/xray-omit-function-index.ll
llvm/test/CodeGen/AArch64/xray-partial-instrumentation-skip-entry.ll
llvm/test/CodeGen/AArch64/xray-partial-instrumentation-skip-exit.ll
llvm/test/CodeGen/AArch64/xray-tail-call-sled.ll
llvm/test/CodeGen/ARM/xray-armv6-attribute-instrumentation.ll
llvm/test/CodeGen/ARM/xray-armv7-attribute-instrumentation.ll
llvm/test/CodeGen/X86/xray-attribute-instrumentation.ll
llvm/test/CodeGen/X86/xray-partial-instrumentation-skip-entry.ll
llvm/test/CodeGen/X86/xray-partial-instrumentation-skip-exit.ll
llvm/test/CodeGen/X86/xray-tail-call-sled.ll
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 253c072152376..12766e81a0dbe 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -4016,11 +4016,13 @@ void AsmPrinter::emitXRayTable() {
"xray_fn_idx", ELF::SHT_PROGBITS, Flags | ELF::SHF_WRITE, 0,
GroupName, F.hasComdat(), MCSection::NonUniqueID, LinkedToSym);
} else if (MF->getSubtarget().getTargetTriple().isOSBinFormatMachO()) {
- InstMap = OutContext.getMachOSection("__DATA", "xray_instr_map", 0,
+ InstMap = OutContext.getMachOSection("__DATA", "xray_instr_map",
+ MachO::S_ATTR_LIVE_SUPPORT,
SectionKind::getReadOnlyWithRel());
if (TM.Options.XRayFunctionIndex)
FnSledIndex = OutContext.getMachOSection(
- "__DATA", "xray_fn_idx", 0, SectionKind::getReadOnlyWithRel());
+ "__DATA", "xray_fn_idx", MachO::S_ATTR_LIVE_SUPPORT,
+ SectionKind::getReadOnlyWithRel());
} else {
llvm_unreachable("Unsupported target");
}
diff --git a/llvm/test/CodeGen/AArch64/xray-attribute-instrumentation.ll b/llvm/test/CodeGen/AArch64/xray-attribute-instrumentation.ll
index 6c269869f11c8..f196a5dc89ba4 100644
--- a/llvm/test/CodeGen/AArch64/xray-attribute-instrumentation.ll
+++ b/llvm/test/CodeGen/AArch64/xray-attribute-instrumentation.ll
@@ -21,7 +21,7 @@ define i32 @foo() nounwind noinline uwtable "function-instrument"="xray-always"
; CHECK-LINUX: .xword .Lxray_sled_1
; CHECK-LINUX-LABEL: Lxray_sleds_end0:
-; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map{{$}}
+; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map,regular,live_support{{$}}
; CHECK-MACOS-LABEL: Lxray_sleds_start0:
; CHECK-MACOS: .quad Lxray_sled_0
; CHECK-MACOS: .quad Lxray_sled_1
@@ -47,7 +47,7 @@ define i32 @bar() nounwind noinline uwtable "function-instrument"="xray-never" "
; CHECK-LINUX: .xword .Lxray_sled_3
; CHECK-LINUX-LABEL: Lxray_sleds_end1:
-; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map{{$}}
+; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map,regular,live_support{{$}}
; CHECK-MACOS-LABEL: Lxray_sleds_start1:
; CHECK-MACOS: .quad Lxray_sled_2
; CHECK-MACOS: .quad Lxray_sled_3
@@ -73,7 +73,7 @@ define i32 @instrumented() nounwind noinline uwtable "xray-instruction-threshold
; CHECK-LINUX: .xword .Lxray_sled_5
; CHECK-LINUX-LABEL: Lxray_sleds_end2:
-; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map{{$}}
+; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map,regular,live_support{{$}}
; CHECK-MACOS-LABEL: Lxray_sleds_start2:
; CHECK-MACOS: .quad Lxray_sled_4
; CHECK-MACOS: .quad Lxray_sled_5
diff --git a/llvm/test/CodeGen/AArch64/xray-omit-function-index.ll b/llvm/test/CodeGen/AArch64/xray-omit-function-index.ll
index bc450d726202e..36faabe57ddcb 100644
--- a/llvm/test/CodeGen/AArch64/xray-omit-function-index.ll
+++ b/llvm/test/CodeGen/AArch64/xray-omit-function-index.ll
@@ -31,7 +31,7 @@ define i32 @foo() nounwind noinline uwtable "function-instrument"="xray-always"
; CHECK-LINUX: .xword .Lxray_sled_1
; CHECK-LINUX-LABEL: Lxray_sleds_end0:
-; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map{{$}}
+; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map,regular,live_support{{$}}
; CHECK-MACOS-LABEL: Lxray_sleds_start0:
; CHECK-MACOS: .quad Lxray_sled_0
; CHECK-MACOS: .quad Lxray_sled_1
diff --git a/llvm/test/CodeGen/AArch64/xray-partial-instrumentation-skip-entry.ll b/llvm/test/CodeGen/AArch64/xray-partial-instrumentation-skip-entry.ll
index 00055b5f439ed..ed2d488ed0105 100644
--- a/llvm/test/CodeGen/AArch64/xray-partial-instrumentation-skip-entry.ll
+++ b/llvm/test/CodeGen/AArch64/xray-partial-instrumentation-skip-entry.ll
@@ -22,7 +22,7 @@ define i32 @foo() nounwind noinline uwtable "function-instrument"="xray-always"
; CHECK-LINUX: .xword .Lxray_sled_0
; CHECK-LINUX-LABEL: Lxray_sleds_end0:
-; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map{{$}}
+; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map,regular,live_support{{$}}
; CHECK-MACOS-LABEL: Lxray_sleds_start0:
; CHECK-MACOS: .quad Lxray_sled_0
; CHECK-MACOS-LABEL: Lxray_sleds_end0:
diff --git a/llvm/test/CodeGen/AArch64/xray-partial-instrumentation-skip-exit.ll b/llvm/test/CodeGen/AArch64/xray-partial-instrumentation-skip-exit.ll
index 2097be44d16b6..1908a4e3ab585 100644
--- a/llvm/test/CodeGen/AArch64/xray-partial-instrumentation-skip-exit.ll
+++ b/llvm/test/CodeGen/AArch64/xray-partial-instrumentation-skip-exit.ll
@@ -22,7 +22,7 @@ define i32 @foo() nounwind noinline uwtable "function-instrument"="xray-always"
; CHECK-LINUX: .xword .Lxray_sled_0
; CHECK-LINUX-LABEL: Lxray_sleds_end0:
-; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map{{$}}
+; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map,regular,live_support{{$}}
; CHECK-MACOS-LABEL: Lxray_sleds_start0:
; CHECK-MACOS: .quad Lxray_sled_0
; CHECK-MACOS-LABEL: Lxray_sleds_end0:
diff --git a/llvm/test/CodeGen/AArch64/xray-tail-call-sled.ll b/llvm/test/CodeGen/AArch64/xray-tail-call-sled.ll
index 67de3246c0352..aa3802bfd2495 100644
--- a/llvm/test/CodeGen/AArch64/xray-tail-call-sled.ll
+++ b/llvm/test/CodeGen/AArch64/xray-tail-call-sled.ll
@@ -28,14 +28,14 @@ define i32 @callee() nounwind noinline uwtable "function-instrument"="xray-alway
; CHECK-LINUX: .xword .Lxray_sleds_start0
; CHECK-LINUX-NEXT: .xword .Lxray_sleds_end0
-; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map{{$}}
+; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map,regular,live_support{{$}}
; CHECK-MACOS-LABEL: Lxray_sleds_start0:
; CHECK-MACOS-NEXT: [[TMP:Ltmp[0-9]+]]:
; CHECK-MACOS: .quad Lxray_sled_0-[[TMP]]
; CHECK-MACOS: [[TMP:Ltmp[0-9]+]]:
; CHECK-MACOS-NEXT: .quad Lxray_sled_1-[[TMP]]
; CHECK-MACOS-LABEL: Lxray_sleds_end0:
-; CHECK-MACOS-LABEL: .section __DATA,xray_fn_idx{{$}}
+; CHECK-MACOS-LABEL: .section __DATA,xray_fn_idx,regular,live_support{{$}}
; CHECK-MACOS: .quad Lxray_sleds_start0
; CHECK-MACOS-NEXT: .quad Lxray_sleds_end0
@@ -65,11 +65,11 @@ define i32 @caller() nounwind noinline uwtable "function-instrument"="xray-alway
; CHECK-LINUX: .xword .Lxray_sleds_start1
; CHECK-LINUX-NEXT: .xword .Lxray_sleds_end1
-; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map{{$}}
+; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map,regular,live_support{{$}}
; CHECK-MACOS-LABEL: Lxray_sleds_start1:
; CHECK-MACOS: .quad Lxray_sled_2
; CHECK-MACOS: .quad Lxray_sled_3
; CHECK-MACOS-LABEL: Lxray_sleds_end1:
-; CHECK-MACOS-LABEL: .section __DATA,xray_fn_idx{{$}}
+; CHECK-MACOS-LABEL: .section __DATA,xray_fn_idx,regular,live_support{{$}}
; CHECK-MACOS: .quad Lxray_sleds_start1
; CHECK-MACOS-NEXT: .quad Lxray_sleds_end1
diff --git a/llvm/test/CodeGen/ARM/xray-armv6-attribute-instrumentation.ll b/llvm/test/CodeGen/ARM/xray-armv6-attribute-instrumentation.ll
index b37b22b5c359d..965e1781884d4 100644
--- a/llvm/test/CodeGen/ARM/xray-armv6-attribute-instrumentation.ll
+++ b/llvm/test/CodeGen/ARM/xray-armv6-attribute-instrumentation.ll
@@ -33,11 +33,11 @@ define i32 @foo() nounwind noinline uwtable "function-instrument"="xray-always"
; CHECK-LINUX: .long .Lxray_sleds_start0
; CHECK-LINUX-NEXT: .long .Lxray_sleds_end0
-; CHECK-IOS-LABEL: .section __DATA,xray_instr_map{{$}}
+; CHECK-IOS-LABEL: .section __DATA,xray_instr_map,regular,live_support{{$}}
; CHECK-IOS-LABEL: Lxray_sleds_start0:
; CHECK-IOS: .long Lxray_sled_0
; CHECK-IOS: .long Lxray_sled_1
; CHECK-IOS-LABEL: Lxray_sleds_end0:
-; CHECK-IOS-LABEL: .section __DATA,xray_fn_idx{{$}}
+; CHECK-IOS-LABEL: .section __DATA,xray_fn_idx,regular,live_support{{$}}
; CHECK-IOS: .long Lxray_sleds_start0
; CHECK-IOS-NEXT: .long Lxray_sleds_end0
diff --git a/llvm/test/CodeGen/ARM/xray-armv7-attribute-instrumentation.ll b/llvm/test/CodeGen/ARM/xray-armv7-attribute-instrumentation.ll
index c3be28828be22..1570a87181940 100644
--- a/llvm/test/CodeGen/ARM/xray-armv7-attribute-instrumentation.ll
+++ b/llvm/test/CodeGen/ARM/xray-armv7-attribute-instrumentation.ll
@@ -23,11 +23,11 @@ define i32 @foo() nounwind noinline uwtable "function-instrument"="xray-always"
; CHECK-LINUX: .long .Lxray_sleds_start0
; CHECK-LINUX-NEXT: .long .Lxray_sleds_end0
-; CHECK-IOS-LABEL: .section __DATA,xray_instr_map{{$}}
+; CHECK-IOS-LABEL: .section __DATA,xray_instr_map,regular,live_support{{$}}
; CHECK-IOS-LABEL: Lxray_sleds_start0:
; CHECK-IOS: .long Lxray_sled_0
; CHECK-IOS: .long Lxray_sled_1
; CHECK-IOS-LABEL: Lxray_sleds_end0:
-; CHECK-IOS-LABEL: .section __DATA,xray_fn_idx{{$}}
+; CHECK-IOS-LABEL: .section __DATA,xray_fn_idx,regular,live_support{{$}}
; CHECK-IOS: .long Lxray_sleds_start0
; CHECK-IOS-NEXT: .long Lxray_sleds_end0
diff --git a/llvm/test/CodeGen/X86/xray-attribute-instrumentation.ll b/llvm/test/CodeGen/X86/xray-attribute-instrumentation.ll
index f7137f50f49c1..dad876dfcacae 100644
--- a/llvm/test/CodeGen/X86/xray-attribute-instrumentation.ll
+++ b/llvm/test/CodeGen/X86/xray-attribute-instrumentation.ll
@@ -23,12 +23,12 @@ define i32 @foo() nounwind noinline uwtable "function-instrument"="xray-always"
; CHECK-LINUX: .quad .Lxray_sleds_start0
; CHECK-LINUX-NEXT: .quad .Lxray_sleds_end0
-; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map{{$}}
+; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map,regular,live_support{{$}}
; CHECK-MACOS-LABEL: Lxray_sleds_start0:
; CHECK-MACOS: .quad Lxray_sled_0
; CHECK-MACOS: .quad Lxray_sled_1
; CHECK-MACOS-LABEL: Lxray_sleds_end0:
-; CHECK-MACOS-LABEL: .section __DATA,xray_fn_idx{{$}}
+; CHECK-MACOS-LABEL: .section __DATA,xray_fn_idx,regular,live_support{{$}}
; CHECK-MACOS: .quad Lxray_sleds_start0
; CHECK-MACOS-NEXT: .quad Lxray_sleds_end0
@@ -70,7 +70,7 @@ NotEqual:
; CHECK-LINUX: .quad .Lxray_sleds_start1
; CHECK-LINUX-NEXT: .quad .Lxray_sleds_end1
-; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map{{$}}
+; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map,regular,live_support{{$}}
; CHECK-MACOS-LABEL: Lxray_sleds_start1:
; CHECK-MACOS: [[TMP:Ltmp[0-9]+]]:
; CHECK-MACOS-NEXT: .quad Lxray_sled_2-[[TMP]]
@@ -79,6 +79,6 @@ NotEqual:
; CHECK-MACOS: [[TMP:Ltmp[0-9]+]]:
; CHECK-MACOS-NEXT: .quad Lxray_sled_4-[[TMP]]
; CHECK-MACOS-LABEL: Lxray_sleds_end1:
-; CHECK-MACOS-LABEL: .section __DATA,xray_fn_idx{{$}}
+; CHECK-MACOS-LABEL: .section __DATA,xray_fn_idx,regular,live_support{{$}}
; CHECK-MACOS: .quad Lxray_sleds_start1
; CHECK-MACOS-NEXT: .quad Lxray_sleds_end1
diff --git a/llvm/test/CodeGen/X86/xray-partial-instrumentation-skip-entry.ll b/llvm/test/CodeGen/X86/xray-partial-instrumentation-skip-entry.ll
index 465aab3e32b34..839afb682d57f 100644
--- a/llvm/test/CodeGen/X86/xray-partial-instrumentation-skip-entry.ll
+++ b/llvm/test/CodeGen/X86/xray-partial-instrumentation-skip-entry.ll
@@ -19,11 +19,11 @@ define i32 @foo() nounwind noinline uwtable "function-instrument"="xray-always"
; CHECK-LINUX: .quad .Lxray_sleds_start0
; CHECK-LINUX-NEXT: .quad .Lxray_sleds_end0
-; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map{{$}}
+; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map,regular,live_support{{$}}
; CHECK-MACOS-LABEL: Lxray_sleds_start0:
; CHECK-MACOS: .quad Lxray_sled_0
; CHECK-MACOS-LABEL: Lxray_sleds_end0:
-; CHECK-MACOS-LABEL: .section __DATA,xray_fn_idx{{$}}
+; CHECK-MACOS-LABEL: .section __DATA,xray_fn_idx,regular,live_support{{$}}
; CHECK-MACOS: .quad Lxray_sleds_start0
; CHECK-MACOS-NEXT: .quad Lxray_sleds_end0
@@ -58,11 +58,11 @@ NotEqual:
; CHECK-LINUX: .quad .Lxray_sleds_start1
; CHECK-LINUX-NEXT: .quad .Lxray_sleds_end1
-; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map{{$}}
+; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map,regular,live_support{{$}}
; CHECK-MACOS-LABEL: Lxray_sleds_start1:
; CHECK-MACOS: .quad Lxray_sled_1
; CHECK-MACOS: .quad Lxray_sled_2
; CHECK-MACOS-LABEL: Lxray_sleds_end1:
-; CHECK-MACOS-LABEL: .section __DATA,xray_fn_idx{{$}}
+; CHECK-MACOS-LABEL: .section __DATA,xray_fn_idx,regular,live_support{{$}}
; CHECK-MACOS: .quad Lxray_sleds_start1
; CHECK-MACOS-NEXT: .quad Lxray_sleds_end1
diff --git a/llvm/test/CodeGen/X86/xray-partial-instrumentation-skip-exit.ll b/llvm/test/CodeGen/X86/xray-partial-instrumentation-skip-exit.ll
index 7d9ec92d770e0..a2229c7d78f8f 100644
--- a/llvm/test/CodeGen/X86/xray-partial-instrumentation-skip-exit.ll
+++ b/llvm/test/CodeGen/X86/xray-partial-instrumentation-skip-exit.ll
@@ -21,11 +21,11 @@ define i32 @foo() nounwind noinline uwtable "function-instrument"="xray-always"
; CHECK-LINUX: .quad .Lxray_sleds_start0
; CHECK-LINUX-NEXT: .quad .Lxray_sleds_end0
-; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map{{$}}
+; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map,regular,live_support{{$}}
; CHECK-MACOS-LABEL: Lxray_sleds_start0:
; CHECK-MACOS: .quad Lxray_sled_0
; CHECK-MACOS-LABEL: Lxray_sleds_end0:
-; CHECK-MACOS-LABEL: .section __DATA,xray_fn_idx{{$}}
+; CHECK-MACOS-LABEL: .section __DATA,xray_fn_idx,regular,live_support{{$}}
; CHECK-MACOS: .quad Lxray_sleds_start0
; CHECK-MACOS-NEXT: .quad Lxray_sleds_end0
@@ -58,10 +58,10 @@ NotEqual:
; CHECK-LINUX: .quad .Lxray_sleds_start1
; CHECK-LINUX-NEXT: .quad .Lxray_sleds_end1
-; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map{{$}}
+; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map,regular,live_support{{$}}
; CHECK-MACOS-LABEL: Lxray_sleds_start1:
; CHECK-MACOS: .quad Lxray_sled_1
; CHECK-MACOS-LABEL: Lxray_sleds_end1:
-; CHECK-MACOS-LABEL: .section __DATA,xray_fn_idx{{$}}
+; CHECK-MACOS-LABEL: .section __DATA,xray_fn_idx,regular,live_support{{$}}
; CHECK-MACOS: .quad Lxray_sleds_start1
; CHECK-MACOS-NEXT: .quad Lxray_sleds_end1
diff --git a/llvm/test/CodeGen/X86/xray-tail-call-sled.ll b/llvm/test/CodeGen/X86/xray-tail-call-sled.ll
index d63102696a6ca..b755f610ccd65 100644
--- a/llvm/test/CodeGen/X86/xray-tail-call-sled.ll
+++ b/llvm/test/CodeGen/X86/xray-tail-call-sled.ll
@@ -22,12 +22,12 @@ define dso_local i32 @callee() nounwind noinline uwtable "function-instrument"="
; CHECK-LINUX: .quad .Lxray_sleds_start0
; CHECK-LINUX-NEXT: .quad .Lxray_sleds_end0
-; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map{{$}}
+; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map,regular,live_support{{$}}
; CHECK-MACOS-LABEL: Lxray_sleds_start0:
; CHECK-MACOS: .quad Lxray_sled_0
; CHECK-MACOS: .quad Lxray_sled_1
; CHECK-MACOS-LABEL: Lxray_sleds_end0:
-; CHECK-MACOS-LABEL: .section __DATA,xray_fn_idx{{$}}
+; CHECK-MACOS-LABEL: .section __DATA,xray_fn_idx,regular,live_support{{$}}
; CHECK-MACOS: .quad Lxray_sleds_start0
; CHECK-MACOS-NEXT: .quad Lxray_sleds_end0
@@ -54,11 +54,11 @@ define dso_local i32 @caller() nounwind noinline uwtable "function-instrument"="
; CHECK-LINUX: .quad .Lxray_sleds_start1
; CHECK-LINUX: .quad .Lxray_sleds_end1
-; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map{{$}}
+; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map,regular,live_support{{$}}
; CHECK-MACOS-LABEL: Lxray_sleds_start1:
; CHECK-MACOS: .quad Lxray_sled_2
; CHECK-MACOS: .quad Lxray_sled_3
; CHECK-MACOS-LABEL: Lxray_sleds_end1:
-; CHECK-MACOS-LABEL: .section __DATA,xray_fn_idx{{$}}
+; CHECK-MACOS-LABEL: .section __DATA,xray_fn_idx,regular,live_support{{$}}
; CHECK-MACOS: .quad Lxray_sleds_start1
; CHECK-MACOS: .quad Lxray_sleds_end1
More information about the llvm-commits
mailing list