Skip to content

Commit 68494ae

Browse files
committed
[XRay] xray_fn_idx: fix alignment directive
Use `emitValueToAlignment` as the section does not contain code. `emitCodeAlignment` would lead to ALIGN relocations on RISC-V and LoongArch with linker relaxation. In addition, change the alignment to wordsize, sufficient for the runtime requirement (`XRayFunctionSledIndex`). Related to #147322
1 parent 4d0c25f commit 68494ae

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4628,12 +4628,10 @@ void AsmPrinter::emitXRayTable() {
46284628

46294629
// We then emit a single entry in the index per function. We use the symbols
46304630
// that bound the instrumentation map as the range for a specific function.
4631-
// Each entry here will be 2 * word size aligned, as we're writing down two
4632-
// pointers. This should work for both 32-bit and 64-bit platforms.
4631+
// Each entry contains 2 words and needs to be word-aligned.
46334632
if (FnSledIndex) {
46344633
OutStreamer->switchSection(FnSledIndex);
4635-
OutStreamer->emitCodeAlignment(Align(2 * WordSizeBytes),
4636-
&getSubtargetInfo());
4634+
OutStreamer->emitValueToAlignment(Align(WordSizeBytes));
46374635
// For Mach-O, use an "l" symbol as the atom of this subsection. The label
46384636
// difference uses a SUBTRACTOR external relocation which references the
46394637
// symbol.

llvm/test/CodeGen/PowerPC/xray-attribute-instrumentation.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ define i32 @foo() nounwind noinline uwtable "function-instrument"="xray-always"
4141
; CHECK-NEXT: .space 13
4242
; CHECK-NEXT: .Lxray_sleds_end0:
4343
; CHECK-LABEL: xray_fn_idx,"ao",@progbits,foo{{$}}
44-
; CHECK: .p2align 4
44+
; CHECK: .p2align 3, 0x0
4545
; CHECK-NEXT: [[IDX:.Lxray_fn_idx[0-9]+]]:
4646
; CHECK-NEXT: .quad .Lxray_sleds_start0-[[IDX]]
4747
; CHECK-NEXT: .quad 2

llvm/test/CodeGen/SystemZ/xray.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ define signext i32 @foo() "function-instrument"="xray-always" {
3838
; CHECK: .space 13
3939
; CHECK: .Lxray_sleds_end0:
4040
; CHECK: .section xray_fn_idx,"ao",@progbits,foo
41-
; CHECK: .p2align 4
41+
; CHECK: .p2align 3, 0
4242
; CHECK: .Lxray_fn_idx0:
4343
; CHECK: .quad .Lxray_sleds_start0-.Lxray_fn_idx0
4444
; CHECK: .quad 2

llvm/test/CodeGen/X86/xray-attribute-instrumentation.ll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ define i32 @foo() nounwind noinline uwtable "function-instrument"="xray-always"
2020
; CHECK-LINUX: .quad .Lxray_sled_1
2121
; CHECK-LINUX-LABEL: .Lxray_sleds_end0:
2222
; CHECK-LINUX-LABEL: .section xray_fn_idx,"ao",@progbits,foo{{$}}
23-
; CHECK-LINUX: [[IDX:\.Lxray_fn_idx[0-9]+]]:
23+
; CHECK-LINUX-NEXT: .p2align 3, 0x0
24+
; CHECK-LINUX-NEXT: [[IDX:\.Lxray_fn_idx[0-9]+]]:
2425
; CHECK-LINUX-NEXT: .quad .Lxray_sleds_start0-[[IDX]]
2526
; CHECK-LINUX-NEXT: .quad 2
2627

0 commit comments

Comments
 (0)