Revert "[SafeStack][DebugInfo] Insert DW_OP_deref in correct location"

This reverts commit 2d3174c4df.

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.
This commit is contained in:
Jeremy Morse 2020-02-05 15:19:00 +00:00
parent d6da8a1d94
commit ed5998d21e
5 changed files with 40 additions and 71 deletions

View File

@ -650,8 +650,8 @@ bool LDVImpl::handleDebugValue(MachineInstr &MI, SlotIndex Idx) {
}
// Get or create the UserValue for (variable,offset) here.
assert((!MI.getOperand(1).isImm() || MI.getOperand(1).getImm() == 0) &&
"DBG_VALUE with nonzero offset");
assert(!MI.getOperand(1).isImm() && "DBG_VALUE with indirect flag before "
"LiveDebugVariables");
const DILocalVariable *Var = MI.getDebugVariable();
const DIExpression *Expr = MI.getDebugExpression();
UserValue *UV =

View File

@ -751,9 +751,9 @@ InstrEmitter::EmitDbgValue(SDDbgValue *SD,
// Indirect addressing is indicated by an Imm as the second parameter.
if (SD->isIndirect())
MIB.addImm(0U);
else
MIB.addReg(0U, RegState::Debug);
Expr = DIExpression::append(Expr, {dwarf::DW_OP_deref});
MIB.addReg(0U, RegState::Debug);
MIB.addMetadata(Var);
MIB.addMetadata(Expr);

View File

@ -51,28 +51,39 @@
; CHECK: SizeOf: 0
; CHECK: Name:
; CHECK: }
; CHECK: Array (0x1004) {
; CHECK: Pointer (0x1004) {
; CHECK: TypeLeafKind: LF_POINTER (0x1002)
; CHECK: PointeeType: 0x1003
; CHECK: PtrType: Near32 (0xA)
; CHECK: PtrMode: LValueReference (0x1)
; CHECK: IsFlat: 0
; CHECK: IsConst: 0
; CHECK: IsVolatile: 0
; CHECK: IsUnaligned: 0
; CHECK: SizeOf: 0
; CHECK: }
; CHECK: Array (0x1005) {
; CHECK: TypeLeafKind: LF_ARRAY (0x1503)
; CHECK: ElementType: char (0x70)
; CHECK: IndexType: unsigned long (0x22)
; CHECK: SizeOf: 7
; CHECK: Name:
; CHECK: }
; CHECK: Array (0x1005) {
; CHECK: TypeLeafKind: LF_ARRAY (0x1503)
; CHECK: ElementType: 0x1004
; CHECK: IndexType: unsigned long (0x22)
; CHECK: SizeOf: 35
; CHECK: Name:
; CHECK: }
; CHECK: Array (0x1006) {
; CHECK: TypeLeafKind: LF_ARRAY (0x1503)
; CHECK: ElementType: 0x1005
; CHECK: IndexType: unsigned long (0x22)
; CHECK: SizeOf: 35
; CHECK: Name:
; CHECK: }
; CHECK: Array (0x1007) {
; CHECK: TypeLeafKind: LF_ARRAY (0x1503)
; CHECK: ElementType: 0x1006
; CHECK: IndexType: unsigned long (0x22)
; CHECK: SizeOf: 70
; CHECK: Name:
; CHECK: }
; CHECK: Struct (0x1007) {
; CHECK: Struct (0x1008) {
; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505)
; CHECK: MemberCount: 0
; CHECK: Properties [ (0x280)
@ -86,16 +97,16 @@
; CHECK: Name: incomplete_struct
; CHECK: LinkageName: .?AUincomplete_struct@@
; CHECK: }
; CHECK: Array (0x1008) {
; CHECK: Array (0x1009) {
; CHECK: TypeLeafKind: LF_ARRAY (0x1503)
; CHECK: ElementType: incomplete_struct (0x1007)
; CHECK: ElementType: incomplete_struct (0x1008)
; CHECK: IndexType: unsigned long (0x22)
; CHECK: SizeOf: 12
; CHECK: Name:
; CHECK: }
; CHECK: Pointer (0x1009) {
; CHECK: Pointer (0x100A) {
; CHECK: TypeLeafKind: LF_POINTER (0x1002)
; CHECK: PointeeType: 0x1008
; CHECK: PointeeType: 0x1009
; CHECK: PtrType: Near32 (0xA)
; CHECK: PtrMode: Pointer (0x0)
; CHECK: IsFlat: 0
@ -104,7 +115,7 @@
; CHECK: IsUnaligned: 0
; CHECK: SizeOf: 4
; CHECK: }
; CHECK: FieldList (0x100A) {
; CHECK: FieldList (0x100B) {
; CHECK: TypeLeafKind: LF_FIELDLIST (0x1203)
; CHECK: DataMember {
; CHECK: TypeLeafKind: LF_MEMBER (0x150D)
@ -114,31 +125,31 @@
; CHECK: Name: s1
; CHECK: }
; CHECK: }
; CHECK: Struct (0x100B) {
; CHECK: Struct (0x100C) {
; CHECK: TypeLeafKind: LF_STRUCTURE (0x1505)
; CHECK: MemberCount: 1
; CHECK: Properties [ (0x200)
; CHECK: HasUniqueName (0x200)
; CHECK: ]
; CHECK: FieldList: <field list> (0x100A)
; CHECK: FieldList: <field list> (0x100B)
; CHECK: DerivedFrom: 0x0
; CHECK: VShape: 0x0
; CHECK: SizeOf: 4
; CHECK: Name: incomplete_struct
; CHECK: LinkageName: .?AUincomplete_struct@@
; CHECK: }
; CHECK: StringId (0x100C) {
; CHECK: StringId (0x100D) {
; CHECK: TypeLeafKind: LF_STRING_ID (0x1605)
; CHECK: Id: 0x0
; CHECK: StringData: /t.cpp
; CHECK: }
; CHECK: UdtSourceLine (0x100D) {
; CHECK: UdtSourceLine (0x100E) {
; CHECK: TypeLeafKind: LF_UDT_SRC_LINE (0x1606)
; CHECK: UDT: incomplete_struct (0x100B)
; CHECK: SourceFile: /t.cpp (0x100C)
; CHECK: UDT: incomplete_struct (0x100C)
; CHECK: SourceFile: /t.cpp (0x100D)
; CHECK: LineNumber: 4
; CHECK: }
; CHECK: Modifier (0x100E) {
; CHECK: Modifier (0x100F) {
; CHECK: TypeLeafKind: LF_MODIFIER (0x1001)
; CHECK: ModifiedType: int (0x74)
; CHECK: Modifiers [ (0x3)
@ -146,9 +157,9 @@
; CHECK: Volatile (0x2)
; CHECK: ]
; CHECK: }
; CHECK: Array (0x100F) {
; CHECK: Array (0x1010) {
; CHECK: TypeLeafKind: LF_ARRAY (0x1503)
; CHECK: ElementType: const volatile int (0x100E)
; CHECK: ElementType: const volatile int (0x100F)
; CHECK: IndexType: unsigned long (0x22)
; CHECK: SizeOf: 16
; CHECK: Name:

View File

@ -14,7 +14,7 @@
; }
; CHECK: ![[ZZZ:.*]] = !DILocalVariable(name: "zzz",
; CHECK: DBG_VALUE {{.*}} ![[ZZZ]], !DIExpression(DW_OP_constu, 400, DW_OP_minus)
; CHECK: DBG_VALUE {{.*}} ![[ZZZ]], !DIExpression(DW_OP_constu, 400, DW_OP_minus, DW_OP_deref)
%struct.S = type { [100 x i32] }

View File

@ -1,42 +0,0 @@
; This test prevents a regression of PR44585 where the DW_OP_deref is incorrectly placed at the end of the expression chain.
; RUN: llc -O0 -mtriple=x86_64-unknown-linux-gnu -filetype=obj %s -o - | llvm-dwarfdump - --name=value | FileCheck %s
; REQUIRES: object-emission
; CHECK: DW_TAG_variable
; CHECK-NEXT: DW_AT_location
; CHECK-NEXT: DW_OP_breg{{[0-9]+}} R{{[0-9A-Z]+}}-8
; CHECK-NEXT: DW_OP_breg{{[0-9]+}} R{{[0-9A-Z]+}}+8, DW_OP_deref, DW_OP_lit8, DW_OP_minus
; CHECK-NEXT: DW_AT_name ("value")
define dso_local void @_Z4funcv() safestack !dbg !7 {
%1 = alloca i8, align 8
call void @llvm.dbg.declare(metadata i8* %1, metadata !11, metadata !DIExpression()), !dbg !22
call void @extern_func(i8* %1), !dbg !22
ret void
}
declare void @llvm.dbg.declare(metadata, metadata, metadata)
declare void @extern_func(i8* %0)
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!4}
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, emissionKind: FullDebug)
!1 = !DIFile(filename: "/tmp/test3.cpp", directory: "")
!4 = !{i32 2, !"Debug Info Version", i32 3}
!7 = distinct !DISubprogram(name: "func", linkageName: "_Z4funcv", scope: !8, file: !8, line: 7, type: !9, scopeLine: 7, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0)
!8 = !DIFile(filename: "/tmp/test3.cpp", directory: "")
!9 = !DISubroutineType(types: !10)
!10 = !{null}
!11 = !DILocalVariable(name: "value", scope: !7, file: !8, line: 8, type: !12)
!12 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "A", file: !8, line: 1, size: 64, flags: DIFlagTypePassByValue | DIFlagNonTrivial, elements: !13, identifier: "_ZTS1A")
!13 = !{!14, !18}
!14 = !DIDerivedType(tag: DW_TAG_member, name: "c", scope: !12, file: !8, line: 4, baseType: !15, size: 64, flags: DIFlagPublic)
!15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !16, size: 64)
!16 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !17)
!17 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
!18 = !DISubprogram(name: "A", scope: !12, file: !8, line: 3, type: !19, scopeLine: 3, flags: DIFlagPublic | DIFlagPrototyped, spFlags: 0)
!19 = !DISubroutineType(types: !20)
!20 = !{null, !21, !15}
!21 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
!22 = !DILocation(line: 8, column: 5, scope: !7)