llvm.org GIT mirror llvm / 0749000
X86FrameLowering: Fix getFrameIndexReference() for 'fixed' objects Debug information is calculated with getFrameIndexReference() which was missing some logic for the fixed object cases (= parameters on the stack). rdar://24557797 Differential Revision: https://reviews.llvm.org/D32204 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300781 91177308-0d34-0410-b5e6-96231b3b80d8 Matthias Braun 3 years ago
3 changed file(s) with 83 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
16971697 }
16981698 }
16991699
1700 // NOTE: this only has a subset of the full frame index logic. In
1701 // particular, the FI < 0 and AfterFPPop logic is handled in
1702 // X86RegisterInfo::eliminateFrameIndex, but not here. Possibly
1703 // (probably?) it should be moved into here.
17041700 int X86FrameLowering::getFrameIndexReference(const MachineFunction &MF, int FI,
17051701 unsigned &FrameReg) const {
17061702 const MachineFrameInfo &MFI = MF.getFrameInfo();
17071703
1704 bool IsFixed = MFI.isFixedObjectIndex(FI);
17081705 // We can't calculate offset from frame pointer if the stack is realigned,
17091706 // so enforce usage of stack/base pointer. The base pointer is used when we
17101707 // have dynamic allocas in addition to dynamic realignment.
17111708 if (TRI->hasBasePointer(MF))
1712 FrameReg = TRI->getBaseRegister();
1709 FrameReg = IsFixed ? TRI->getFramePtr() : TRI->getBaseRegister();
17131710 else if (TRI->needsStackRealignment(MF))
1714 FrameReg = TRI->getStackRegister();
1711 FrameReg = IsFixed ? TRI->getFramePtr() : TRI->getStackRegister();
17151712 else
17161713 FrameReg = TRI->getFrameRegister(MF);
17171714
132132 unsigned getPtrSizedFrameRegister(const MachineFunction &MF) const;
133133 unsigned getStackRegister() const { return StackPtr; }
134134 unsigned getBaseRegister() const { return BasePtr; }
135 /// Returns physical register used as frame pointer.
136 /// This will always returns the frame pointer register, contrary to
137 /// getFrameRegister() which returns the "base pointer" in situations
138 /// involving a stack, frame and base pointer.
139 unsigned getFramePtr() const { return FramePtr; }
135140 // FIXME: Move to FrameInfok
136141 unsigned getSlotSize() const { return SlotSize; }
137142 };
0 ; RUN: llc -o - %s | FileCheck %s
1 ; This test checks that parameters on the stack pointer are correctly
2 ; referenced by debug info.
3 target triple = "x86_64--"
4
5 @glob = external global i64
6 @ptr = external global i32*
7 %struct.s = type { i32, i32, i32, i32, i32 }
8
9 ; CHECK-LABEL: f0:
10 ; CHECK: DEBUG_VALUE: f:input <- [%RSP+8]
11 define i32 @f0(%struct.s* byval align 8 %input) !dbg !8 {
12 call void @llvm.dbg.declare(metadata %struct.s* %input, metadata !4, metadata !17), !dbg !18
13 ret i32 42
14 }
15
16 ; CHECK-LABEL: f1:
17 ; CHECK: DEBUG_VALUE: f:input <- [%RBP+16]
18 define i32 @f1(%struct.s* byval align 8 %input) !dbg !8 {
19 %val = load i64, i64* @glob
20 ; this alloca should force FP usage.
21 %stackspace = alloca i32, i64 %val, align 1
22 store i32* %stackspace, i32** @ptr
23 call void @llvm.dbg.declare(metadata %struct.s* %input, metadata !4, metadata !17), !dbg !18
24 ret i32 42
25 }
26
27 ; CHECK-LABEL: f2:
28 ; Just check that we are indeed aligning the stack and setting up a base pointer
29 ; in RBX.
30 ; CHECK: pushq %rbp
31 ; CHECK: movq %rsp, %rbp
32 ; CHECK: pushq %rbx
33 ; CHECK: andq $-64, %rsp
34 ; CHECK: subq $64, %rsp
35 ; CHECK: movq %rsp, %rbx
36 ; The parameter should still be referenced through RBP though.
37 ; CHECK-NOT: DEBUG_VALUE: f:input <- [%RBX
38 ; CHECK: DEBUG_VALUE: f:input <- [%RBP+16]
39 define i32 @f2(%struct.s* byval align 8 %input) !dbg !8 {
40 %val = load i64, i64* @glob
41 %stackspace = alloca i32, i64 %val, align 64
42 store i32* %stackspace, i32** @ptr
43 call void @llvm.dbg.declare(metadata %struct.s* %input, metadata !4, metadata !17), !dbg !18
44 ret i32 42
45 }
46
47 declare void @llvm.dbg.declare(metadata, metadata, metadata)
48
49 !llvm.dbg.cu = !{!2}
50 !llvm.module.flags = !{!0, !1}
51
52 !0 = !{i32 2, !"Dwarf Version", i32 4}
53 !1 = !{i32 2, !"Debug Info Version", i32 3}
54 !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3)
55 !3 = !DIFile(filename: "dbg-baseptr.ll", directory: "/")
56 !4 = !DILocalVariable(name: "input", arg: 1, scope: !8, file: !3, line: 5, type: !9)
57 !5 = !{}
58
59 !6 = !DISubroutineType(types: !7)
60 !7 = !{!10, !9}
61
62 !8 = distinct !DISubprogram(name: "f", file: !3, line: 5, type: !6, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, unit: !2, variables: !5)
63
64 !9 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "s", elements: !11)
65 !10 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
66 !11 = !{!12, !13, !14, !15, !16}
67 !12 = !DIDerivedType(tag: DW_TAG_member, name: "a", baseType: !10, size: 32)
68 !13 = !DIDerivedType(tag: DW_TAG_member, name: "b", baseType: !10, size: 32, offset: 32)
69 !14 = !DIDerivedType(tag: DW_TAG_member, name: "c", baseType: !10, size: 32, offset: 64)
70 !15 = !DIDerivedType(tag: DW_TAG_member, name: "d", baseType: !10, size: 32, offset: 96)
71 !16 = !DIDerivedType(tag: DW_TAG_member, name: "e", baseType: !10, size: 32, offset: 128)
72
73 !17 = !DIExpression()
74 !18 = !DILocation(line: 5, scope: !8)