From: Reid Kleckner Date: Wed, 23 Aug 2017 20:31:27 +0000 (+0000) Subject: Parse and print DIExpressions inline to ease IR and MIR testing X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a5b2af0eae4529b17c52b45d6f8071bb80ede86d;p=llvm Parse and print DIExpressions inline to ease IR and MIR testing Summary: Most DIExpressions are empty or very simple. When they are complex, they tend to be unique, so checking them inline is reasonable. This also avoids the need for CodeGen passes to append to the llvm.dbg.mir named md node. See also PR22780, for making DIExpression not be an MDNode. Reviewers: aprantl, dexonsmith, dblaikie Subscribers: qcolombet, javed.absar, eraman, hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D37075 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311594 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index 828f873d37b..a5f4dd73d30 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -643,11 +643,18 @@ bool LLParser::ParseNamedMetadata() { NamedMDNode *NMD = M->getOrInsertNamedMetadata(Name); if (Lex.getKind() != lltok::rbrace) do { - if (ParseToken(lltok::exclaim, "Expected '!' here")) - return true; - MDNode *N = nullptr; - if (ParseMDNodeID(N)) return true; + // Parse DIExpressions inline as a special case. They are still MDNodes, + // so they can still appear in named metadata. Remove this logic if they + // become plain Metadata. + if (Lex.getKind() == lltok::MetadataVar && + Lex.getStrVal() == "DIExpression") { + if (ParseDIExpression(N, /*IsDistinct=*/false)) + return true; + } else if (ParseToken(lltok::exclaim, "Expected '!' here") || + ParseMDNodeID(N)) { + return true; + } NMD->addOperand(N); } while (EatIfPresent(lltok::comma)); diff --git a/lib/CodeGen/MIRParser/MILexer.cpp b/lib/CodeGen/MIRParser/MILexer.cpp index 58a655a4dee..25f48368af5 100644 --- a/lib/CodeGen/MIRParser/MILexer.cpp +++ b/lib/CodeGen/MIRParser/MILexer.cpp @@ -490,6 +490,7 @@ static MIToken::TokenKind getMetadataKeywordKind(StringRef Identifier) { .Case("!alias.scope", MIToken::md_alias_scope) .Case("!noalias", MIToken::md_noalias) .Case("!range", MIToken::md_range) + .Case("!DIExpression", MIToken::md_diexpr) .Default(MIToken::Error); } diff --git a/lib/CodeGen/MIRParser/MILexer.h b/lib/CodeGen/MIRParser/MILexer.h index 08b82e59c4f..c203d2c4817 100644 --- a/lib/CodeGen/MIRParser/MILexer.h +++ b/lib/CodeGen/MIRParser/MILexer.h @@ -100,6 +100,7 @@ struct MIToken { md_alias_scope, md_noalias, md_range, + md_diexpr, // Identifier tokens Identifier, diff --git a/lib/CodeGen/MIRParser/MIParser.cpp b/lib/CodeGen/MIRParser/MIParser.cpp index c68d87b15a3..5d68d4463a6 100644 --- a/lib/CodeGen/MIRParser/MIParser.cpp +++ b/lib/CodeGen/MIRParser/MIParser.cpp @@ -39,6 +39,7 @@ #include "llvm/IR/BasicBlock.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DataLayout.h" +#include "llvm/IR/DebugInfoMetadata.h" #include "llvm/IR/DebugLoc.h" #include "llvm/IR/Function.h" #include "llvm/IR/InstrTypes.h" @@ -209,6 +210,7 @@ public: bool parseJumpTableIndexOperand(MachineOperand &Dest); bool parseExternalSymbolOperand(MachineOperand &Dest); bool parseMDNode(MDNode *&Node); + bool parseDIExpression(MDNode *&Node); bool parseMetadataOperand(MachineOperand &Dest); bool parseCFIOffset(int &Offset); bool parseCFIRegister(unsigned &Reg); @@ -854,10 +856,14 @@ bool MIParser::parseStandaloneStackObject(int &FI) { bool MIParser::parseStandaloneMDNode(MDNode *&Node) { lex(); - if (Token.isNot(MIToken::exclaim)) + if (Token.is(MIToken::exclaim)) { + if (parseMDNode(Node)) + return true; + } else if (Token.is(MIToken::md_diexpr)) { + if (parseDIExpression(Node)) + return true; + } else return error("expected a metadata node"); - if (parseMDNode(Node)) - return true; if (Token.isNot(MIToken::Eof)) return error("expected end of string after the metadata node"); return false; @@ -1492,6 +1498,7 @@ bool MIParser::parseSubRegisterIndexOperand(MachineOperand &Dest) { bool MIParser::parseMDNode(MDNode *&Node) { assert(Token.is(MIToken::exclaim)); + auto Loc = Token.location(); lex(); if (Token.isNot(MIToken::IntegerLiteral) || Token.integerValue().isSigned()) @@ -1507,10 +1514,56 @@ bool MIParser::parseMDNode(MDNode *&Node) { return false; } +bool MIParser::parseDIExpression(MDNode *&Expr) { + assert(Token.is(MIToken::md_diexpr)); + lex(); + + // FIXME: Share this parsing with the IL parser. + SmallVector Elements; + + if (expectAndConsume(MIToken::lparen)) + return true; + + if (Token.isNot(MIToken::rparen)) { + do { + if (Token.is(MIToken::Identifier)) { + if (unsigned Op = dwarf::getOperationEncoding(Token.stringValue())) { + lex(); + Elements.push_back(Op); + continue; + } + return error(Twine("invalid DWARF op '") + Token.stringValue() + "'"); + } + + if (Token.isNot(MIToken::IntegerLiteral) || + Token.integerValue().isSigned()) + return error("expected unsigned integer"); + + auto &U = Token.integerValue(); + if (U.ugt(UINT64_MAX)) + return error("element too large, limit is " + Twine(UINT64_MAX)); + Elements.push_back(U.getZExtValue()); + lex(); + + } while (consumeIfPresent(MIToken::comma)); + } + + if (expectAndConsume(MIToken::rparen)) + return true; + + Expr = DIExpression::get(MF.getFunction()->getContext(), Elements); + return false; +} + bool MIParser::parseMetadataOperand(MachineOperand &Dest) { MDNode *Node = nullptr; - if (parseMDNode(Node)) - return true; + if (Token.is(MIToken::exclaim)) { + if (parseMDNode(Node)) + return true; + } else if (Token.is(MIToken::md_diexpr)) { + if (parseDIExpression(Node)) + return true; + } Dest = MachineOperand::CreateMetadata(Node); return false; } @@ -1851,6 +1904,7 @@ bool MIParser::parseMachineOperand(MachineOperand &Dest, return parseExternalSymbolOperand(Dest); case MIToken::SubRegisterIndex: return parseSubRegisterIndexOperand(Dest); + case MIToken::md_diexpr: case MIToken::exclaim: return parseMetadataOperand(Dest); case MIToken::kw_cfi_same_value: diff --git a/lib/IR/AsmWriter.cpp b/lib/IR/AsmWriter.cpp index 170bc544d53..1cd6dd0ddff 100644 --- a/lib/IR/AsmWriter.cpp +++ b/lib/IR/AsmWriter.cpp @@ -1046,6 +1046,10 @@ void SlotTracker::CreateFunctionSlot(const Value *V) { void SlotTracker::CreateMetadataSlot(const MDNode *N) { assert(N && "Can't insert a null Value into SlotTracker!"); + // Don't make slots for DIExpressions. We just print them inline everywhere. + if (isa(N)) + return; + unsigned DestSlot = mdnNext; if (!mdnMap.insert(std::make_pair(N, DestSlot)).second) return; @@ -2073,6 +2077,13 @@ static void WriteAsOperandInternal(raw_ostream &Out, const Metadata *MD, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context, bool FromValue) { + // Write DIExpressions inline when used as a value. Improves readability of + // debug info intrinsics. + if (const DIExpression *Expr = dyn_cast(MD)) { + writeDIExpression(Out, Expr, TypePrinter, Machine, Context); + return; + } + if (const MDNode *N = dyn_cast(MD)) { std::unique_ptr MachineStorage; if (!Machine) { @@ -2424,7 +2435,16 @@ void AssemblyWriter::printNamedMDNode(const NamedMDNode *NMD) { for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) { if (i) Out << ", "; - int Slot = Machine.getMetadataSlot(NMD->getOperand(i)); + + // Write DIExpressions inline. + // FIXME: Ban DIExpressions in NamedMDNodes, they will serve no purpose. + MDNode *Op = NMD->getOperand(i); + if (auto *Expr = dyn_cast(Op)) { + writeDIExpression(Out, Expr, nullptr, nullptr, nullptr); + continue; + } + + int Slot = Machine.getMetadataSlot(Op); if (Slot == -1) Out << ""; else diff --git a/test/Assembler/DIGlobalVariableExpression.ll b/test/Assembler/DIGlobalVariableExpression.ll index 19f3d1443bf..148b7eb6633 100644 --- a/test/Assembler/DIGlobalVariableExpression.ll +++ b/test/Assembler/DIGlobalVariableExpression.ll @@ -3,7 +3,7 @@ @foo = global i32 0 -; CHECK: !named = !{!0, !1, !2, !3, !4, !5, !6, !7} +; CHECK: !named = !{!0, !1, !2, !3, !4, !5, !6, !DIExpression(DW_OP_constu, 42, DW_OP_stack_value)} !named = !{!0, !1, !2, !3, !4, !5, !6, !7} !0 = !DIFile(filename: "scope.h", directory: "/path/to/dir") @@ -17,7 +17,6 @@ file: !2, line: 7, type: !3, isLocal: true, isDefinition: false, align: 32) -; CHECK: !6 = !DIGlobalVariableExpression(var: !5, expr: !7) +; CHECK: !6 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression(DW_OP_constu, 42, DW_OP_stack_value)) !6 = !DIGlobalVariableExpression(var: !5, expr: !7) -; CHECK: !7 = !DIExpression(DW_OP_constu, 42, DW_OP_stack_value) !7 = !DIExpression(DW_OP_constu, 42, DW_OP_stack_value) diff --git a/test/Assembler/diexpression.ll b/test/Assembler/diexpression.ll index 39f4be70145..b6d2cc2dc57 100644 --- a/test/Assembler/diexpression.ll +++ b/test/Assembler/diexpression.ll @@ -1,16 +1,17 @@ ; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s ; RUN: verify-uselistorder %s -; CHECK: !named = !{!0, !1, !2, !3, !4, !5, !6} +; CHECK: !named = !{ +; CHECK-SAME: !DIExpression(), +; CHECK-SAME: !DIExpression(DW_OP_deref), +; CHECK-SAME: !DIExpression(DW_OP_constu, 3, DW_OP_plus), +; CHECK-SAME: !DIExpression(DW_OP_LLVM_fragment, 3, 7), +; CHECK-SAME: !DIExpression(DW_OP_deref, DW_OP_plus_uconst, 3, DW_OP_LLVM_fragment, 3, 7), +; CHECK-SAME: !DIExpression(DW_OP_constu, 2, DW_OP_swap, DW_OP_xderef), +; CHECK-SAME: !DIExpression(DW_OP_plus_uconst, 3)} + !named = !{!0, !1, !2, !3, !4, !5, !6} -; CHECK: !0 = !DIExpression() -; CHECK-NEXT: !1 = !DIExpression(DW_OP_deref) -; CHECK-NEXT: !2 = !DIExpression(DW_OP_constu, 3, DW_OP_plus) -; CHECK-NEXT: !3 = !DIExpression(DW_OP_LLVM_fragment, 3, 7) -; CHECK-NEXT: !4 = !DIExpression(DW_OP_deref, DW_OP_plus_uconst, 3, DW_OP_LLVM_fragment, 3, 7) -; CHECK-NEXT: !5 = !DIExpression(DW_OP_constu, 2, DW_OP_swap, DW_OP_xderef) -; CHECK-NEXT: !6 = !DIExpression(DW_OP_plus_uconst, 3) !0 = !DIExpression() !1 = !DIExpression(DW_OP_deref) !2 = !DIExpression(DW_OP_constu, 3, DW_OP_plus) diff --git a/test/Assembler/invalid-diexpression-verify.ll b/test/Assembler/invalid-diexpression-verify.ll index 50d6943dead..92c39ac7a6c 100644 --- a/test/Assembler/invalid-diexpression-verify.ll +++ b/test/Assembler/invalid-diexpression-verify.ll @@ -1,9 +1,8 @@ ; RUN: not llvm-as -disable-output < %s 2>&1 | FileCheck -check-prefix VERIFY %s ; RUN: llvm-as -disable-verify < %s | llvm-dis | FileCheck -check-prefix NOVERIFY %s -; NOVERIFY: !named = !{!0} +; NOVERIFY: !named = !{!DIExpression(0, 1, 9, 7, 2)} !named = !{!0} -; NOVERIFY: !0 = !DIExpression(0, 1, 9, 7, 2) ; VERIFY: assembly parsed, but does not verify !0 = !DIExpression(0, 1, 9, 7, 2) diff --git a/test/Bitcode/DIExpression-aggresult.ll b/test/Bitcode/DIExpression-aggresult.ll index 5ce936d7074..27298710adb 100644 --- a/test/Bitcode/DIExpression-aggresult.ll +++ b/test/Bitcode/DIExpression-aggresult.ll @@ -2,8 +2,7 @@ %class.A = type { i32, i32, i32, i32 } define void @_Z3fooi(%class.A* sret %agg.result) #0 !dbg !3 { - ; CHECK: call void @llvm.dbg.declare({{.*}}, metadata ![[EXPR:[0-9]+]]), !dbg - ; CHECK: ![[EXPR]] = !DIExpression() + ; CHECK: call void @llvm.dbg.declare({{.*}}, metadata !DIExpression()), !dbg call void @llvm.dbg.declare(metadata %class.A* %agg.result, metadata !13, metadata !16), !dbg !17 ret void, !dbg !17 } diff --git a/test/Bitcode/DIGlobalVariableExpression.ll b/test/Bitcode/DIGlobalVariableExpression.ll index 3cf08247282..d6ff1390717 100644 --- a/test/Bitcode/DIGlobalVariableExpression.ll +++ b/test/Bitcode/DIGlobalVariableExpression.ll @@ -5,16 +5,14 @@ ; BC: GLOBAL_DECL_ATTACHMENT ; CHECK: @g = common global i32 0, align 4, !dbg ![[G:[0-9]+]] ; CHECK: @h = common global i32 0, align 4, !dbg ![[H:[0-9]+]] -; CHECK: ![[G]] = {{.*}}!DIGlobalVariableExpression(var: ![[GVAR:[0-9]+]], expr: ![[GEXPR:[0-9]+]]) +; CHECK: ![[G]] = {{.*}}!DIGlobalVariableExpression(var: ![[GVAR:[0-9]+]], expr: !DIExpression(DW_OP_plus_uconst, 1)) ; CHECK: ![[GVAR]] = distinct !DIGlobalVariable(name: "g", ; CHECK: DICompileUnit({{.*}}, imports: ![[IMPORTS:[0-9]+]] -; CHECK: !DIGlobalVariableExpression(var: ![[CVAR:[0-9]+]], expr: ![[CEXPR:[0-9]+]]) +; CHECK: !DIGlobalVariableExpression(var: ![[CVAR:[0-9]+]], expr: !DIExpression(DW_OP_constu, 23, DW_OP_stack_value)) ; CHECK: ![[CVAR]] = distinct !DIGlobalVariable(name: "c", -; CHECK: ![[CEXPR]] = !DIExpression(DW_OP_constu, 23, DW_OP_stack_value) ; CHECK: ![[HVAR:[0-9]+]] = distinct !DIGlobalVariable(name: "h", ; CHECK: ![[IMPORTS]] = !{![[CIMPORT:[0-9]+]]} ; CHECK: ![[CIMPORT]] = !DIImportedEntity({{.*}}entity: ![[HVAR]] -; CHECK: ![[GEXPR]] = !DIExpression(DW_OP_plus_uconst, 1) ; CHECK: ![[H]] = {{.*}}!DIGlobalVariableExpression(var: ![[HVAR]]) @g = common global i32 0, align 4, !dbg !0 diff --git a/test/Bitcode/diglobalvariable-3.8.ll b/test/Bitcode/diglobalvariable-3.8.ll index f00a2dd86f7..9a904c7aff7 100644 --- a/test/Bitcode/diglobalvariable-3.8.ll +++ b/test/Bitcode/diglobalvariable-3.8.ll @@ -9,9 +9,8 @@ !2 = !{} ; CHECK: !3 = !{!4} !3 = !{!4} -; CHECK: !4 = {{.*}}!DIGlobalVariableExpression(var: !5, expr: !8) +; CHECK: !4 = {{.*}}!DIGlobalVariableExpression(var: !5, expr: !DIExpression(DW_OP_constu, 42, DW_OP_stack_value)) ; CHECK: !5 = !DIGlobalVariable(name: "c", scope: !0, file: !1, line: 1, type: !6, isLocal: false, isDefinition: true) -; CHECK: !8 = !DIExpression(DW_OP_constu, 42, DW_OP_stack_value) !4 = !DIGlobalVariable(name: "c", scope: !0, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, variable: i32 42) !5 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !6) !6 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) diff --git a/test/Bitcode/upgrade-dbg-value.ll b/test/Bitcode/upgrade-dbg-value.ll index 5b6ffb6d3e8..2a3a6369ae8 100644 --- a/test/Bitcode/upgrade-dbg-value.ll +++ b/test/Bitcode/upgrade-dbg-value.ll @@ -6,7 +6,7 @@ define void @f() !dbg !3 { entry: ; CHECK-NOT: call void @llvm.dbg.value - ; CHECK: call void @llvm.dbg.value(metadata i32 42, metadata !8, metadata !9), !dbg !10 + ; CHECK: call void @llvm.dbg.value(metadata i32 42, metadata !8, metadata !DIExpression()) call void @llvm.dbg.value(metadata i32 42, i64 0, metadata !8, metadata !9), !dbg !10 ; CHECK-NOT: call void @llvm.dbg.value call void @llvm.dbg.value(metadata i32 0, i64 1, metadata !8, metadata !9), !dbg !10 diff --git a/test/CodeGen/AArch64/GlobalISel/debug-insts.ll b/test/CodeGen/AArch64/GlobalISel/debug-insts.ll index e832ba95324..cd32cb41c7c 100644 --- a/test/CodeGen/AArch64/GlobalISel/debug-insts.ll +++ b/test/CodeGen/AArch64/GlobalISel/debug-insts.ll @@ -4,41 +4,41 @@ ; CHECK-LABEL: name: debug_declare ; CHECK: stack: ; CHECK: - { id: {{.*}}, name: in.addr, type: default, offset: 0, size: {{.*}}, alignment: {{.*}}, -; CHECK-NEXT: callee-saved-register: '', di-variable: '!11', di-expression: '!12', -; CHECK: DBG_VALUE debug-use %0(s32), debug-use _, !11, !12, debug-location !13 +; CHECK-NEXT: callee-saved-register: '', di-variable: '!11', di-expression: '!DIExpression()', +; CHECK: DBG_VALUE debug-use %0(s32), debug-use _, !11, !DIExpression(), debug-location !12 define void @debug_declare(i32 %in) #0 !dbg !7 { entry: %in.addr = alloca i32, align 4 store i32 %in, i32* %in.addr, align 4 - call void @llvm.dbg.declare(metadata i32* %in.addr, metadata !11, metadata !12), !dbg !13 - call void @llvm.dbg.declare(metadata i32 %in, metadata !11, metadata !12), !dbg !13 - ret void, !dbg !13 + call void @llvm.dbg.declare(metadata i32* %in.addr, metadata !11, metadata !DIExpression()), !dbg !12 + call void @llvm.dbg.declare(metadata i32 %in, metadata !11, metadata !DIExpression()), !dbg !12 + ret void, !dbg !12 } ; CHECK-LABEL: name: debug_declare_vla -; CHECK: DBG_VALUE debug-use %{{[0-9]+}}(p0), debug-use _, !15, !12, debug-location !16 -define void @debug_declare_vla(i32 %in) #0 !dbg !14 { +; CHECK: DBG_VALUE debug-use %{{[0-9]+}}(p0), debug-use _, !14, !DIExpression(), debug-location !15 +define void @debug_declare_vla(i32 %in) #0 !dbg !13 { entry: %vla.addr = alloca i32, i32 %in - call void @llvm.dbg.declare(metadata i32* %vla.addr, metadata !15, metadata !12), !dbg !16 - ret void, !dbg !16 + call void @llvm.dbg.declare(metadata i32* %vla.addr, metadata !14, metadata !DIExpression()), !dbg !15 + ret void, !dbg !15 } ; CHECK-LABEL: name: debug_value ; CHECK: [[IN:%[0-9]+]](s32) = COPY %w0 -define void @debug_value(i32 %in) #0 !dbg !17 { +define void @debug_value(i32 %in) #0 !dbg !16 { %addr = alloca i32 -; CHECK: DBG_VALUE debug-use [[IN]](s32), debug-use _, !18, !12, debug-location !19 - call void @llvm.dbg.value(metadata i32 %in, i64 0, metadata !18, metadata !12), !dbg !19 +; CHECK: DBG_VALUE debug-use [[IN]](s32), debug-use _, !17, !DIExpression(), debug-location !18 + call void @llvm.dbg.value(metadata i32 %in, i64 0, metadata !17, metadata !DIExpression()), !dbg !18 store i32 %in, i32* %addr -; CHECK: DBG_VALUE debug-use %1(p0), debug-use _, !18, !20, debug-location !19 - call void @llvm.dbg.value(metadata i32* %addr, i64 0, metadata !18, metadata !20), !dbg !19 -; CHECK: DBG_VALUE 123, 0, !18, !12, debug-location !19 - call void @llvm.dbg.value(metadata i32 123, i64 0, metadata !18, metadata !12), !dbg !19 -; CHECK: DBG_VALUE float 1.000000e+00, 0, !18, !12, debug-location !19 - call void @llvm.dbg.value(metadata float 1.000000e+00, i64 0, metadata !18, metadata !12), !dbg !19 -; CHECK: DBG_VALUE _, 0, !18, !12, debug-location !19 - call void @llvm.dbg.value(metadata i32* null, i64 0, metadata !18, metadata !12), !dbg !19 +; CHECK: DBG_VALUE debug-use %1(p0), debug-use _, !17, !DIExpression(DW_OP_deref), debug-location !18 + call void @llvm.dbg.value(metadata i32* %addr, i64 0, metadata !17, metadata !DIExpression(DW_OP_deref)), !dbg !18 +; CHECK: DBG_VALUE 123, 0, !17, !DIExpression(), debug-location !18 + call void @llvm.dbg.value(metadata i32 123, i64 0, metadata !17, metadata !DIExpression()), !dbg !18 +; CHECK: DBG_VALUE float 1.000000e+00, 0, !17, !DIExpression(), debug-location !18 + call void @llvm.dbg.value(metadata float 1.000000e+00, i64 0, metadata !17, metadata !DIExpression()), !dbg !18 +; CHECK: DBG_VALUE _, 0, !17, !DIExpression(), debug-location !18 + call void @llvm.dbg.value(metadata i32* null, i64 0, metadata !17, metadata !DIExpression()), !dbg !18 ret void } @@ -62,12 +62,10 @@ declare void @llvm.dbg.value(metadata, i64, metadata, metadata) !9 = !{null, !10} !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) !11 = !DILocalVariable(name: "in", arg: 1, scope: !7, file: !1, line: 1, type: !10) -!12 = !DIExpression() -!13 = !DILocation(line: 1, column: 14, scope: !7) -!14 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2) -!15 = !DILocalVariable(name: "in", arg: 1, scope: !14, file: !1, line: 1, type: !10) -!16 = !DILocation(line: 1, column: 14, scope: !14) -!17 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2) -!18 = !DILocalVariable(name: "in", arg: 1, scope: !17, file: !1, line: 1, type: !10) -!19 = !DILocation(line: 1, column: 14, scope: !17) -!20 = !DIExpression(DW_OP_deref) +!12 = !DILocation(line: 1, column: 14, scope: !7) +!13 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2) +!14 = !DILocalVariable(name: "in", arg: 1, scope: !13, file: !1, line: 1, type: !10) +!15 = !DILocation(line: 1, column: 14, scope: !13) +!16 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2) +!17 = !DILocalVariable(name: "in", arg: 1, scope: !16, file: !1, line: 1, type: !10) +!18 = !DILocation(line: 1, column: 14, scope: !16) diff --git a/test/CodeGen/AArch64/GlobalISel/regbankselect-dbg-value.mir b/test/CodeGen/AArch64/GlobalISel/regbankselect-dbg-value.mir index c8a8266e8b2..4282bffdab1 100644 --- a/test/CodeGen/AArch64/GlobalISel/regbankselect-dbg-value.mir +++ b/test/CodeGen/AArch64/GlobalISel/regbankselect-dbg-value.mir @@ -5,7 +5,7 @@ define void @test_dbg_value() !dbg !5 { ; Keep the dbg metadata live by referencing it in the IR. - call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !7, metadata !9), !dbg !10 + call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !7, metadata !DIExpression()), !dbg !9 ret void } @@ -23,8 +23,7 @@ !6 = !DISubroutineType(types: !2) !7 = !DILocalVariable(name: "in", arg: 1, scope: !5, file: !1, line: 1, type: !8) !8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) - !9 = !DIExpression() - !10 = !DILocation(line: 1, column: 1, scope: !5) + !9 = !DILocation(line: 1, column: 1, scope: !5) ... --- @@ -37,9 +36,9 @@ body: | bb.0: liveins: %w0 %0:_(s32) = COPY %w0 - ; CHECK: DBG_VALUE debug-use %0(s32), debug-use _, !7, !9, debug-location !10 - DBG_VALUE debug-use %0(s32), debug-use _, !7, !9, debug-location !10 + ; CHECK: DBG_VALUE debug-use %0(s32), debug-use _, !7, !DIExpression(), debug-location !9 + DBG_VALUE debug-use %0(s32), debug-use _, !7, !DIExpression(), debug-location !9 - ; CHECK: DBG_VALUE _, 0, !7, !9, debug-location !10 - DBG_VALUE _, 0, !7, !9, debug-location !10 + ; CHECK: DBG_VALUE _, 0, !7, !DIExpression(), debug-location !9 + DBG_VALUE _, 0, !7, !DIExpression(), debug-location !9 ... diff --git a/test/CodeGen/AArch64/GlobalISel/select-dbg-value.mir b/test/CodeGen/AArch64/GlobalISel/select-dbg-value.mir index 790cd6517dd..96245e3ec62 100644 --- a/test/CodeGen/AArch64/GlobalISel/select-dbg-value.mir +++ b/test/CodeGen/AArch64/GlobalISel/select-dbg-value.mir @@ -5,12 +5,12 @@ define void @test_dbg_value(i32 %a) !dbg !5 { %tmp0 = add i32 %a, %a - call void @llvm.dbg.value(metadata i32 %tmp0, i64 0, metadata !7, metadata !9), !dbg !10 + call void @llvm.dbg.value(metadata i32 %tmp0, i64 0, metadata !7, metadata !DIExpression()), !dbg !9 ret void } - define void @test_dbg_value_dead(i32 %a) !dbg !11 { - call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !12, metadata !9), !dbg !13 + define void @test_dbg_value_dead(i32 %a) !dbg !10 { + call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !11, metadata !DIExpression()), !dbg !12 ret void } @@ -28,11 +28,10 @@ !6 = !DISubroutineType(types: !2) !7 = !DILocalVariable(name: "in", arg: 1, scope: !5, file: !1, line: 1, type: !8) !8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) - !9 = !DIExpression() - !10 = !DILocation(line: 1, column: 1, scope: !5) - !11 = distinct !DISubprogram(name: "test_dbg_value", scope: !1, file: !1, line: 1, type: !6, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2) - !12 = !DILocalVariable(name: "in", arg: 1, scope: !11, file: !1, line: 1, type: !8) - !13 = !DILocation(line: 1, column: 1, scope: !11) + !9 = !DILocation(line: 1, column: 1, scope: !5) + !10 = distinct !DISubprogram(name: "test_dbg_value", scope: !1, file: !1, line: 1, type: !6, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2) + !11 = !DILocalVariable(name: "in", arg: 1, scope: !10, file: !1, line: 1, type: !8) + !12 = !DILocation(line: 1, column: 1, scope: !10) ... --- @@ -50,9 +49,9 @@ body: | ; CHECK: %0 = COPY %w0 ; CHECK-NEXT: %1 = ADDWrr %0, %0 ; CHECK-NEXT: %w0 = COPY %1 - ; CHECK-NEXT: DBG_VALUE debug-use %1, debug-use _, !7, !9, debug-location !10 + ; CHECK-NEXT: DBG_VALUE debug-use %1, debug-use _, !7, !DIExpression(), debug-location !9 - DBG_VALUE debug-use %1(s32), debug-use _, !7, !9, debug-location !10 + DBG_VALUE debug-use %1(s32), debug-use _, !7, !DIExpression(), debug-location !9 ... --- @@ -66,7 +65,7 @@ body: | %0:gpr(s32) = COPY %w0 ; CHECK-NOT: COPY - ; CHECK: DBG_VALUE debug-use _, debug-use _, !7, !9, debug-location !10 + ; CHECK: DBG_VALUE debug-use _, debug-use _, !7, !DIExpression(), debug-location !9 - DBG_VALUE debug-use %0(s32), debug-use _, !7, !9, debug-location !10 + DBG_VALUE debug-use %0(s32), debug-use _, !7, !DIExpression(), debug-location !9 ... diff --git a/test/CodeGen/MIR/X86/instructions-debug-location.mir b/test/CodeGen/MIR/X86/instructions-debug-location.mir index aa6cd5a0a45..28809d3ee90 100644 --- a/test/CodeGen/MIR/X86/instructions-debug-location.mir +++ b/test/CodeGen/MIR/X86/instructions-debug-location.mir @@ -8,18 +8,18 @@ entry: %x.addr = alloca i32, align 4 store i32 %x, i32* %x.addr, align 4 - call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !12, metadata !13), !dbg !14 - %0 = load i32, i32* %x.addr, align 4, !dbg !15 - ret i32 %0, !dbg !15 + call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !12, metadata !DIExpression()), !dbg !13 + %0 = load i32, i32* %x.addr, align 4, !dbg !14 + ret i32 %0, !dbg !14 } define i32 @test_typed_immediates(i32 %x) #0 { entry: %x.addr = alloca i32, align 4 store i32 %x, i32* %x.addr, align 4 - call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !12, metadata !13), !dbg !14 - %0 = load i32, i32* %x.addr, align 4, !dbg !15 - ret i32 %0, !dbg !15 + call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !12, metadata !DIExpression()), !dbg !13 + %0 = load i32, i32* %x.addr, align 4, !dbg !14 + ret i32 %0, !dbg !14 } declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 @@ -43,9 +43,8 @@ !10 = !{i32 2, !"Debug Info Version", i32 3} !11 = !{!"clang version 3.7.0"} !12 = !DILocalVariable(name: "x", arg: 1, scope: !4, file: !5, line: 4, type: !8) - !13 = !DIExpression() - !14 = !DILocation(line: 4, scope: !4) - !15 = !DILocation(line: 8, scope: !4) + !13 = !DILocation(line: 4, scope: !4) + !14 = !DILocation(line: 8, scope: !4) ... --- @@ -60,14 +59,14 @@ stack: body: | bb.0.entry: liveins: %edi - ; CHECK: DBG_VALUE debug-use _, 0, !11, !12, debug-location !13 - ; CHECK: %eax = COPY %0, debug-location !14 - ; CHECK: RETQ %eax, debug-location !14 + ; CHECK: DBG_VALUE debug-use _, 0, !11, !DIExpression(), debug-location !12 + ; CHECK: %eax = COPY %0, debug-location !13 + ; CHECK: RETQ %eax, debug-location !13 %0 = COPY %edi - DBG_VALUE debug-use _, 0, !12, !13, debug-location !14 + DBG_VALUE debug-use _, 0, !12, !DIExpression(), debug-location !13 MOV32mr %stack.0.x.addr, 1, _, 0, _, %0 - %eax = COPY %0, debug-location !15 - RETQ %eax, debug-location !15 + %eax = COPY %0, debug-location !14 + RETQ %eax, debug-location !14 ... --- name: test_typed_immediates @@ -83,12 +82,12 @@ body: | liveins: %edi %0 = COPY %edi - ; CHECK: DBG_VALUE _, i32 0, !11, !12 - ; CHECK-NEXT: DBG_VALUE _, i64 -22, !11, !12 - ; CHECK-NEXT: DBG_VALUE _, i128 123492148938512984928424384934328985928, !11, !12 - DBG_VALUE _, i32 0, !12, !13 - DBG_VALUE _, i64 -22, !12, !13 - DBG_VALUE _, i128 123492148938512984928424384934328985928, !12, !13 + ; CHECK: DBG_VALUE _, i32 0, !DIExpression(), !12 + ; CHECK-NEXT: DBG_VALUE _, i64 -22, !DIExpression(), !12 + ; CHECK-NEXT: DBG_VALUE _, i128 123492148938512984928424384934328985928, !DIExpression(), !12 + DBG_VALUE _, i32 0, !DIExpression(), !13 + DBG_VALUE _, i64 -22, !DIExpression(), !13 + DBG_VALUE _, i128 123492148938512984928424384934328985928, !DIExpression(), !13 MOV32mr %stack.0.x.addr, 1, _, 0, _, %0 %eax = COPY %0 RETQ %eax diff --git a/test/CodeGen/MIR/X86/metadata-operands.mir b/test/CodeGen/MIR/X86/metadata-operands.mir index 9d92fe5c2c6..758f3031465 100644 --- a/test/CodeGen/MIR/X86/metadata-operands.mir +++ b/test/CodeGen/MIR/X86/metadata-operands.mir @@ -8,9 +8,9 @@ entry: %x.addr = alloca i32, align 4 store i32 %x, i32* %x.addr, align 4 - call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !12, metadata !13), !dbg !14 - %0 = load i32, i32* %x.addr, align 4, !dbg !15 - ret i32 %0, !dbg !15 + call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !12, metadata !DIExpression()), !dbg !13 + %0 = load i32, i32* %x.addr, align 4, !dbg !14 + ret i32 %0, !dbg !14 } declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 @@ -34,9 +34,8 @@ !10 = !{i32 2, !"Debug Info Version", i32 3} !11 = !{!"clang version 3.7.0"} !12 = !DILocalVariable(name: "x", arg: 1, scope: !4, file: !5, line: 4, type: !8) - !13 = !DIExpression() - !14 = !DILocation(line: 4, scope: !4) - !15 = !DILocation(line: 8, scope: !4) + !13 = !DILocation(line: 4, scope: !4) + !14 = !DILocation(line: 8, scope: !4) ... --- @@ -52,9 +51,9 @@ body: | bb.0.entry: liveins: %edi ; CHECK: %0 = COPY %edi - ; CHECK-NEXT: DBG_VALUE _, 0, !11, !12 + ; CHECK-NEXT: DBG_VALUE _, 0, !11, !DIExpression() %0 = COPY %edi - DBG_VALUE _, 0, !12, ! 13 + DBG_VALUE _, 0, !12, !DIExpression() MOV32mr %stack.0.x.addr, 1, _, 0, _, %0 %eax = COPY %0 RETQ %eax diff --git a/test/CodeGen/MIR/X86/stack-object-debug-info.mir b/test/CodeGen/MIR/X86/stack-object-debug-info.mir index 445d1bd3f1f..5c70582233e 100644 --- a/test/CodeGen/MIR/X86/stack-object-debug-info.mir +++ b/test/CodeGen/MIR/X86/stack-object-debug-info.mir @@ -15,7 +15,7 @@ %1 = bitcast [256 x i8]* %y.i to i8* call void @llvm.lifetime.end(i64 -1, i8* %1) #3 call void @llvm.lifetime.start(i64 -1, i8* %0) #3 - call void @llvm.dbg.declare(metadata i8* %0, metadata !4, metadata !7) #3, !dbg !8 + call void @llvm.dbg.declare(metadata i8* %0, metadata !4, metadata !DIExpression()) #3, !dbg !7 br label %for.body } @@ -35,14 +35,13 @@ !1 = !DIFile(filename: "t.c", directory: "") !2 = !{} !3 = !{i32 1, !"Debug Info Version", i32 3} - !4 = !DILocalVariable(name: "x", scope: !5, file: !1, line: 16, type: !9) + !4 = !DILocalVariable(name: "x", scope: !5, file: !1, line: 16, type: !8) !5 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0) !6 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char) - !7 = !DIExpression() - !8 = !DILocation(line: 0, scope: !5) - !9 = !DICompositeType(tag: DW_TAG_array_type, baseType: !6, size: 2048, align: 8, elements: !10) - !10 = !{!11} - !11 = !DISubrange(count: 256) + !7 = !DILocation(line: 0, scope: !5) + !8 = !DICompositeType(tag: DW_TAG_array_type, baseType: !6, size: 2048, align: 8, elements: !9) + !9 = !{!10} + !10 = !DISubrange(count: 256) ... --- name: foo @@ -52,17 +51,17 @@ frameInfo: # CHECK-LABEL: foo # CHECK: stack: # CHECK: - { id: 0, name: y.i, type: default, offset: 0, size: 256, alignment: 16, -# CHECK-NEXT: callee-saved-register: '', di-variable: '!4', di-expression: '!10', -# CHECK-NEXT: di-location: '!11' } +# CHECK-NEXT: callee-saved-register: '', di-variable: '!4', di-expression: '!DIExpression()', +# CHECK-NEXT: di-location: '!10' } stack: - { id: 0, name: y.i, offset: 0, size: 256, alignment: 16, di-variable: '!4', - di-expression: '!7', di-location: '!8' } + di-expression: '!DIExpression()', di-location: '!7' } body: | bb.0.entry: successors: %bb.1.for.body bb.1.for.body: successors: %bb.1.for.body - DBG_VALUE %stack.0.y.i, 0, !4, !7, debug-location !8 + DBG_VALUE %stack.0.y.i, 0, !4, !DIExpression(), debug-location !7 JMP_1 %bb.1.for.body ... diff --git a/test/CodeGen/X86/lea-opt-with-debug.mir b/test/CodeGen/X86/lea-opt-with-debug.mir index 03a745888b5..5a32d7e0815 100644 --- a/test/CodeGen/X86/lea-opt-with-debug.mir +++ b/test/CodeGen/X86/lea-opt-with-debug.mir @@ -14,22 +14,22 @@ @d = common local_unnamed_addr global i32 0, align 4 @b = common local_unnamed_addr global i32 0, align 4 - define i32 @fn1() local_unnamed_addr !dbg !9 { - %1 = load %struct.A*, %struct.A** @c, align 8, !dbg !14 - %2 = load i32, i32* @a, align 4, !dbg !14 - %3 = sext i32 %2 to i64, !dbg !14 - %4 = getelementptr inbounds %struct.A, %struct.A* %1, i64 %3, !dbg !14 - %5 = ptrtoint %struct.A* %4 to i64, !dbg !14 - %6 = trunc i64 %5 to i32, !dbg !14 - store i32 %6, i32* @d, align 4, !dbg !14 - %7 = getelementptr inbounds %struct.A, %struct.A* %1, i64 %3, i32 2, !dbg !15 - tail call void @llvm.dbg.value(metadata i32* %7, i64 0, metadata !12, metadata !16), !dbg !17 - br label %8, !dbg !18 + define i32 @fn1() local_unnamed_addr !dbg !8 { + %1 = load %struct.A*, %struct.A** @c, align 8, !dbg !13 + %2 = load i32, i32* @a, align 4, !dbg !13 + %3 = sext i32 %2 to i64, !dbg !13 + %4 = getelementptr inbounds %struct.A, %struct.A* %1, i64 %3, !dbg !13 + %5 = ptrtoint %struct.A* %4 to i64, !dbg !13 + %6 = trunc i64 %5 to i32, !dbg !13 + store i32 %6, i32* @d, align 4, !dbg !13 + %7 = getelementptr inbounds %struct.A, %struct.A* %1, i64 %3, i32 2, !dbg !14 + tail call void @llvm.dbg.value(metadata i32* %7, i64 0, metadata !11, metadata !DIExpression()), !dbg !15 + br label %8, !dbg !16 ;