Skip to content

Commit ed5998d

Browse files
committed
Revert "[SafeStack][DebugInfo] Insert DW_OP_deref in correct location"
This reverts commit 2d3174c. The overall solution for this problem is reverting D68945, which wasn't handling the -O0 path through the codegen backend correctly. See: discussion in D73526.
1 parent d6da8a1 commit ed5998d

File tree

5 files changed

+37
-68
lines changed

5 files changed

+37
-68
lines changed

llvm/lib/CodeGen/LiveDebugVariables.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -650,8 +650,8 @@ bool LDVImpl::handleDebugValue(MachineInstr &MI, SlotIndex Idx) {
650650
}
651651

652652
// Get or create the UserValue for (variable,offset) here.
653-
assert((!MI.getOperand(1).isImm() || MI.getOperand(1).getImm() == 0) &&
654-
"DBG_VALUE with nonzero offset");
653+
assert(!MI.getOperand(1).isImm() && "DBG_VALUE with indirect flag before "
654+
"LiveDebugVariables");
655655
const DILocalVariable *Var = MI.getDebugVariable();
656656
const DIExpression *Expr = MI.getDebugExpression();
657657
UserValue *UV =

llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -751,9 +751,9 @@ InstrEmitter::EmitDbgValue(SDDbgValue *SD,
751751

752752
// Indirect addressing is indicated by an Imm as the second parameter.
753753
if (SD->isIndirect())
754-
MIB.addImm(0U);
755-
else
756-
MIB.addReg(0U, RegState::Debug);
754+
Expr = DIExpression::append(Expr, {dwarf::DW_OP_deref});
755+
756+
MIB.addReg(0U, RegState::Debug);
757757

758758
MIB.addMetadata(Var);
759759
MIB.addMetadata(Expr);

llvm/test/DebugInfo/COFF/types-array-advanced.ll

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -51,28 +51,39 @@
5151
; CHECK: SizeOf: 0
5252
; CHECK: Name:
5353
; CHECK: }
54-
; CHECK: Array (0x1004) {
54+
; CHECK: Pointer (0x1004) {
55+
; CHECK: TypeLeafKind: LF_POINTER (0x1002)
56+
; CHECK: PointeeType: 0x1003
57+
; CHECK: PtrType: Near32 (0xA)
58+
; CHECK: PtrMode: LValueReference (0x1)
59+
; CHECK: IsFlat: 0
60+
; CHECK: IsConst: 0
61+
; CHECK: IsVolatile: 0
62+
; CHECK: IsUnaligned: 0
63+
; CHECK: SizeOf: 0
64+
; CHECK: }
65+
; CHECK: Array (0x1005) {
5566
; CHECK: TypeLeafKind: LF_ARRAY (0x1503)
5667
; CHECK: ElementType: char (0x70)
5768
; CHECK: IndexType: unsigned long (0x22)
5869
; CHECK: SizeOf: 7
5970
; CHECK: Name:
6071
; CHECK: }
61-
; CHECK: Array (0x1005) {
72+
; CHECK: Array (0x1006) {
6273
; CHECK: TypeLeafKind: LF_ARRAY (0x1503)
63-
; CHECK: ElementType: 0x1004
74+
; CHECK: ElementType: 0x1005
6475
; CHECK: IndexType: unsigned long (0x22)
6576
; CHECK: SizeOf: 35
6677
; CHECK: Name:
6778
; CHECK: }
68-
; CHECK: Array (0x1006) {
79+
; CHECK: Array (0x1007) {
6980
; CHECK: TypeLeafKind: LF_ARRAY (0x1503)
70-
; CHECK: ElementType: 0x1005
81+
; CHECK: ElementType: 0x1006
7182
; CHECK: IndexType: unsigned long (0x22)
7283
; CHECK: SizeOf: 70
7384
; CHECK: Name:
7485
; CHECK: }
75-
; CHECK: Struct (0x1007) {
86+
; CHECK: Struct (0x1008) {
7687
; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505)
7788
; CHECK: MemberCount: 0
7889
; CHECK: Properties [ (0x280)
@@ -86,16 +97,16 @@
8697
; CHECK: Name: incomplete_struct
8798
; CHECK: LinkageName: .?AUincomplete_struct@@
8899
; CHECK: }
89-
; CHECK: Array (0x1008) {
100+
; CHECK: Array (0x1009) {
90101
; CHECK: TypeLeafKind: LF_ARRAY (0x1503)
91-
; CHECK: ElementType: incomplete_struct (0x1007)
102+
; CHECK: ElementType: incomplete_struct (0x1008)
92103
; CHECK: IndexType: unsigned long (0x22)
93104
; CHECK: SizeOf: 12
94105
; CHECK: Name:
95106
; CHECK: }
96-
; CHECK: Pointer (0x1009) {
107+
; CHECK: Pointer (0x100A) {
97108
; CHECK: TypeLeafKind: LF_POINTER (0x1002)
98-
; CHECK: PointeeType: 0x1008
109+
; CHECK: PointeeType: 0x1009
99110
; CHECK: PtrType: Near32 (0xA)
100111
; CHECK: PtrMode: Pointer (0x0)
101112
; CHECK: IsFlat: 0
@@ -104,7 +115,7 @@
104115
; CHECK: IsUnaligned: 0
105116
; CHECK: SizeOf: 4
106117
; CHECK: }
107-
; CHECK: FieldList (0x100A) {
118+
; CHECK: FieldList (0x100B) {
108119
; CHECK: TypeLeafKind: LF_FIELDLIST (0x1203)
109120
; CHECK: DataMember {
110121
; CHECK: TypeLeafKind: LF_MEMBER (0x150D)
@@ -114,41 +125,41 @@
114125
; CHECK: Name: s1
115126
; CHECK: }
116127
; CHECK: }
117-
; CHECK: Struct (0x100B) {
128+
; CHECK: Struct (0x100C) {
118129
; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505)
119130
; CHECK: MemberCount: 1
120131
; CHECK: Properties [ (0x200)
121132
; CHECK: HasUniqueName (0x200)
122133
; CHECK: ]
123-
; CHECK: FieldList: <field list> (0x100A)
134+
; CHECK: FieldList: <field list> (0x100B)
124135
; CHECK: DerivedFrom: 0x0
125136
; CHECK: VShape: 0x0
126137
; CHECK: SizeOf: 4
127138
; CHECK: Name: incomplete_struct
128139
; CHECK: LinkageName: .?AUincomplete_struct@@
129140
; CHECK: }
130-
; CHECK: StringId (0x100C) {
141+
; CHECK: StringId (0x100D) {
131142
; CHECK: TypeLeafKind: LF_STRING_ID (0x1605)
132143
; CHECK: Id: 0x0
133144
; CHECK: StringData: /t.cpp
134145
; CHECK: }
135-
; CHECK: UdtSourceLine (0x100D) {
146+
; CHECK: UdtSourceLine (0x100E) {
136147
; CHECK: TypeLeafKind: LF_UDT_SRC_LINE (0x1606)
137-
; CHECK: UDT: incomplete_struct (0x100B)
138-
; CHECK: SourceFile: /t.cpp (0x100C)
148+
; CHECK: UDT: incomplete_struct (0x100C)
149+
; CHECK: SourceFile: /t.cpp (0x100D)
139150
; CHECK: LineNumber: 4
140151
; CHECK: }
141-
; CHECK: Modifier (0x100E) {
152+
; CHECK: Modifier (0x100F) {
142153
; CHECK: TypeLeafKind: LF_MODIFIER (0x1001)
143154
; CHECK: ModifiedType: int (0x74)
144155
; CHECK: Modifiers [ (0x3)
145156
; CHECK: Const (0x1)
146157
; CHECK: Volatile (0x2)
147158
; CHECK: ]
148159
; CHECK: }
149-
; CHECK: Array (0x100F) {
160+
; CHECK: Array (0x1010) {
150161
; CHECK: TypeLeafKind: LF_ARRAY (0x1503)
151-
; CHECK: ElementType: const volatile int (0x100E)
162+
; CHECK: ElementType: const volatile int (0x100F)
152163
; CHECK: IndexType: unsigned long (0x22)
153164
; CHECK: SizeOf: 16
154165
; CHECK: Name:

llvm/test/DebugInfo/X86/safestack-byval.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
; }
1515

1616
; CHECK: ![[ZZZ:.*]] = !DILocalVariable(name: "zzz",
17-
; CHECK: DBG_VALUE {{.*}} ![[ZZZ]], !DIExpression(DW_OP_constu, 400, DW_OP_minus)
17+
; CHECK: DBG_VALUE {{.*}} ![[ZZZ]], !DIExpression(DW_OP_constu, 400, DW_OP_minus, DW_OP_deref)
1818

1919
%struct.S = type { [100 x i32] }
2020

llvm/test/DebugInfo/X86/safestack-deref.ll

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)