[PATCH] D143618: [X86] Fix for offsets of CFA directives
Theodoros Kasampalis via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 15 13:38:13 PST 2023
theo25 updated this revision to Diff 497781.
theo25 added a comment.
I have added a test to showcase the issue this diff resolves. Previously, the generated DWARF directives were erroneously using an offset of 16 instead of the correct offset of 8176.
I have also applied some linting changes suggested by `clang-format`.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D143618/new/
https://reviews.llvm.org/D143618
Files:
llvm/lib/Target/X86/X86FrameLowering.cpp
llvm/test/CodeGen/X86/tailcc-dwarf.ll
Index: llvm/test/CodeGen/X86/tailcc-dwarf.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/X86/tailcc-dwarf.ll
@@ -0,0 +1,47 @@
+; RUN: llc -mtriple=x86_64-unknown-linux-gnu -O0 --frame-pointer=non-leaf %s -o - | FileCheck %s
+
+%block = type { %blockheader, [0 x i64*] }
+%blockheader = type { i64 }
+
+define void @scanStackRoots(i32) {
+ ret void
+}
+
+define i32 @main(i32 %argc, i8** %argv) {
+entry:
+ %0 = call tailcc %block* @apply_rule_6870(%block* null, %block* null)
+ ret i32 0
+}
+
+define internal tailcc %block* @apply_rule_6870(%block* %0, %block* %1) {
+entry:
+ %2 = tail call tailcc %block* @sender12(%block* %0, %block* %1)
+ ret %block* null
+}
+
+define internal tailcc %block* @sender12(%block* %0, %block* %1) {
+; CHECK-LABEL: sender12:
+; CHECK: .cfi_startproc
+; CHECK: subq $8160, %rsp
+; CHECK: pushq %rbp
+; CHECK: .cfi_def_cfa_offset 8176
+; CHECK: .cfi_offset %rbp, -8176
+entry:
+ %a = alloca [1024 x i32]
+ %b = load [1024 x i32], [1024 x i32]* %a
+ call void @scanStackRoots(i32 1)
+ %2 = tail call tailcc %block* @apply_rule_6300(%block* %0, %block* %1, [1024 x i32] %b)
+ ret %block* %2
+}
+
+define internal tailcc %block* @apply_rule_6300(%block* %0, %block* %1, [1024 x i32] %2) {
+entry:
+ %3 = tail call tailcc %block* @sender4(%block* %0, %block* %1)
+ ret %block* %3
+}
+
+define internal tailcc %block* @sender4(%block* %0, %block* %1) {
+entry:
+ call void @scanStackRoots(i32 2)
+ ret %block* null
+}
Index: llvm/lib/Target/X86/X86FrameLowering.cpp
===================================================================
--- llvm/lib/Target/X86/X86FrameLowering.cpp
+++ llvm/lib/Target/X86/X86FrameLowering.cpp
@@ -1649,14 +1649,16 @@
// Define the current CFA rule to use the provided offset.
assert(StackSize);
BuildCFI(MBB, MBBI, DL,
- MCCFIInstruction::cfiDefCfaOffset(nullptr, -2 * stackGrowth),
+ MCCFIInstruction::cfiDefCfaOffset(
+ nullptr, -2 * stackGrowth + (int)TailCallArgReserveSize),
MachineInstr::FrameSetup);
// Change the rule for the FramePtr to be an "offset" rule.
unsigned DwarfFramePtr = TRI->getDwarfRegNum(MachineFramePtr, true);
BuildCFI(MBB, MBBI, DL,
MCCFIInstruction::createOffset(nullptr, DwarfFramePtr,
- 2 * stackGrowth),
+ 2 * stackGrowth -
+ (int)TailCallArgReserveSize),
MachineInstr::FrameSetup);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143618.497781.patch
Type: text/x-patch
Size: 2633 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230215/8483cef0/attachment.bin>
More information about the llvm-commits
mailing list