llvm.org GIT mirror llvm / a5b2af0
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 Reid Kleckner 2 years ago
48 changed file(s) with 336 addition(s) and 288 deletion(s). Raw diff Collapse all Expand all
642642 NamedMDNode *NMD = M->getOrInsertNamedMetadata(Name);
643643 if (Lex.getKind() != lltok::rbrace)
644644 do {
645 if (ParseToken(lltok::exclaim, "Expected '!' here"))
645 MDNode *N = nullptr;
646 // Parse DIExpressions inline as a special case. They are still MDNodes,
647 // so they can still appear in named metadata. Remove this logic if they
648 // become plain Metadata.
649 if (Lex.getKind() == lltok::MetadataVar &&
650 Lex.getStrVal() == "DIExpression") {
651 if (ParseDIExpression(N, /*IsDistinct=*/false))
652 return true;
653 } else if (ParseToken(lltok::exclaim, "Expected '!' here") ||
654 ParseMDNodeID(N)) {
646655 return true;
647
648 MDNode *N = nullptr;
649 if (ParseMDNodeID(N)) return true;
656 }
650657 NMD->addOperand(N);
651658 } while (EatIfPresent(lltok::comma));
652659
489489 .Case("!alias.scope", MIToken::md_alias_scope)
490490 .Case("!noalias", MIToken::md_noalias)
491491 .Case("!range", MIToken::md_range)
492 .Case("!DIExpression", MIToken::md_diexpr)
492493 .Default(MIToken::Error);
493494 }
494495
9999 md_alias_scope,
100100 md_noalias,
101101 md_range,
102 md_diexpr,
102103
103104 // Identifier tokens
104105 Identifier,
3838 #include "llvm/IR/BasicBlock.h"
3939 #include "llvm/IR/Constants.h"
4040 #include "llvm/IR/DataLayout.h"
41 #include "llvm/IR/DebugInfoMetadata.h"
4142 #include "llvm/IR/DebugLoc.h"
4243 #include "llvm/IR/Function.h"
4344 #include "llvm/IR/InstrTypes.h"
208209 bool parseJumpTableIndexOperand(MachineOperand &Dest);
209210 bool parseExternalSymbolOperand(MachineOperand &Dest);
210211 bool parseMDNode(MDNode *&Node);
212 bool parseDIExpression(MDNode *&Node);
211213 bool parseMetadataOperand(MachineOperand &Dest);
212214 bool parseCFIOffset(int &Offset);
213215 bool parseCFIRegister(unsigned &Reg);
853855
854856 bool MIParser::parseStandaloneMDNode(MDNode *&Node) {
855857 lex();
856 if (Token.isNot(MIToken::exclaim))
858 if (Token.is(MIToken::exclaim)) {
859 if (parseMDNode(Node))
860 return true;
861 } else if (Token.is(MIToken::md_diexpr)) {
862 if (parseDIExpression(Node))
863 return true;
864 } else
857865 return error("expected a metadata node");
858 if (parseMDNode(Node))
859 return true;
860866 if (Token.isNot(MIToken::Eof))
861867 return error("expected end of string after the metadata node");
862868 return false;
14911497
14921498 bool MIParser::parseMDNode(MDNode *&Node) {
14931499 assert(Token.is(MIToken::exclaim));
1500
14941501 auto Loc = Token.location();
14951502 lex();
14961503 if (Token.isNot(MIToken::IntegerLiteral) || Token.integerValue().isSigned())
15061513 return false;
15071514 }
15081515
1516 bool MIParser::parseDIExpression(MDNode *&Expr) {
1517 assert(Token.is(MIToken::md_diexpr));
1518 lex();
1519
1520 // FIXME: Share this parsing with the IL parser.
1521 SmallVector Elements;
1522
1523 if (expectAndConsume(MIToken::lparen))
1524 return true;
1525
1526 if (Token.isNot(MIToken::rparen)) {
1527 do {
1528 if (Token.is(MIToken::Identifier)) {
1529 if (unsigned Op = dwarf::getOperationEncoding(Token.stringValue())) {
1530 lex();
1531 Elements.push_back(Op);
1532 continue;
1533 }
1534 return error(Twine("invalid DWARF op '") + Token.stringValue() + "'");
1535 }
1536
1537 if (Token.isNot(MIToken::IntegerLiteral) ||
1538 Token.integerValue().isSigned())
1539 return error("expected unsigned integer");
1540
1541 auto &U = Token.integerValue();
1542 if (U.ugt(UINT64_MAX))
1543 return error("element too large, limit is " + Twine(UINT64_MAX));
1544 Elements.push_back(U.getZExtValue());
1545 lex();
1546
1547 } while (consumeIfPresent(MIToken::comma));
1548 }
1549
1550 if (expectAndConsume(MIToken::rparen))
1551 return true;
1552
1553 Expr = DIExpression::get(MF.getFunction()->getContext(), Elements);
1554 return false;
1555 }
1556
15091557 bool MIParser::parseMetadataOperand(MachineOperand &Dest) {
15101558 MDNode *Node = nullptr;
1511 if (parseMDNode(Node))
1512 return true;
1559 if (Token.is(MIToken::exclaim)) {
1560 if (parseMDNode(Node))
1561 return true;
1562 } else if (Token.is(MIToken::md_diexpr)) {
1563 if (parseDIExpression(Node))
1564 return true;
1565 }
15131566 Dest = MachineOperand::CreateMetadata(Node);
15141567 return false;
15151568 }
18501903 return parseExternalSymbolOperand(Dest);
18511904 case MIToken::SubRegisterIndex:
18521905 return parseSubRegisterIndexOperand(Dest);
1906 case MIToken::md_diexpr:
18531907 case MIToken::exclaim:
18541908 return parseMetadataOperand(Dest);
18551909 case MIToken::kw_cfi_same_value:
10451045 void SlotTracker::CreateMetadataSlot(const MDNode *N) {
10461046 assert(N && "Can't insert a null Value into SlotTracker!");
10471047
1048 // Don't make slots for DIExpressions. We just print them inline everywhere.
1049 if (isa(N))
1050 return;
1051
10481052 unsigned DestSlot = mdnNext;
10491053 if (!mdnMap.insert(std::make_pair(N, DestSlot)).second)
10501054 return;
20722076 TypePrinting *TypePrinter,
20732077 SlotTracker *Machine, const Module *Context,
20742078 bool FromValue) {
2079 // Write DIExpressions inline when used as a value. Improves readability of
2080 // debug info intrinsics.
2081 if (const DIExpression *Expr = dyn_cast(MD)) {
2082 writeDIExpression(Out, Expr, TypePrinter, Machine, Context);
2083 return;
2084 }
2085
20752086 if (const MDNode *N = dyn_cast(MD)) {
20762087 std::unique_ptr MachineStorage;
20772088 if (!Machine) {
24232434 for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
24242435 if (i)
24252436 Out << ", ";
2426 int Slot = Machine.getMetadataSlot(NMD->getOperand(i));
2437
2438 // Write DIExpressions inline.
2439 // FIXME: Ban DIExpressions in NamedMDNodes, they will serve no purpose.
2440 MDNode *Op = NMD->getOperand(i);
2441 if (auto *Expr = dyn_cast(Op)) {
2442 writeDIExpression(Out, Expr, nullptr, nullptr, nullptr);
2443 continue;
2444 }
2445
2446 int Slot = Machine.getMetadataSlot(Op);
24272447 if (Slot == -1)
24282448 Out << "";
24292449 else
22
33 @foo = global i32 0
44
5 ; CHECK: !named = !{!0, !1, !2, !3, !4, !5, !6, !7}
5 ; CHECK: !named = !{!0, !1, !2, !3, !4, !5, !6, !DIExpression(DW_OP_constu, 42, DW_OP_stack_value)}
66 !named = !{!0, !1, !2, !3, !4, !5, !6, !7}
77
88 !0 = !DIFile(filename: "scope.h", directory: "/path/to/dir")
1616 file: !2, line: 7, type: !3, isLocal: true,
1717 isDefinition: false, align: 32)
1818
19 ; CHECK: !6 = !DIGlobalVariableExpression(var: !5, expr: !7)
19 ; CHECK: !6 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression(DW_OP_constu, 42, DW_OP_stack_value))
2020 !6 = !DIGlobalVariableExpression(var: !5, expr: !7)
21 ; CHECK: !7 = !DIExpression(DW_OP_constu, 42, DW_OP_stack_value)
2221 !7 = !DIExpression(DW_OP_constu, 42, DW_OP_stack_value)
0 ; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s
11 ; RUN: verify-uselistorder %s
22
3 ; CHECK: !named = !{!0, !1, !2, !3, !4, !5, !6}
3 ; CHECK: !named = !{
4 ; CHECK-SAME: !DIExpression(),
5 ; CHECK-SAME: !DIExpression(DW_OP_deref),
6 ; CHECK-SAME: !DIExpression(DW_OP_constu, 3, DW_OP_plus),
7 ; CHECK-SAME: !DIExpression(DW_OP_LLVM_fragment, 3, 7),
8 ; CHECK-SAME: !DIExpression(DW_OP_deref, DW_OP_plus_uconst, 3, DW_OP_LLVM_fragment, 3, 7),
9 ; CHECK-SAME: !DIExpression(DW_OP_constu, 2, DW_OP_swap, DW_OP_xderef),
10 ; CHECK-SAME: !DIExpression(DW_OP_plus_uconst, 3)}
11
412 !named = !{!0, !1, !2, !3, !4, !5, !6}
513
6 ; CHECK: !0 = !DIExpression()
7 ; CHECK-NEXT: !1 = !DIExpression(DW_OP_deref)
8 ; CHECK-NEXT: !2 = !DIExpression(DW_OP_constu, 3, DW_OP_plus)
9 ; CHECK-NEXT: !3 = !DIExpression(DW_OP_LLVM_fragment, 3, 7)
10 ; CHECK-NEXT: !4 = !DIExpression(DW_OP_deref, DW_OP_plus_uconst, 3, DW_OP_LLVM_fragment, 3, 7)
11 ; CHECK-NEXT: !5 = !DIExpression(DW_OP_constu, 2, DW_OP_swap, DW_OP_xderef)
12 ; CHECK-NEXT: !6 = !DIExpression(DW_OP_plus_uconst, 3)
1314 !0 = !DIExpression()
1415 !1 = !DIExpression(DW_OP_deref)
1516 !2 = !DIExpression(DW_OP_constu, 3, DW_OP_plus)
0 ; RUN: not llvm-as -disable-output < %s 2>&1 | FileCheck -check-prefix VERIFY %s
11 ; RUN: llvm-as -disable-verify < %s | llvm-dis | FileCheck -check-prefix NOVERIFY %s
22
3 ; NOVERIFY: !named = !{!0}
3 ; NOVERIFY: !named = !{!DIExpression(0, 1, 9, 7, 2)}
44 !named = !{!0}
55
6 ; NOVERIFY: !0 = !DIExpression(0, 1, 9, 7, 2)
76 ; VERIFY: assembly parsed, but does not verify
87 !0 = !DIExpression(0, 1, 9, 7, 2)
11 %class.A = type { i32, i32, i32, i32 }
22
33 define void @_Z3fooi(%class.A* sret %agg.result) #0 !dbg !3 {
4 ; CHECK: call void @llvm.dbg.declare({{.*}}, metadata ![[EXPR:[0-9]+]]), !dbg
5 ; CHECK: ![[EXPR]] = !DIExpression()
4 ; CHECK: call void @llvm.dbg.declare({{.*}}, metadata !DIExpression()), !dbg
65 call void @llvm.dbg.declare(metadata %class.A* %agg.result, metadata !13, metadata !16), !dbg !17
76 ret void, !dbg !17
87 }
44 ; BC: GLOBAL_DECL_ATTACHMENT
55 ; CHECK: @g = common global i32 0, align 4, !dbg ![[G:[0-9]+]]
66 ; CHECK: @h = common global i32 0, align 4, !dbg ![[H:[0-9]+]]
7 ; CHECK: ![[G]] = {{.*}}!DIGlobalVariableExpression(var: ![[GVAR:[0-9]+]], expr: ![[GEXPR:[0-9]+]])
7 ; CHECK: ![[G]] = {{.*}}!DIGlobalVariableExpression(var: ![[GVAR:[0-9]+]], expr: !DIExpression(DW_OP_plus_uconst, 1))
88 ; CHECK: ![[GVAR]] = distinct !DIGlobalVariable(name: "g",
99 ; CHECK: DICompileUnit({{.*}}, imports: ![[IMPORTS:[0-9]+]]
10 ; CHECK: !DIGlobalVariableExpression(var: ![[CVAR:[0-9]+]], expr: ![[CEXPR:[0-9]+]])
10 ; CHECK: !DIGlobalVariableExpression(var: ![[CVAR:[0-9]+]], expr: !DIExpression(DW_OP_constu, 23, DW_OP_stack_value))
1111 ; CHECK: ![[CVAR]] = distinct !DIGlobalVariable(name: "c",
12 ; CHECK: ![[CEXPR]] = !DIExpression(DW_OP_constu, 23, DW_OP_stack_value)
1312 ; CHECK: ![[HVAR:[0-9]+]] = distinct !DIGlobalVariable(name: "h",
1413 ; CHECK: ![[IMPORTS]] = !{![[CIMPORT:[0-9]+]]}
1514 ; CHECK: ![[CIMPORT]] = !DIImportedEntity({{.*}}entity: ![[HVAR]]
16 ; CHECK: ![[GEXPR]] = !DIExpression(DW_OP_plus_uconst, 1)
1715 ; CHECK: ![[H]] = {{.*}}!DIGlobalVariableExpression(var: ![[HVAR]])
1816
1917 @g = common global i32 0, align 4, !dbg !0
88 !2 = !{}
99 ; CHECK: !3 = !{!4}
1010 !3 = !{!4}
11 ; CHECK: !4 = {{.*}}!DIGlobalVariableExpression(var: !5, expr: !8)
11 ; CHECK: !4 = {{.*}}!DIGlobalVariableExpression(var: !5, expr: !DIExpression(DW_OP_constu, 42, DW_OP_stack_value))
1212 ; CHECK: !5 = !DIGlobalVariable(name: "c", scope: !0, file: !1, line: 1, type: !6, isLocal: false, isDefinition: true)
13 ; CHECK: !8 = !DIExpression(DW_OP_constu, 42, DW_OP_stack_value)
1413 !4 = !DIGlobalVariable(name: "c", scope: !0, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, variable: i32 42)
1514 !5 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !6)
1615 !6 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
55 define void @f() !dbg !3 {
66 entry:
77 ; CHECK-NOT: call void @llvm.dbg.value
8 ; CHECK: call void @llvm.dbg.value(metadata i32 42, metadata !8, metadata !9), !dbg !10
8 ; CHECK: call void @llvm.dbg.value(metadata i32 42, metadata !8, metadata !DIExpression())
99 call void @llvm.dbg.value(metadata i32 42, i64 0, metadata !8, metadata !9), !dbg !10
1010 ; CHECK-NOT: call void @llvm.dbg.value
1111 call void @llvm.dbg.value(metadata i32 0, i64 1, metadata !8, metadata !9), !dbg !10
33 ; CHECK-LABEL: name: debug_declare
44 ; CHECK: stack:
55 ; CHECK: - { id: {{.*}}, name: in.addr, type: default, offset: 0, size: {{.*}}, alignment: {{.*}},
6 ; CHECK-NEXT: callee-saved-register: '', di-variable: '!11', di-expression: '!12',
7 ; CHECK: DBG_VALUE debug-use %0(s32), debug-use _, !11, !12, debug-location !13
6 ; CHECK-NEXT: callee-saved-register: '', di-variable: '!11', di-expression: '!DIExpression()',
7 ; CHECK: DBG_VALUE debug-use %0(s32), debug-use _, !11, !DIExpression(), debug-location !12
88 define void @debug_declare(i32 %in) #0 !dbg !7 {
99 entry:
1010 %in.addr = alloca i32, align 4
1111 store i32 %in, i32* %in.addr, align 4
12 call void @llvm.dbg.declare(metadata i32* %in.addr, metadata !11, metadata !12), !dbg !13
13 call void @llvm.dbg.declare(metadata i32 %in, metadata !11, metadata !12), !dbg !13
14 ret void, !dbg !13
12 call void @llvm.dbg.declare(metadata i32* %in.addr, metadata !11, metadata !DIExpression()), !dbg !12
13 call void @llvm.dbg.declare(metadata i32 %in, metadata !11, metadata !DIExpression()), !dbg !12
14 ret void, !dbg !12
1515 }
1616
1717 ; CHECK-LABEL: name: debug_declare_vla
18 ; CHECK: DBG_VALUE debug-use %{{[0-9]+}}(p0), debug-use _, !15, !12, debug-location !16
19 define void @debug_declare_vla(i32 %in) #0 !dbg !14 {
18 ; CHECK: DBG_VALUE debug-use %{{[0-9]+}}(p0), debug-use _, !14, !DIExpression(), debug-location !15
19 define void @debug_declare_vla(i32 %in) #0 !dbg !13 {
2020 entry:
2121 %vla.addr = alloca i32, i32 %in
22 call void @llvm.dbg.declare(metadata i32* %vla.addr, metadata !15, metadata !12), !dbg !16
23 ret void, !dbg !16
22 call void @llvm.dbg.declare(metadata i32* %vla.addr, metadata !14, metadata !DIExpression()), !dbg !15
23 ret void, !dbg !15
2424 }
2525
2626 ; CHECK-LABEL: name: debug_value
2727 ; CHECK: [[IN:%[0-9]+]](s32) = COPY %w0
28 define void @debug_value(i32 %in) #0 !dbg !17 {
28 define void @debug_value(i32 %in) #0 !dbg !16 {
2929 %addr = alloca i32
30 ; CHECK: DBG_VALUE debug-use [[IN]](s32), debug-use _, !18, !12, debug-location !19
31 call void @llvm.dbg.value(metadata i32 %in, i64 0, metadata !18, metadata !12), !dbg !19
30 ; CHECK: DBG_VALUE debug-use [[IN]](s32), debug-use _, !17, !DIExpression(), debug-location !18
31 call void @llvm.dbg.value(metadata i32 %in, i64 0, metadata !17, metadata !DIExpression()), !dbg !18
3232 store i32 %in, i32* %addr
33 ; CHECK: DBG_VALUE debug-use %1(p0), debug-use _, !18, !20, debug-location !19
34 call void @llvm.dbg.value(metadata i32* %addr, i64 0, metadata !18, metadata !20), !dbg !19
35 ; CHECK: DBG_VALUE 123, 0, !18, !12, debug-location !19
36 call void @llvm.dbg.value(metadata i32 123, i64 0, metadata !18, metadata !12), !dbg !19
37 ; CHECK: DBG_VALUE float 1.000000e+00, 0, !18, !12, debug-location !19
38 call void @llvm.dbg.value(metadata float 1.000000e+00, i64 0, metadata !18, metadata !12), !dbg !19
39 ; CHECK: DBG_VALUE _, 0, !18, !12, debug-location !19
40 call void @llvm.dbg.value(metadata i32* null, i64 0, metadata !18, metadata !12), !dbg !19
33 ; CHECK: DBG_VALUE debug-use %1(p0), debug-use _, !17, !DIExpression(DW_OP_deref), debug-location !18
34 call void @llvm.dbg.value(metadata i32* %addr, i64 0, metadata !17, metadata !DIExpression(DW_OP_deref)), !dbg !18
35 ; CHECK: DBG_VALUE 123, 0, !17, !DIExpression(), debug-location !18
36 call void @llvm.dbg.value(metadata i32 123, i64 0, metadata !17, metadata !DIExpression()), !dbg !18
37 ; CHECK: DBG_VALUE float 1.000000e+00, 0, !17, !DIExpression(), debug-location !18
38 call void @llvm.dbg.value(metadata float 1.000000e+00, i64 0, metadata !17, metadata !DIExpression()), !dbg !18
39 ; CHECK: DBG_VALUE _, 0, !17, !DIExpression(), debug-location !18
40 call void @llvm.dbg.value(metadata i32* null, i64 0, metadata !17, metadata !DIExpression()), !dbg !18
4141 ret void
4242 }
4343
6161 !9 = !{null, !10}
6262 !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
6363 !11 = !DILocalVariable(name: "in", arg: 1, scope: !7, file: !1, line: 1, type: !10)
64 !12 = !DIExpression()
65 !13 = !DILocation(line: 1, column: 14, scope: !7)
66 !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)
67 !15 = !DILocalVariable(name: "in", arg: 1, scope: !14, file: !1, line: 1, type: !10)
68 !16 = !DILocation(line: 1, column: 14, scope: !14)
69 !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)
70 !18 = !DILocalVariable(name: "in", arg: 1, scope: !17, file: !1, line: 1, type: !10)
71 !19 = !DILocation(line: 1, column: 14, scope: !17)
72 !20 = !DIExpression(DW_OP_deref)
64 !12 = !DILocation(line: 1, column: 14, scope: !7)
65 !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)
66 !14 = !DILocalVariable(name: "in", arg: 1, scope: !13, file: !1, line: 1, type: !10)
67 !15 = !DILocation(line: 1, column: 14, scope: !13)
68 !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)
69 !17 = !DILocalVariable(name: "in", arg: 1, scope: !16, file: !1, line: 1, type: !10)
70 !18 = !DILocation(line: 1, column: 14, scope: !16)
44
55 define void @test_dbg_value() !dbg !5 {
66 ; Keep the dbg metadata live by referencing it in the IR.
7 call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !7, metadata !9), !dbg !10
7 call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !7, metadata !DIExpression()), !dbg !9
88 ret void
99 }
1010
2222 !6 = !DISubroutineType(types: !2)
2323 !7 = !DILocalVariable(name: "in", arg: 1, scope: !5, file: !1, line: 1, type: !8)
2424 !8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
25 !9 = !DIExpression()
26 !10 = !DILocation(line: 1, column: 1, scope: !5)
25 !9 = !DILocation(line: 1, column: 1, scope: !5)
2726 ...
2827
2928 ---
3635 bb.0:
3736 liveins: %w0
3837 %0:_(s32) = COPY %w0
39 ; CHECK: DBG_VALUE debug-use %0(s32), debug-use _, !7, !9, debug-location !10
40 DBG_VALUE debug-use %0(s32), debug-use _, !7, !9, debug-location !10
38 ; CHECK: DBG_VALUE debug-use %0(s32), debug-use _, !7, !DIExpression(), debug-location !9
39 DBG_VALUE debug-use %0(s32), debug-use _, !7, !DIExpression(), debug-location !9
4140
42 ; CHECK: DBG_VALUE _, 0, !7, !9, debug-location !10
43 DBG_VALUE _, 0, !7, !9, debug-location !10
41 ; CHECK: DBG_VALUE _, 0, !7, !DIExpression(), debug-location !9
42 DBG_VALUE _, 0, !7, !DIExpression(), debug-location !9
4443 ...
44
55 define void @test_dbg_value(i32 %a) !dbg !5 {
66 %tmp0 = add i32 %a, %a
7 call void @llvm.dbg.value(metadata i32 %tmp0, i64 0, metadata !7, metadata !9), !dbg !10
7 call void @llvm.dbg.value(metadata i32 %tmp0, i64 0, metadata !7, metadata !DIExpression()), !dbg !9
88 ret void
99 }
1010
11 define void @test_dbg_value_dead(i32 %a) !dbg !11 {
12 call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !12, metadata !9), !dbg !13
11 define void @test_dbg_value_dead(i32 %a) !dbg !10 {
12 call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !11, metadata !DIExpression()), !dbg !12
1313 ret void
1414 }
1515
2727 !6 = !DISubroutineType(types: !2)
2828 !7 = !DILocalVariable(name: "in", arg: 1, scope: !5, file: !1, line: 1, type: !8)
2929 !8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
30 !9 = !DIExpression()
31 !10 = !DILocation(line: 1, column: 1, scope: !5)
32 !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)
33 !12 = !DILocalVariable(name: "in", arg: 1, scope: !11, file: !1, line: 1, type: !8)
34 !13 = !DILocation(line: 1, column: 1, scope: !11)
30 !9 = !DILocation(line: 1, column: 1, scope: !5)
31 !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)
32 !11 = !DILocalVariable(name: "in", arg: 1, scope: !10, file: !1, line: 1, type: !8)
33 !12 = !DILocation(line: 1, column: 1, scope: !10)
3534 ...
3635
3736 ---
4948 ; CHECK: %0 = COPY %w0
5049 ; CHECK-NEXT: %1 = ADDWrr %0, %0
5150 ; CHECK-NEXT: %w0 = COPY %1
52 ; CHECK-NEXT: DBG_VALUE debug-use %1, debug-use _, !7, !9, debug-location !10
51 ; CHECK-NEXT: DBG_VALUE debug-use %1, debug-use _, !7, !DIExpression(), debug-location !9
5352
54 DBG_VALUE debug-use %1(s32), debug-use _, !7, !9, debug-location !10
53 DBG_VALUE debug-use %1(s32), debug-use _, !7, !DIExpression(), debug-location !9
5554 ...
5655
5756 ---
6564 %0:gpr(s32) = COPY %w0
6665
6766 ; CHECK-NOT: COPY
68 ; CHECK: DBG_VALUE debug-use _, debug-use _, !7, !9, debug-location !10
67 ; CHECK: DBG_VALUE debug-use _, debug-use _, !7, !DIExpression(), debug-location !9
6968
70 DBG_VALUE debug-use %0(s32), debug-use _, !7, !9, debug-location !10
69 DBG_VALUE debug-use %0(s32), debug-use _, !7, !DIExpression(), debug-location !9
7170 ...
77 entry:
88 %x.addr = alloca i32, align 4
99 store i32 %x, i32* %x.addr, align 4
10 call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !12, metadata !13), !dbg !14
11 %0 = load i32, i32* %x.addr, align 4, !dbg !15
12 ret i32 %0, !dbg !15
10 call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !12, metadata !DIExpression()), !dbg !13
11 %0 = load i32, i32* %x.addr, align 4, !dbg !14
12 ret i32 %0, !dbg !14
1313 }
1414
1515 define i32 @test_typed_immediates(i32 %x) #0 {
1616 entry:
1717 %x.addr = alloca i32, align 4
1818 store i32 %x, i32* %x.addr, align 4
19 call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !12, metadata !13), !dbg !14
20 %0 = load i32, i32* %x.addr, align 4, !dbg !15
21 ret i32 %0, !dbg !15
19 call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !12, metadata !DIExpression()), !dbg !13
20 %0 = load i32, i32* %x.addr, align 4, !dbg !14
21 ret i32 %0, !dbg !14
2222 }
2323
2424 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
4242 !10 = !{i32 2, !"Debug Info Version", i32 3}
4343 !11 = !{!"clang version 3.7.0"}
4444 !12 = !DILocalVariable(name: "x", arg: 1, scope: !4, file: !5, line: 4, type: !8)
45 !13 = !DIExpression()
46 !14 = !DILocation(line: 4, scope: !4)
47 !15 = !DILocation(line: 8, scope: !4)
45 !13 = !DILocation(line: 4, scope: !4)
46 !14 = !DILocation(line: 8, scope: !4)
4847
4948 ...
5049 ---
5958 body: |
6059 bb.0.entry:
6160 liveins: %edi
62 ; CHECK: DBG_VALUE debug-use _, 0, !11, !12, debug-location !13
63 ; CHECK: %eax = COPY %0, debug-location !14
64 ; CHECK: RETQ %eax, debug-location !14
61 ; CHECK: DBG_VALUE debug-use _, 0, !11, !DIExpression(), debug-location !12
62 ; CHECK: %eax = COPY %0, debug-location !13
63 ; CHECK: RETQ %eax, debug-location !13
6564 %0 = COPY %edi
66 DBG_VALUE debug-use _, 0, !12, !13, debug-location !14
65 DBG_VALUE debug-use _, 0, !12, !DIExpression(), debug-location !13
6766 MOV32mr %stack.0.x.addr, 1, _, 0, _, %0
68 %eax = COPY %0, debug-location !15
69 RETQ %eax, debug-location !15
67 %eax = COPY %0, debug-location !14
68 RETQ %eax, debug-location !14
7069 ...
7170 ---
7271 name: test_typed_immediates
8281 liveins: %edi
8382
8483 %0 = COPY %edi
85 ; CHECK: DBG_VALUE _, i32 0, !11, !12
86 ; CHECK-NEXT: DBG_VALUE _, i64 -22, !11, !12
87 ; CHECK-NEXT: DBG_VALUE _, i128 123492148938512984928424384934328985928, !11, !12
88 DBG_VALUE _, i32 0, !12, !13
89 DBG_VALUE _, i64 -22, !12, !13
90 DBG_VALUE _, i128 123492148938512984928424384934328985928, !12, !13
84 ; CHECK: DBG_VALUE _, i32 0, !DIExpression(), !12
85 ; CHECK-NEXT: DBG_VALUE _, i64 -22, !DIExpression(), !12
86 ; CHECK-NEXT: DBG_VALUE _, i128 123492148938512984928424384934328985928, !DIExpression(), !12
87 DBG_VALUE _, i32 0, !DIExpression(), !13
88 DBG_VALUE _, i64 -22, !DIExpression(), !13
89 DBG_VALUE _, i128 123492148938512984928424384934328985928, !DIExpression(), !13
9190 MOV32mr %stack.0.x.addr, 1, _, 0, _, %0
9291 %eax = COPY %0
9392 RETQ %eax
77 entry:
88 %x.addr = alloca i32, align 4
99 store i32 %x, i32* %x.addr, align 4
10 call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !12, metadata !13), !dbg !14
11 %0 = load i32, i32* %x.addr, align 4, !dbg !15
12 ret i32 %0, !dbg !15
10 call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !12, metadata !DIExpression()), !dbg !13
11 %0 = load i32, i32* %x.addr, align 4, !dbg !14
12 ret i32 %0, !dbg !14
1313 }
1414
1515 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
3333 !10 = !{i32 2, !"Debug Info Version", i32 3}
3434 !11 = !{!"clang version 3.7.0"}
3535 !12 = !DILocalVariable(name: "x", arg: 1, scope: !4, file: !5, line: 4, type: !8)
36 !13 = !DIExpression()
37 !14 = !DILocation(line: 4, scope: !4)
38 !15 = !DILocation(line: 8, scope: !4)
36 !13 = !DILocation(line: 4, scope: !4)
37 !14 = !DILocation(line: 8, scope: !4)
3938
4039 ...
4140 ---
5150 bb.0.entry:
5251 liveins: %edi
5352 ; CHECK: %0 = COPY %edi
54 ; CHECK-NEXT: DBG_VALUE _, 0, !11, !12
53 ; CHECK-NEXT: DBG_VALUE _, 0, !11, !DIExpression()
5554 %0 = COPY %edi
56 DBG_VALUE _, 0, !12, ! 13
55 DBG_VALUE _, 0, !12, !DIExpression()
5756 MOV32mr %stack.0.x.addr, 1, _, 0, _, %0
5857 %eax = COPY %0
5958 RETQ %eax
1414 %1 = bitcast [256 x i8]* %y.i to i8*
1515 call void @llvm.lifetime.end(i64 -1, i8* %1) #3
1616 call void @llvm.lifetime.start(i64 -1, i8* %0) #3
17 call void @llvm.dbg.declare(metadata i8* %0, metadata !4, metadata !7) #3, !dbg !8
17 call void @llvm.dbg.declare(metadata i8* %0, metadata !4, metadata !DIExpression()) #3, !dbg !7
1818 br label %for.body
1919 }
2020
3434 !1 = !DIFile(filename: "t.c", directory: "")
3535 !2 = !{}
3636 !3 = !{i32 1, !"Debug Info Version", i32 3}
37 !4 = !DILocalVariable(name: "x", scope: !5, file: !1, line: 16, type: !9)
37 !4 = !DILocalVariable(name: "x", scope: !5, file: !1, line: 16, type: !8)
3838 !5 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0)
3939 !6 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)
40 !7 = !DIExpression()
41 !8 = !DILocation(line: 0, scope: !5)
42 !9 = !DICompositeType(tag: DW_TAG_array_type, baseType: !6, size: 2048, align: 8, elements: !10)
43 !10 = !{!11}
44 !11 = !DISubrange(count: 256)
40 !7 = !DILocation(line: 0, scope: !5)
41 !8 = !DICompositeType(tag: DW_TAG_array_type, baseType: !6, size: 2048, align: 8, elements: !9)
42 !9 = !{!10}
43 !10 = !DISubrange(count: 256)
4544 ...
4645 ---
4746 name: foo
5150 # CHECK-LABEL: foo
5251 # CHECK: stack:
5352 # CHECK: - { id: 0, name: y.i, type: default, offset: 0, size: 256, alignment: 16,
54 # CHECK-NEXT: callee-saved-register: '', di-variable: '!4', di-expression: '!10',
55 # CHECK-NEXT: di-location: '!11' }
53 # CHECK-NEXT: callee-saved-register: '', di-variable: '!4', di-expression: '!DIExpression()',
54 # CHECK-NEXT: di-location: '!10' }
5655 stack:
5756 - { id: 0, name: y.i, offset: 0, size: 256, alignment: 16, di-variable: '!4',
58 di-expression: '!7', di-location: '!8' }
57 di-expression: '!DIExpression()', di-location: '!7' }
5958 body: |
6059 bb.0.entry:
6160 successors: %bb.1.for.body
6261 bb.1.for.body:
6362 successors: %bb.1.for.body
6463
65 DBG_VALUE %stack.0.y.i, 0, !4, !7, debug-location !8
64 DBG_VALUE %stack.0.y.i, 0, !4, !DIExpression(), debug-location !7
6665 JMP_1 %bb.1.for.body
6766 ...
1313 @d = common local_unnamed_addr global i32 0, align 4
1414 @b = common local_unnamed_addr global i32 0, align 4
1515
16 define i32 @fn1() local_unnamed_addr !dbg !9 {
17 %1 = load %struct.A*, %struct.A** @c, align 8, !dbg !14
18 %2 = load i32, i32* @a, align 4, !dbg !14
19 %3 = sext i32 %2 to i64, !dbg !14
20 %4 = getelementptr inbounds %struct.A, %struct.A* %1, i64 %3, !dbg !14
21 %5 = ptrtoint %struct.A* %4 to i64, !dbg !14
22 %6 = trunc i64 %5 to i32, !dbg !14
23 store i32 %6, i32* @d, align 4, !dbg !14
24 %7 = getelementptr inbounds %struct.A, %struct.A* %1, i64 %3, i32 2, !dbg !15
25 tail call void @llvm.dbg.value(metadata i32* %7, i64 0, metadata !12, metadata !16), !dbg !17
26 br label %8, !dbg !18
16 define i32 @fn1() local_unnamed_addr !dbg !8 {
17 %1 = load %struct.A*, %struct.A** @c, align 8, !dbg !13
18 %2 = load i32, i32* @a, align 4, !dbg !13
19 %3 = sext i32 %2 to i64, !dbg !13
20 %4 = getelementptr inbounds %struct.A, %struct.A* %1, i64 %3, !dbg !13
21 %5 = ptrtoint %struct.A* %4 to i64, !dbg !13
22 %6 = trunc i64 %5 to i32, !dbg !13
23 store i32 %6, i32* @d, align 4, !dbg !13
24 %7 = getelementptr inbounds %struct.A, %struct.A* %1, i64 %3, i32 2, !dbg !14
25 tail call void @llvm.dbg.value(metadata i32* %7, i64 0, metadata !11, metadata !DIExpression()), !dbg !15
26 br label %8, !dbg !16
2727
2828 ;
29 %9 = load i32, i32* %7, align 4, !dbg !19
30 store i32 %9, i32* @d, align 4, !dbg !19
31 br label %8, !dbg !20
29 %9 = load i32, i32* %7, align 4, !dbg !17
30 store i32 %9, i32* @d, align 4, !dbg !17
31 br label %8, !dbg !18
3232 }
3333
3434 ; Function Attrs: nounwind readnone
3838
3939 !llvm.dbg.cu = !{!0}
4040 !llvm.module.flags = !{!5, !6, !7}
41 !misc = !{!8}
4241
4342 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, globals: !2)
4443 !1 = !DIFile(filename: "test.c", directory: "")
4847 !5 = !{i32 2, !"Dwarf Version", i32 4}
4948 !6 = !{i32 2, !"Debug Info Version", i32 3}
5049 !7 = !{i32 1, !"PIC Level", i32 2}
51 !8 = !DIExpression(DW_OP_plus_uconst, 8, DW_OP_stack_value)
52 !9 = distinct !DISubprogram(name: "fn1", scope: !1, file: !1, line: 7, type: !10, isLocal: false, isDefinition: true, scopeLine: 7, isOptimized: true, unit: !0, variables: !11)
53 !10 = !DISubroutineType(types: !3)
54 !11 = !{!12}
55 !12 = !DILocalVariable(name: "e", scope: !9, file: !1, line: 8, type: !13)
56 !13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !4, size: 64)
57 !14 = !DILocation(line: 9, scope: !9)
58 !15 = !DILocation(line: 10, scope: !9)
59 !16 = !DIExpression()
60 !17 = !DILocation(line: 8, scope: !9)
61 !18 = !DILocation(line: 11, scope: !9)
62 !19 = !DILocation(line: 13, scope: !9)
63 !20 = !DILocation(line: 14, scope: !9)
50 !8 = distinct !DISubprogram(name: "fn1", scope: !1, file: !1, line: 7, type: !9, isLocal: false, isDefinition: true, scopeLine: 7, isOptimized: true, unit: !0, variables: !10)
51 !9 = !DISubroutineType(types: !3)
52 !10 = !{!11}
53 !11 = !DILocalVariable(name: "e", scope: !8, file: !1, line: 8, type: !12)
54 !12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !4, size: 64)
55 !13 = !DILocation(line: 9, scope: !8)
56 !14 = !DILocation(line: 10, scope: !8)
57 !15 = !DILocation(line: 8, scope: !8)
58 !16 = !DILocation(line: 11, scope: !8)
59 !17 = !DILocation(line: 13, scope: !8)
60 !18 = !DILocation(line: 14, scope: !8)
6461
6562 ...
6663 ---
9794 bb.0 (%ir-block.0):
9895 successors: %bb.1(0x80000000)
9996
100 ; CHECK: %3 = LEA64r %2, 2, %2, 0, _, debug-location !14
101 ; CHECK-NEXT: %4 = LEA64r %1, 4, %3, 0, _, debug-location !14
102 ; CHECK-NOT: %0 = LEA64r %1, 4, %3, 8, _, debug-location !15
103 ; CHECK: DBG_VALUE debug-use %4, debug-use _, !12, !8, debug-location !17
97 ; CHECK: %3 = LEA64r %2, 2, %2, 0, _, debug-location !13
98 ; CHECK-NEXT: %4 = LEA64r %1, 4, %3, 0, _, debug-location !13
99 ; CHECK-NOT: %0 = LEA64r %1, 4, %3, 8, _, debug-location !14
100 ; CHECK: DBG_VALUE debug-use %4, debug-use _, !11, !DIExpression(DW_OP_plus_uconst, 8, DW_OP_stack_value), debug-location !15
104101
105 %1 = MOV64rm %rip, 1, _, @c, _, debug-location !14 :: (dereferenceable load 8 from @c)
106 %2 = MOVSX64rm32 %rip, 1, _, @a, _, debug-location !14 :: (dereferenceable load 4 from @a)
107 %3 = LEA64r %2, 2, %2, 0, _, debug-location !14
108 %4 = LEA64r %1, 4, %3, 0, _, debug-location !14
109 %5 = COPY %4.sub_32bit, debug-location !14
110 MOV32mr %rip, 1, _, @d, _, killed %5, debug-location !14 :: (store 4 into @d)
111 %0 = LEA64r %1, 4, %3, 8, _, debug-location !15
112 DBG_VALUE debug-use %0, debug-use _, !12, !16, debug-location !17
102 %1 = MOV64rm %rip, 1, _, @c, _, debug-location !13 :: (dereferenceable load 8 from @c)
103 %2 = MOVSX64rm32 %rip, 1, _, @a, _, debug-location !13 :: (dereferenceable load 4 from @a)
104 %3 = LEA64r %2, 2, %2, 0, _, debug-location !13
105 %4 = LEA64r %1, 4, %3, 0, _, debug-location !13
106 %5 = COPY %4.sub_32bit, debug-location !13
107 MOV32mr %rip, 1, _, @d, _, killed %5, debug-location !13 :: (store 4 into @d)
108 %0 = LEA64r %1, 4, %3, 8, _, debug-location !14
109 DBG_VALUE debug-use %0, debug-use _, !11, !DIExpression(), debug-location !15
113110
114111 ; CHECK-LABEL: bb.1 (%ir-block.8):
115 ; CHECK: %6 = MOV32rm %4, 1, _, 8, _, debug-location !19 :: (load 4 from %ir.7)
112 ; CHECK: %6 = MOV32rm %4, 1, _, 8, _, debug-location !17 :: (load 4 from %ir.7)
116113
117114 bb.1 (%ir-block.8):
118115 successors: %bb.1(0x80000000)
119116
120 %6 = MOV32rm %0, 1, _, 0, _, debug-location !19 :: (load 4 from %ir.7)
121 MOV32mr %rip, 1, _, @d, _, killed %6, debug-location !19 :: (store 4 into @d)
122 JMP_1 %bb.1, debug-location !20
117 %6 = MOV32rm %0, 1, _, 0, _, debug-location !17 :: (load 4 from %ir.7)
118 MOV32mr %rip, 1, _, @d, _, killed %6, debug-location !17 :: (store 4 into @d)
119 JMP_1 %bb.1, debug-location !18
123120
124121 ...
226226 !47 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed)
227227 !48 = !DILocation(line: 10, column: 8, scope: !40, inlinedAt: !45)
228228
229 # CHECK: ![[I_VAR:[0-9]+]] = !DILocalVariable(name: "i", {{.*}}line: 9, {{.*}})
230 # CHECK: ![[I_LOC:[0-9]+]] = !DILocation(line: 9, column: 37, {{.*}})
231 # CHECK: ![[J_VAR:[0-9]+]] = !DILocalVariable(name: "j", {{.*}}line: 10, {{.*}})
232 # CHECK: ![[J_LOC:[0-9]+]] = !DILocation(line: 10, column: 8, {{.*}})
233
229234 ...
230235 ---
231236 name: _ZN1sC2Ei
245250 liveins: %esi, %rdi, %r14, %rbx, %rbp
246251
247252 ; CHECK: [[REGISTER:%r[a-z0-9]+]] = LEA64r {{%r[a-z0-9]+}}, 1, _, -20, _
248 ; CHECK-NEXT: DBG_VALUE debug-use [[REGISTER]], debug-use _, !46, !17, debug-location !48
249 ; CHECK-NEXT: DBG_VALUE debug-use [[REGISTER]], debug-use _, !39, !17, debug-location !44
253 ; CHECK-NEXT: DBG_VALUE debug-use [[REGISTER]], debug-use _, ![[J_VAR]], !DIExpression(), debug-location ![[J_LOC]]
254 ; CHECK-NEXT: DBG_VALUE debug-use [[REGISTER]], debug-use _, ![[I_VAR]], !DIExpression(), debug-location ![[I_LOC]]
250255
251256 frame-setup PUSH64r killed %rbp, implicit-def %rsp, implicit %rsp
252257 CFI_INSTRUCTION def_cfa_offset 16
1919 ; no native double data type available.
2020 ; Test that debug info for both values survives:
2121 ; CHECK: call void @llvm.dbg.value(metadata i64 0,
22 ; CHECK-SAME: metadata ![[C:.*]], metadata ![[REAL:.*]])
22 ; CHECK-SAME: metadata ![[C:[^,]*]],
23 ; CHECK-SAME: metadata !DIExpression(DW_OP_LLVM_fragment, 0, 64))
2324 store double 0.000000e+00, double* %c.imagp, align 8, !dbg !17
2425 ; CHECK: call void @llvm.dbg.value(metadata i64 0,
25 ; CHECK-SAME: metadata ![[C]], metadata ![[IMG:.*]])
26 ; CHECK-SAME: metadata ![[C]],
27 ; CHECK-SAME: metadata !DIExpression(DW_OP_LLVM_fragment, 64, 64))
2628 ret void, !dbg !18
2729 }
28 ; CHECK: ![[REAL]] = !DIExpression(DW_OP_LLVM_fragment, 0, 64)
29 ; CHECK: ![[IMG]] = !DIExpression(DW_OP_LLVM_fragment, 64, 64)
3030
3131 ; Function Attrs: nounwind readnone
3232 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
2323 ; CHECK: @array.0.0 = internal unnamed_addr global i32 0, align 16, !dbg ![[EL0:.*]]
2424 ; CHECK: @array.1.0 = internal unnamed_addr global i32 0, align 8, !dbg ![[EL1:.*]]
2525 ;
26 ; CHECK: ![[EL0]] = !DIGlobalVariableExpression(var: ![[VAR:.*]], expr: ![[EX1:.*]])
26 ; CHECK: ![[EL0]] = !DIGlobalVariableExpression(var: ![[VAR:.*]], expr: !DIExpression(DW_OP_LLVM_fragment, 0, 32))
2727 ; CHECK: ![[VAR]] = distinct !DIGlobalVariable(name: "array"
28 ; CHECK: ![[EX1]] = !DIExpression(DW_OP_LLVM_fragment, 0, 32)
29 ; CHECK: ![[EL1]] = !DIGlobalVariableExpression(var: ![[VAR]], expr: ![[EX2:.*]])
30 ; CHECK: ![[EX2]] = !DIExpression(DW_OP_LLVM_fragment, 64, 32)
28 ; CHECK: ![[EL1]] = !DIGlobalVariableExpression(var: ![[VAR]], expr: !DIExpression(DW_OP_LLVM_fragment, 64, 32))
3129
3230
3331 ; Function Attrs: nounwind optsize ssp uwtable
2121 ; CHECK: @static_struct.0 = internal unnamed_addr global i32 0, align 8, !dbg ![[EL0:.*]]
2222 ; CHECK: @static_struct.1 = internal unnamed_addr global i64 0, align 8, !dbg ![[EL1:.*]]
2323
24 ; CHECK: ![[EL0]] = !DIGlobalVariableExpression(var: ![[VAR:.*]], expr: ![[EX1:.*]])
24 ; CHECK: ![[EL0]] = !DIGlobalVariableExpression(var: ![[VAR:.*]], expr: !DIExpression(DW_OP_LLVM_fragment, 0, 32))
2525 ; CHECK: ![[VAR]] = distinct !DIGlobalVariable(name: "static_struct"
26 ; CHECK: ![[EX1]] = !DIExpression(DW_OP_LLVM_fragment, 0, 32)
27 ; CHECK: ![[EL1]] = !DIGlobalVariableExpression(var: ![[VAR]], expr: ![[EX2:.*]])
28 ; CHECK: ![[EX2]] = !DIExpression(DW_OP_LLVM_fragment, 32, 64)
26 ; CHECK: ![[EL1]] = !DIGlobalVariableExpression(var: ![[VAR]], expr: !DIExpression(DW_OP_LLVM_fragment, 32, 64))
2927
3028 @static_struct = internal global %struct.mystruct zeroinitializer, align 8, !dbg !0
3129
2323 # with clang -g -O1 -c -emit-llvm LiveDebugValues-3preds.c -S -o live-debug-values-3preds.ll
2424 # then llc -stop-after stackmap-liveness live-debug-values-3preds.ll -o /dev/null > live-debug-values-3preds.mir
2525
26 # CHECK: ![[X_VAR:[0-9]+]] = !DILocalVariable(name: "x", {{.*}})
27 # CHECK: ![[Y_VAR:[0-9]+]] = !DILocalVariable(name: "y", {{.*}})
28 # CHECK: ![[Z_VAR:[0-9]+]] = !DILocalVariable(name: "z", {{.*}})
29
2630 # DBG_VALUE for variables "x", "y" and "z" are extended into BB#9 from its
2731 # predecessors BB#0, BB#2 and BB#8.
2832 # CHECK: bb.9.for.end:
29 # CHECK-DAG: DBG_VALUE debug-use %edi, debug-use _, !11, !16, debug-location !17
30 # CHECK-DAG: DBG_VALUE debug-use %edx, debug-use _, !13, !16, debug-location !20
31 # CHECK-DAG: DBG_VALUE debug-use %esi, debug-use _, !12, !16, debug-location !18
33 # CHECK-DAG: DBG_VALUE debug-use %edi, debug-use _, ![[X_VAR]], !DIExpression(), debug-location !{{[0-9]+}}
34 # CHECK-DAG: DBG_VALUE debug-use %esi, debug-use _, ![[Y_VAR]], !DIExpression(), debug-location !{{[0-9]+}}
35 # CHECK-DAG: DBG_VALUE debug-use %edx, debug-use _, ![[Z_VAR]], !DIExpression(), debug-location !{{[0-9]+}}
3236 # CHECK: RET
3337
3438 --- |
4646 # llc -stop-after=funclet-layout < spill1.ll > spill1.mir
4747 #
4848 # Make sure that we generated DBG_VALUE instructions for the spills
49 # GENERATE: ![[MINUS48:.*]] = !DIExpression(DW_OP_constu, 48, DW_OP_minus)
50 # GENERATE: ![[MINUS52:.*]] = !DIExpression(DW_OP_constu, 52, DW_OP_minus)
51 # GENERATE: ![[MINUS56:.*]] = !DIExpression(DW_OP_constu, 56, DW_OP_minus)
49 # GENERATE: ![[INT0:[0-9]+]] = !DILocalVariable(name: "int0",{{.*}})
50 # GENERATE: ![[INTB:[0-9]+]] = !DILocalVariable(name: "intb",{{.*}})
51 # GENERATE: ![[INTD:[0-9]+]] = !DILocalVariable(name: "intd",{{.*}})
52 #
5253 # GENERATE: bb.1.if.end:
5354 # GENERATE: MOV32mr %rbp, 1, _, -48, _, killed %edx :: (store 4 into %stack.5)
54 # GENERATE-NEXT: DBG_VALUE debug-use %rbp, 0, !29, ![[MINUS48]]
55 # GENERATE-NEXT: DBG_VALUE debug-use %rbp, 0, ![[INT0]], !DIExpression(DW_OP_constu, 48, DW_OP_minus)
5556 # GENERATE: MOV32mr %rbp, 1, _, -52, _, killed %r8d :: (store 4 into %stack.4)
56 # GENERATE-NEXT: DBG_VALUE debug-use %rbp, 0, !35, ![[MINUS52]]
57 # GENERATE-NEXT: DBG_VALUE debug-use %rbp, 0, ![[INTB]], !DIExpression(DW_OP_constu, 52, DW_OP_minus)
5758 # GENERATE: MOV32mr %rbp, 1, _, -56, _, killed %esi :: (store 4 into %stack.3)
58 # GENERATE-NEXT: DBG_VALUE debug-use %rbp, 0, !37, ![[MINUS56]]
59 # GENERATE-NEXT: DBG_VALUE debug-use %rbp, 0, ![[INTD]], !DIExpression(DW_OP_constu, 56, DW_OP_minus)
5960 #
6061 # Check that the spill locations that are valid at the end of bb.1.if.end are
6162 # propagated to subsequent BBs.
6263 #
6364 # GENERATE: bb.2.if.then4:
6465 # GENERATE-NOT: bb.3:
65 # GENERATE-DAG: DBG_VALUE debug-use %rbp, 0, !37, ![[MINUS56]]
66 # GENERATE-DAG: DBG_VALUE debug-use %rbp, 0, !35, ![[MINUS52]]
66 # GENERATE-DAG: DBG_VALUE debug-use %rbp, 0, ![[INTD]], !DIExpression(DW_OP_constu, 56, DW_OP_minus)
67 # GENERATE-DAG: DBG_VALUE debug-use %rbp, 0, ![[INTB]], !DIExpression(DW_OP_constu, 52, DW_OP_minus)
6768 #
6869 # GENERATE: bb.3:
6970 # GENERATE-NOT: bb.4.if.end13:
70 # GENERATE-DAG: DBG_VALUE debug-use %rbp, 0, !37, ![[MINUS56]]
71 # GENERATE-DAG: DBG_VALUE debug-use %rbp, 0, !35, ![[MINUS52]]
71 # GENERATE-DAG: DBG_VALUE debug-use %rbp, 0, ![[INTD]], !DIExpression(DW_OP_constu, 56, DW_OP_minus)
72 # GENERATE-DAG: DBG_VALUE debug-use %rbp, 0, ![[INTB]], !DIExpression(DW_OP_constu, 52, DW_OP_minus)
7273 #
7374 # GENERATE: bb.4.if.end13:
7475 # GENERATE-NOT: bb.5.cleanup:
75 # GENERATE-DAG: DBG_VALUE debug-use %rbp, 0, !37, ![[MINUS56]]
76 # GENERATE-DAG: DBG_VALUE debug-use %rbp, 0, !35, ![[MINUS52]]
76 # GENERATE-DAG: DBG_VALUE debug-use %rbp, 0, ![[INTD]], !DIExpression(DW_OP_constu, 56, DW_OP_minus)
77 # GENERATE-DAG: DBG_VALUE debug-use %rbp, 0, ![[INTB]], !DIExpression(DW_OP_constu, 52, DW_OP_minus)
7778 #
7879 # Check that the spill location rbp-48 (the variable int0) is not propagated
7980 # because int0 is redefined within the same basic block.
8081 #
8182 # TERMINATE: bb.2.if.then4:
82 # TERMINATE-NOT: DBG_VALUE debug-use %rbp, -48, !26, !38
83 # TERMINATE-NOT: DBG_VALUE debug-use %rbp, -48,
8384 --- |
8485 ; ModuleID = ''
8586 source_filename = "spill1.c"
3131
3232 # DBG_VALUE for variable "n" is extended into BB#5 from its predecessors BB#3
3333 # and BB#4.
34 # CHECK: ![[N_VAR:[0-9]+]] = !DILocalVariable(name: "n",{{.*}})
35 #
3436 # CHECK: bb.5.if.end.7:
35 # CHECK: DBG_VALUE debug-use %ebx, debug-use _, !19, !20, debug-location !33
37 # CHECK: DBG_VALUE debug-use %ebx, debug-use _, ![[N_VAR]], !DIExpression(), debug-location !{{[0-9]+}}
3638
3739
3840 --- |
1212 ; This test verifies that LiveDebugValues doesn't propagate DBG_VALUEs into
1313 ; basic blocks that are beyond the scope of the source variable.
1414 ;
15 ; CHECK: ![[F_SP:[0-9]+]] = distinct !DISubprogram(name: "f", {{.*}})
16 ; CHECK: ![[A_VAR:[0-9]+]] = !DILocalVariable(name: "a",{{.*}})
17 ; CHECK: ![[I_VAR:[0-9]+]] = !DILocalVariable(name: "i",{{.*}})
18 ; CHECK: ![[I_LOC:[0-9]+]] = !DILocation(line: 4, column: 14, scope: !{{[0-9]+}})
19 ; CHECK: ![[INLCS1:[0-9]+]] = !DILocation(line: 3, column: 41, scope: ![[F_SP]], inlinedAt: ![[CS1:[0-9]+]])
20 ; CHECK: ![[CS1]] = distinct !DILocation(line: 5, column: 3, scope: !{{[0-9]+}})
21 ; CHECK: ![[INLCS2:[0-9]+]] = !DILocation(line: 3, column: 41, scope: ![[F_SP]], inlinedAt: ![[CS2:[0-9]+]])
22 ; CHECK: ![[CS2]] = distinct !DILocation(line: 7, column: 5, scope: !{{[0-9]+}})
23 ; CHECK: ![[INLCS3:[0-9]+]] = !DILocation(line: 3, column: 41, scope: ![[F_SP]], inlinedAt: ![[CS3:[0-9]+]])
24 ; CHECK: ![[CS3]] = distinct !DILocation(line: 8, column: 3, scope: !{{[0-9]+}})
25 ;
1526 ; CHECK: bb.1.if.then:
16 ; CHECK: DBG_VALUE debug-use %ebx, debug-use _, !19, !13, debug-location !20
17 ; CHECK-NOT: DBG_VALUE debug-use %ebx, debug-use _, !12, !13, debug-location !21
18 ; CHECK: DBG_VALUE debug-use %ebx, debug-use _, !12, !13, debug-location !27
27 ; CHECK: DBG_VALUE debug-use %ebx, debug-use _, ![[I_VAR]], !DIExpression(), debug-location ![[I_LOC]]
28 ; CHECK-NOT: DBG_VALUE debug-use %ebx, debug-use _, ![[A_VAR]], !DIExpression(), debug-location
29 ; CHECK: DBG_VALUE debug-use %ebx, debug-use _, ![[A_VAR]], !DIExpression(), debug-location ![[INLCS2]]
1930 ; CHECK: bb.2.if.end:
20 ; CHECK: DBG_VALUE debug-use %ebx, debug-use _, !19, !13, debug-location !20
21 ; CHECK-NOT: DBG_VALUE debug-use %ebx, debug-use _, !12, !13, debug-location !21
22 ; CHECK: DBG_VALUE debug-use %ebx, debug-use _, !12, !13, debug-location !31
31 ; CHECK: DBG_VALUE debug-use %ebx, debug-use _, ![[I_VAR]], !DIExpression(), debug-location ![[I_LOC]]
32 ; CHECK-NOT: DBG_VALUE debug-use %ebx, debug-use _, ![[A_VAR]], !DIExpression(), debug-location
33 ; CHECK: DBG_VALUE debug-use %ebx, debug-use _, ![[A_VAR]], !DIExpression(), debug-location ![[INLCS3]]
2334 ;
2435 ; ModuleID = 'livedebugvalues-limit.ll'
2536 source_filename = "livedebugvalues-limit.c"
1212 ; return 0;
1313 ; }
1414 ;
15 ; CHECK: ![[MDN1:[0-9]+]] = !DIExpression(DW_OP_LLVM_fragment, 32, 16)
16 ; CHECK: ![[MDN2:[0-9]+]] = !DIExpression(DW_OP_LLVM_fragment, 48, 16)
17 ; CHECK: ![[MDN3:[0-9]+]] = !DIExpression(DW_OP_LLVM_fragment, 0, 16)
18 ; CHECK: ![[MDN4:[0-9]+]] = !DIExpression(DW_OP_LLVM_fragment, 16, 16)
19 ; CHECK-DAG: DBG_VALUE debug-use %r{{[0-9]+}}, debug-use _, !{{[0-9]+}}, ![[MDN1]], debug-location !{{[0-9]+}}
20 ; CHECK-DAG: DBG_VALUE debug-use %r{{[0-9]+}}, debug-use _, !{{[0-9]+}}, ![[MDN2]], debug-location !{{[0-9]+}}
21 ; CHECK-DAG: DBG_VALUE debug-use %r{{[0-9]+}}, debug-use _, !{{[0-9]+}}, ![[MDN3]], debug-location !{{[0-9]+}}
22 ; CHECK-DAG: DBG_VALUE debug-use %r{{[0-9]+}}, debug-use _, !{{[0-9]+}}, ![[MDN4]], debug-location !{{[0-9]+}}
15 ; CHECK-DAG: DBG_VALUE debug-use %r{{[0-9]+}}, debug-use _, !{{[0-9]+}}, !DIExpression(DW_OP_LLVM_fragment, 32, 16), debug-location !{{[0-9]+}}
16 ; CHECK-DAG: DBG_VALUE debug-use %r{{[0-9]+}}, debug-use _, !{{[0-9]+}}, !DIExpression(DW_OP_LLVM_fragment, 48, 16), debug-location !{{[0-9]+}}
17 ; CHECK-DAG: DBG_VALUE debug-use %r{{[0-9]+}}, debug-use _, !{{[0-9]+}}, !DIExpression(DW_OP_LLVM_fragment, 0, 16), debug-location !{{[0-9]+}}
18 ; CHECK-DAG: DBG_VALUE debug-use %r{{[0-9]+}}, debug-use _, !{{[0-9]+}}, !DIExpression(DW_OP_LLVM_fragment, 16, 16), debug-location !{{[0-9]+}}
2319
2420 ; ModuleID = 'sdagsplit-1.c'
2521 target datalayout = "e-m:e-p:16:16-i32:16-i64:16-f32:16-f64:16-a:8-n8:16-S16"
1515 ; Test that we correctly lower dbg.declares for arrays.
1616 ;
1717 ; CHECK: define i32 @main
18 ; CHECK: call void @llvm.dbg.value(metadata i32 42, metadata ![[ARRAY:[0-9]+]], metadata ![[EXPR:[0-9]+]])
18 ; CHECK: call void @llvm.dbg.value(metadata i32 42, metadata ![[ARRAY:[0-9]+]], metadata !DIExpression(DW_OP_LLVM_fragment, 0, 32))
1919 ; CHECK: ![[ARRAY]] = !DILocalVariable(name: "array",{{.*}} line: 6
20 ; CHECK: ![[EXPR]] = !DIExpression(DW_OP_LLVM_fragment, 0, 32)
2120 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
2221 target triple = "x86_64-apple-macosx10.9.0"
2322
88 ; ++x;
99 ; return x; // check that x is not a constant here.
1010 ; }
11 ; CHECK: ![[EXPR:.*]] = !DIExpression(DW_OP_plus_uconst, 4, DW_OP_deref)
1211 ; CHECK: ![[X:.*]] = !DILocalVariable(name: "x",
1312 ; CHECK: bb.0.entry:
1413 ; CHECK: DBG_VALUE 23, 0, ![[X]],
15 ; CHECK: DBG_VALUE %rsp, 0, ![[X]], ![[EXPR]],
14 ; CHECK: DBG_VALUE %rsp, 0, ![[X]], !DIExpression(DW_OP_plus_uconst, 4, DW_OP_deref),
1615 ; CHECK: bb.1.if.then:
1716 ; CHECK: DBG_VALUE 43, 0, ![[X]],
1817 ; CHECK: bb.2.if.end:
1313 ; }
1414
1515 ; CHECK: ![[ZZZ:.*]] = !DILocalVariable(name: "zzz",
16 ; CHECK: ![[ZZZ_EXPR:.*]] = !DIExpression(DW_OP_deref, DW_OP_constu, 400, DW_OP_minus)
17 ; CHECK: DBG_VALUE {{.*}} ![[ZZZ]], ![[ZZZ_EXPR]]
16 ; CHECK: DBG_VALUE {{.*}} ![[ZZZ]], !DIExpression(DW_OP_deref, DW_OP_constu, 400, DW_OP_minus)
1817
1918 %struct.S = type { [100 x i32] }
2019
1212 ; return 0;
1313 ; }
1414 ;
15 ; CHECK: ![[MDN1:[0-9]+]] = !DIExpression(DW_OP_LLVM_fragment, 0, 32)
16 ; CHECK: ![[MDN2:[0-9]+]] = !DIExpression(DW_OP_LLVM_fragment, 32, 32)
17 ; CHECK-DAG: DBG_VALUE debug-use %{{[a-z]+}}, debug-use _, !{{[0-9]+}}, ![[MDN1]], debug-location !{{[0-9]+}}
18 ; CHECK-DAG: DBG_VALUE debug-use %{{[a-z]+}}, debug-use _, !{{[0-9]+}}, ![[MDN2]], debug-location !{{[0-9]+}}
15 ; CHECK-DAG: DBG_VALUE debug-use %{{[a-z]+}}, debug-use _, !{{[0-9]+}}, !DIExpression(DW_OP_LLVM_fragment, 0, 32), debug-location !{{[0-9]+}}
16 ; CHECK-DAG: DBG_VALUE debug-use %{{[a-z]+}}, debug-use _, !{{[0-9]+}}, !DIExpression(DW_OP_LLVM_fragment, 32, 32), debug-location !{{[0-9]+}}
1917
2018 ; ModuleID = 'sdagsplit-1.c'
2119 target datalayout = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128"
2020
2121 ; Verify that SROA creates a variable piece when splitting i1.
2222 ; CHECK: %[[I1:.*]] = alloca [12 x i8], align 4
23 ; CHECK: call void @llvm.dbg.declare(metadata [12 x i8]* %[[I1]], metadata ![[VAR:[0-9]+]], metadata ![[PIECE1:[0-9]+]])
24 ; CHECK: call void @llvm.dbg.value(metadata i32 %[[A:.*]], metadata ![[VAR]], metadata ![[PIECE2:[0-9]+]])
23 ; CHECK: call void @llvm.dbg.declare(metadata [12 x i8]* %[[I1]], metadata ![[VAR:[0-9]+]], metadata !DIExpression(DW_OP_LLVM_fragment, 32, 96))
24 ; CHECK: call void @llvm.dbg.value(metadata i32 %[[A:.*]], metadata ![[VAR]], metadata !DIExpression(DW_OP_LLVM_fragment, 0, 32))
2525 ; CHECK: ret i32 %[[A]]
2626 ; Read Var and Piece:
2727 ; CHECK: ![[VAR]] = !DILocalVariable(name: "i1",{{.*}} line: 11,
28 ; CHECK: ![[PIECE1]] = !DIExpression(DW_OP_LLVM_fragment, 32, 96)
29 ; CHECK: ![[PIECE2]] = !DIExpression(DW_OP_LLVM_fragment, 0, 32)
3028
3129 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
3230 target triple = "x86_64-apple-macosx10.9.0"
1919 ;
2020
2121 ; Verify that SROA creates a variable piece when splitting i1.
22 ; CHECK: call void @llvm.dbg.value(metadata i64 %outer.coerce0, metadata ![[O:[0-9]+]], metadata ![[PIECE1:[0-9]+]]),
23 ; CHECK: call void @llvm.dbg.value(metadata i64 %outer.coerce1, metadata ![[O]], metadata ![[PIECE2:[0-9]+]]),
24 ; CHECK: call void @llvm.dbg.value({{.*}}, metadata ![[I1:[0-9]+]], metadata ![[PIECE3:[0-9]+]]),
22 ; CHECK: call void @llvm.dbg.value(metadata i64 %outer.coerce0, metadata ![[O:[0-9]+]], metadata !DIExpression(DW_OP_LLVM_fragment, 0, 64)),
23 ; CHECK: call void @llvm.dbg.value(metadata i64 %outer.coerce1, metadata ![[O]], metadata !DIExpression(DW_OP_LLVM_fragment, 64, 64)),
24 ; CHECK: call void @llvm.dbg.value({{.*}}, metadata ![[I1:[0-9]+]], metadata !DIExpression(DW_OP_LLVM_fragment, 0, 32)),
2525 ; CHECK-DAG: ![[O]] = !DILocalVariable(name: "outer",{{.*}} line: 10
26 ; CHECK-DAG: ![[PIECE1]] = !DIExpression(DW_OP_LLVM_fragment, 0, 64)
27 ; CHECK-DAG: ![[PIECE2]] = !DIExpression(DW_OP_LLVM_fragment, 64, 64)
2826 ; CHECK-DAG: ![[I1]] = !DILocalVariable(name: "i1",{{.*}} line: 11
29 ; CHECK-DAG: ![[PIECE3]] = !DIExpression(DW_OP_LLVM_fragment, 0, 32)
3027
3128 ; ModuleID = 'sroasplit-2.c'
3229 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
22 ; Test that SROA updates the debug info correctly if an alloca was rewritten but
33 ; not partitioned into multiple allocas.
44 ;
5 ; CHECK: call void @llvm.dbg.value(metadata float %s.coerce, metadata ![[VAR:[0-9]+]], metadata ![[EXPR:[0-9]+]])
5 ; CHECK: call void @llvm.dbg.value(metadata float %s.coerce, metadata ![[VAR:[0-9]+]], metadata !DIExpression())
66 ; CHECK: ![[VAR]] = !DILocalVariable(name: "s",{{.*}} line: 3,
7 ; CHECK: ![[EXPR]] = !DIExpression(
8 ; CHECK-NOT: DW_OP_LLVM_fragment
97
108 ;
119 ; struct S { float f; };
11 ;
22 ; Test that recursively splitting an alloca updates the debug info correctly.
33 ; CHECK: %[[T:.*]] = load i64, i64* @t, align 8
4 ; CHECK: call void @llvm.dbg.value(metadata i64 %[[T]], metadata ![[Y:.*]], metadata ![[P1:.*]])
4 ; CHECK: call void @llvm.dbg.value(metadata i64 %[[T]], metadata ![[Y:.*]], metadata !DIExpression(DW_OP_LLVM_fragment, 0, 64))
55 ; CHECK: %[[T1:.*]] = load i64, i64* @t, align 8
6 ; CHECK: call void @llvm.dbg.value(metadata i64 %[[T1]], metadata ![[Y]], metadata ![[P2:.*]])
7 ; CHECK: call void @llvm.dbg.value(metadata i64 %[[T]], metadata ![[R:.*]], metadata ![[P3:.*]])
8 ; CHECK: call void @llvm.dbg.value(metadata i64 %[[T1]], metadata ![[R]], metadata ![[P4:.*]])
9 ; CHECK: ![[P1]] = !DIExpression(DW_OP_LLVM_fragment, 0, 64)
10 ; CHECK: ![[P2]] = !DIExpression(DW_OP_LLVM_fragment, 64, 64)
11 ; CHECK: ![[P3]] = !DIExpression(DW_OP_LLVM_fragment, 192, 64)
12 ; CHECK: ![[P4]] = !DIExpression(DW_OP_LLVM_fragment, 256, 64)
6 ; CHECK: call void @llvm.dbg.value(metadata i64 %[[T1]], metadata ![[Y]], metadata !DIExpression(DW_OP_LLVM_fragment, 64, 64))
7 ; CHECK: call void @llvm.dbg.value(metadata i64 %[[T]], metadata ![[R:.*]], metadata !DIExpression(DW_OP_LLVM_fragment, 192, 64))
8 ; CHECK: call void @llvm.dbg.value(metadata i64 %[[T1]], metadata ![[R]], metadata !DIExpression(DW_OP_LLVM_fragment, 256, 64))
139 ;
1410 ; struct p {
1511 ; __SIZE_TYPE__ s;
2323 ; CHECK: entry:
2424 ; Verify that llvm.dbg.declare calls are in the entry basic block.
2525 ; CHECK-NOT: %entry
26 ; CHECK: call void @llvm.dbg.declare(metadata {{.*}}, metadata ![[ARG_ID:[0-9]+]], metadata ![[EMPTY:[0-9]+]])
26 ; CHECK: call void @llvm.dbg.declare(metadata {{.*}}, metadata ![[ARG_ID:[0-9]+]], metadata !DIExpression())
2727 ; CHECK-NOT: %entry
28 ; CHECK: call void @llvm.dbg.declare(metadata {{.*}}, metadata ![[VAR_ID:[0-9]+]], metadata ![[EMPTY:[0-9]+]])
28 ; CHECK: call void @llvm.dbg.declare(metadata {{.*}}, metadata ![[VAR_ID:[0-9]+]], metadata !DIExpression())
2929
3030 declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
3131
4646 ; Verify that debug descriptors for argument and local variable will be replaced
4747 ; with descriptors that end with OpDeref (encoded as 2).
4848 ; CHECK: ![[ARG_ID]] = !DILocalVariable(name: "p", arg: 1,{{.*}} line: 1
49 ; CHECK: ![[EMPTY]] = !DIExpression()
5049 ; CHECK: ![[VAR_ID]] = !DILocalVariable(name: "r",{{.*}} line: 2
5150 ; Verify that there are no more variable descriptors.
5251 ; CHECK-NOT: !DILocalVariable(tag: DW_TAG_arg_variable
1414 }
1515 ; CHECK: [[A]] = !DIGlobalVariableExpression(var: [[AVAR:![0-9]+]])
1616 ; CHECK: [[AVAR]] = !DIGlobalVariable(name: "a", scope: null, type: !2, isLocal: false, isDefinition: true)
17 ; CHECK: [[B]] = !DIGlobalVariableExpression(var: [[BVAR:![0-9]+]], expr: [[EXPR:![0-9]+]])
17 ; CHECK: [[B]] = !DIGlobalVariableExpression(var: [[BVAR:![0-9]+]], expr: !DIExpression(DW_OP_plus_uconst, 4))
1818 ; CHECK: [[BVAR]] = !DIGlobalVariable(name: "b", scope: null, type: !2, isLocal: false, isDefinition: true)
19 ; CHECK: [[EXPR]] = !DIExpression(DW_OP_plus_uconst, 4)
2019
2120 !llvm.module.flags = !{!4, !5}
2221
4242 entry:
4343
4444 ; CHECK: [[x_addr_i:%[a-zA-Z0-9.]+]] = alloca float, align 4
45 ; CHECK-NEXT: void @llvm.dbg.declare(metadata float* [[x_addr_i]], metadata [[m23:![0-9]+]], metadata !{{[0-9]+}}), !dbg [[m24:![0-9]+]]
45 ; CHECK-NEXT: void @llvm.dbg.declare(metadata float* [[x_addr_i]], metadata [[m23:![0-9]+]], metadata !DIExpression()), !dbg [[m24:![0-9]+]]
4646
4747 %dst.addr = alloca float*, align 4
4848 store float* %dst, float** %dst.addr, align 4
3131 ; CHECK: define void @salvage_load
3232 ; CHECK-NEXT: entry:
3333 ; CHECK-NEXT: call void @llvm.dbg.value(metadata %struct.entry** %queue,
34 ; CHECK-SAME: metadata ![[LOAD_EXPR:[0-9]+]])
34 ; CHECK-SAME: metadata !DIExpression(DW_OP_deref, DW_OP_plus_uconst, 0))
3535 store %struct.entry* %1, %struct.entry** %im_not_dead, align 8
3636 ret void, !dbg !21
3737 }
4545 ; CHECK: define void @salvage_bitcast
4646 ; CHECK-NEXT: entry:
4747 ; CHECK-NEXT: call void @llvm.dbg.value(metadata %struct.entry* %queue,
48 ; CHECK-SAME: metadata ![[BITCAST_EXPR:[0-9]+]])
48 ; CHECK-SAME: metadata !DIExpression(DW_OP_plus_uconst, 0))
4949 store i8* %1, i8** %im_not_dead, align 8
5050 ret void, !dbg !23
5151 }
5959 ; CHECK: define void @salvage_gep0
6060 ; CHECK-NEXT: entry:
6161 ; CHECK-NEXT: call void @llvm.dbg.value(metadata %struct.entry* %queue,
62 ; CHECK-SAME: metadata ![[GEP0_EXPR:[0-9]+]])
62 ; CHECK-SAME: metadata !DIExpression(DW_OP_constu, 8, DW_OP_minus, DW_OP_plus_uconst, 0, DW_OP_stack_value))
6363 store %struct.entry** %1, %struct.entry*** %im_not_dead, align 8
6464 ret void, !dbg !26
6565 }
7373 ; CHECK: define void @salvage_gep1
7474 ; CHECK-NEXT: entry:
7575 ; CHECK-NEXT: call void @llvm.dbg.value(metadata %struct.entry* %queue,
76 ; CHECK-SAME: metadata ![[GEP1_EXPR:[0-9]+]])
76 ; CHECK-SAME: metadata !DIExpression(DW_OP_constu, 8, DW_OP_minus, DW_OP_stack_value, DW_OP_LLVM_fragment, 0, 32))
7777 store %struct.entry** %1, %struct.entry*** %im_not_dead, align 8
7878 ret void, !dbg !29
7979 }
8787 ; CHECK: define void @salvage_gep2
8888 ; CHECK-NEXT: entry:
8989 ; CHECK-NEXT: call void @llvm.dbg.value(metadata %struct.entry* %queue,
90 ; CHECK-SAME: metadata ![[GEP2_EXPR:[0-9]+]])
90 ; CHECK-SAME: metadata !DIExpression(DW_OP_constu, 8, DW_OP_minus, DW_OP_stack_value))
9191 store %struct.entry** %1, %struct.entry*** %im_not_dead, align 8
9292 ret void, !dbg !32
9393 }
94
95 ; CHECK: ![[LOAD_EXPR]] = !DIExpression(DW_OP_deref, DW_OP_plus_uconst, 0)
96 ; CHECK: ![[BITCAST_EXPR]] = !DIExpression(DW_OP_plus_uconst, 0)
97 ; CHECK: ![[GEP0_EXPR]] = !DIExpression(DW_OP_constu, 8, DW_OP_minus, DW_OP_plus_uconst, 0, DW_OP_stack_value)
98 ; CHECK: ![[GEP1_EXPR]] = !DIExpression(DW_OP_constu, 8, DW_OP_minus, DW_OP_stack_value,
99 ; CHECK-SAME: DW_OP_LLVM_fragment, 0, 32)
100 ; CHECK: ![[GEP2_EXPR]] = !DIExpression(DW_OP_constu, 8, DW_OP_minus, DW_OP_stack_value)
10194
10295 ; Function Attrs: nounwind readnone
10396 declare void @llvm.dbg.value(metadata, metadata, metadata) #1
22 ;CHECK-LABEL: func
33 ;CHECK-LABEL: entry
44 ;CHECK-NEXT: tail call void @llvm.dbg.value(metadata i32 %a
5 ;CHECK-NEXT: tail call void @llvm.dbg.value(metadata i32 1, metadata !13, metadata !11), !dbg !15
5 ;CHECK-NEXT: tail call void @llvm.dbg.value(metadata i32 1, metadata ![[I_VAR:[0-9]+]], metadata !DIExpression())
66 ;CHECK-LABEL: for.body:
77 ;CHECK-NEXT: [[I:%.*]] = phi i32 [ 1, %entry ], [ %inc, %for.body ]
8 ;CHECK-NEXT: tail call void @llvm.dbg.value(metadata i32 [[I]], metadata !13, metadata !11), !dbg !15
8 ;CHECK-NEXT: tail call void @llvm.dbg.value(metadata i32 [[I]], metadata ![[I_VAR]], metadata !DIExpression())
9
10 ; CHECK: ![[I_VAR]] = !DILocalVariable(name: "i",{{.*}})
911
1012 ; Function Attrs: noinline nounwind
1113 define void @func(i32 %a) local_unnamed_addr #0 !dbg !6 {
1313 ; CHECK: %[[PHI:.*]] = phi i8 [ 0, %entry ], [ %0, %for.cond ]
1414 %entryN = load i8, i8* %entry1, align 8, !dbg !20
1515 ; CHECK: call void @llvm.dbg.value(metadata i8 %[[PHI]],
16 ; CHECK-SAME: metadata ![[EXPR:[0-9]+]])
16 ; CHECK-SAME: metadata !DIExpression())
1717 %0 = add i8 %entryN, 1
1818 ; CHECK: %0 = add i8 %[[PHI]], 1
1919 ; CHECK: call void @llvm.dbg.value(metadata i8 %0,
20 ; CHECK-SAME: metadata ![[EXPR]])
20 ; CHECK-SAME: metadata !DIExpression())
2121 store i8 %0, i8* %entry1, align 8, !dbg !20
2222 br label %for.cond, !dbg !20
2323 }
24
25 ; CHECK: ![[EXPR]] = !DIExpression()
2624
2725 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
2826
8686 ; OPTIMIZATION_LEVEL_0-NEXT: %x.addr = alloca i32, align 4
8787 ; OPTIMIZATION_LEVEL_0-NEXT: %y.addr = alloca i32, align 4
8888 ; OPTIMIZATION_LEVEL_0-NEXT: store i32 %x, i32* %x.addr, align 4
89 ; OPTIMIZATION_LEVEL_0-NEXT: call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !{{[0-9]+}}, metadata !{{[0-9]+}}), !dbg !{{[0-9]+}}
89 ; OPTIMIZATION_LEVEL_0-NEXT: call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !{{[0-9]+}}, metadata !DIExpression()), !dbg !{{[0-9]+}}
9090 ; OPTIMIZATION_LEVEL_0-NEXT: store i32 %y, i32* %y.addr, align 4
91 ; OPTIMIZATION_LEVEL_0-NEXT: call void @llvm.dbg.declare(metadata i32* %y.addr, metadata !{{[0-9]+}}, metadata !{{[0-9]+}}), !dbg !{{[0-9]+}}
91 ; OPTIMIZATION_LEVEL_0-NEXT: call void @llvm.dbg.declare(metadata i32* %y.addr, metadata !{{[0-9]+}}, metadata !DIExpression()), !dbg !{{[0-9]+}}
9292 ; OPTIMIZATION_LEVEL_0-NEXT: %0 = tail call i32 @maxA(i32 %x, i32 %y), !dbg !{{[0-9]+}}
9393 ; OPTIMIZATION_LEVEL_0-NEXT: ret i32 %0, !dbg !{{[0-9]+}}
9494 ; OPTIMIZATION_LEVEL_0-NEXT: }
9595
9696 ; OPTIMIZATION_LEVEL_2: define i32 @maxB(i32 %x, i32 %y)
9797 ; OPTIMIZATION_LEVEL_2-NEXT: entry:
98 ; OPTIMIZATION_LEVEL_2-NEXT: tail call void @llvm.dbg.value(metadata i32 %x, metadata !{{[0-9]+}}, metadata !{{[0-9]+}}), !dbg !{{[0-9]+}}
99 ; OPTIMIZATION_LEVEL_2-NEXT: tail call void @llvm.dbg.value(metadata i32 %y, metadata !{{[0-9]+}}, metadata !{{[0-9]+}}), !dbg !{{[0-9]+}}
98 ; OPTIMIZATION_LEVEL_2-NEXT: tail call void @llvm.dbg.value(metadata i32 %x, metadata !{{[0-9]+}}, metadata !DIExpression()), !dbg !{{[0-9]+}}
99 ; OPTIMIZATION_LEVEL_2-NEXT: tail call void @llvm.dbg.value(metadata i32 %y, metadata !{{[0-9]+}}, metadata !DIExpression()), !dbg !{{[0-9]+}}
100100 ; OPTIMIZATION_LEVEL_2-NEXT: %0 = tail call i32 @maxA(i32 %x, i32 %y) #{{[0-9]+}}, !dbg !{{[0-9]+}}
101101 ; OPTIMIZATION_LEVEL_2-NEXT: ret i32 %0, !dbg !{{[0-9]+}}
102102 ; OPTIMIZATION_LEVEL_2-NEXT: }
1010 ; Checks that SROA still inserts a bit_piece expression, even if it produces only one piece
1111 ; (as long as that piece is smaller than the whole thing)
1212 ; CHECK-NOT: call void @llvm.dbg.value
13 ; CHECK: call void @llvm.dbg.value(metadata %foo* undef, {{.*}}, metadata ![[BIT_PIECE:[0-9]+]]), !dbg
13 ; CHECK: call void @llvm.dbg.value(metadata %foo* undef, {{.*}}, metadata !DIExpression(DW_OP_LLVM_fragment, 64, 64)), !dbg
1414 ; CHECK-NOT: call void @llvm.dbg.value
15 ; CHECK: ![[BIT_PIECE]] = !DIExpression(DW_OP_LLVM_fragment, 64, 64)
1615 %0 = bitcast %foo* %retval to i8*
1716 %1 = getelementptr inbounds i8, i8* %0, i64 8
1817 %2 = bitcast i8* %1 to %foo**
1313 %0 = zext i32 %n to i64, !dbg !16
1414
1515 ; CHECK: store i8* %[[VLA:.*]], i8** @__safestack_unsafe_stack_ptr
16 ; CHECK: tail call void @llvm.dbg.value(metadata i8* %[[VLA]], metadata ![[TYPE:.*]], metadata ![[EXPR:.*]])
16 ; CHECK: tail call void @llvm.dbg.value(metadata i8* %[[VLA]], metadata ![[TYPE:.*]], metadata !DIExpression(DW_OP_deref))
1717 ; CHECK: call void @capture({{.*}} %[[VLA]])
1818
1919 %vla = alloca i8, i64 %0, align 16, !dbg !16
4949 !15 = !DILocation(line: 2, column: 12, scope: !6)
5050 !16 = !DILocation(line: 3, column: 3, scope: !6)
5151
52 ; CHECK-DAG: ![[EXPR]] = !DIExpression(DW_OP_deref)
5352 !17 = !DIExpression(DW_OP_deref)
5453 !18 = !DILocation(line: 3, column: 8, scope: !6)
5554 !19 = !DILocation(line: 4, column: 3, scope: !6)
1919
2020 ; dbg.declare for %zzz and %xxx are gone; replaced with dbg.declare based off the unsafe stack pointer
2121 ; CHECK-NOT: call void @llvm.dbg.declare
22 ; CHECK: call void @llvm.dbg.declare(metadata i8* %[[USP]], metadata ![[VAR_ARG:.*]], metadata ![[EXPR_ARG:.*]])
22 ; CHECK: call void @llvm.dbg.declare(metadata i8* %[[USP]], metadata ![[VAR_ARG:.*]], metadata !DIExpression(DW_OP_constu, 104, DW_OP_minus))
2323 ; CHECK-NOT: call void @llvm.dbg.declare
24 ; CHECK: call void @llvm.dbg.declare(metadata i8* %[[USP]], metadata ![[VAR_LOCAL:.*]], metadata ![[EXPR_LOCAL:.*]])
24 ; CHECK: call void @llvm.dbg.declare(metadata i8* %[[USP]], metadata ![[VAR_LOCAL:.*]], metadata !DIExpression(DW_OP_constu, 208, DW_OP_minus))
2525 ; CHECK-NOT: call void @llvm.dbg.declare
2626
2727 call void @Capture(%struct.S* %zzz), !dbg !23
3636
3737 ; CHECK-DAG: ![[VAR_ARG]] = !DILocalVariable(name: "zzz"
3838 ; 100 aligned up to 8
39 ; CHECK-DAG: ![[EXPR_ARG]] = !DIExpression(DW_OP_constu, 104, DW_OP_minus
4039
4140 ; CHECK-DAG: ![[VAR_LOCAL]] = !DILocalVariable(name: "xxx"
42 ; CHECK-DAG: ![[EXPR_LOCAL]] = !DIExpression(DW_OP_constu, 208, DW_OP_minus
4341
4442 ; Function Attrs: nounwind readnone
4543 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
2424 tail call void @llvm.dbg.value(metadata i32* %x1, metadata !10, metadata !24), !dbg !16
2525
2626 ; Supported dbg.value: rewritted based on the [[USP]] value.
27 ; CHECK: call void @llvm.dbg.value(metadata i8* %[[USP]], metadata ![[X1:.*]], metadata ![[X1_EXPR:.*]])
27 ; CHECK: call void @llvm.dbg.value(metadata i8* %[[USP]], metadata ![[X1:.*]], metadata !DIExpression(DW_OP_deref, DW_OP_constu, 4, DW_OP_minus))
2828 tail call void @llvm.dbg.value(metadata i32* %x1, metadata !10, metadata !15), !dbg !16
2929 call void @capture(i32* nonnull %x1), !dbg !17
3030
3232 ; CHECK: call void @llvm.random.metadata.use(metadata ![[EMPTY]])
3333 call void @llvm.random.metadata.use(metadata i32* %x2)
3434
35 ; CHECK: call void @llvm.dbg.value(metadata i8* %[[USP]], metadata ![[X2:.*]], metadata ![[X2_EXPR:.*]])
35 ; CHECK: call void @llvm.dbg.value(metadata i8* %[[USP]], metadata ![[X2:.*]], metadata !DIExpression(DW_OP_deref, DW_OP_constu, 8, DW_OP_minus))
3636 call void @llvm.dbg.value(metadata i32* %x2, metadata !12, metadata !15), !dbg !18
3737 call void @capture(i32* nonnull %x2), !dbg !19
3838 ret void, !dbg !20
8383 !13 = !DILocation(line: 5, column: 3, scope: !6)
8484 !14 = !DILocation(line: 6, column: 3, scope: !6)
8585
86 ; CHECK-DAG: ![[X1_EXPR]] = !DIExpression(DW_OP_deref, DW_OP_constu, 4, DW_OP_minus)
87 ; CHECK-DAG: ![[X2_EXPR]] = !DIExpression(DW_OP_deref, DW_OP_constu, 8, DW_OP_minus)
8886 !15 = !DIExpression(DW_OP_deref)
8987 !16 = !DILocation(line: 5, column: 7, scope: !6)
9088 !17 = !DILocation(line: 8, column: 3, scope: !6)
1818 ; parameter. It can reference the register it's in directly without masking off
1919 ; high bits or anything
2020
21 ; CHECK: call void @llvm.dbg.value(metadata i8 %g.coerce0, metadata ![[VAR_STRUCT:[0-9]+]], metadata ![[EXPR_STRUCT1:[0-9]+]])
22 ; CHECK: call void @llvm.dbg.value(metadata i64 %g.coerce1, metadata ![[VAR_STRUCT]], metadata ![[EXPR_STRUCT2:[0-9]+]])
23 ; CHECK: call void @llvm.dbg.value(metadata i1 %b, metadata ![[VAR_BOOL:[0-9]+]], metadata ![[EXPR_BOOL:[0-9]+]])
24 ; CHECK: call void @llvm.dbg.value(metadata i1 %frag, metadata ![[FRAG_BOOL:[0-9]+]], metadata ![[FRAG_BOOL:[0-9]+]])
25 ; CHECK: ![[EXPR_STRUCT1]] = !DIExpression(DW_OP_LLVM_fragment, 0, 8)
26 ; CHECK: ![[EXPR_STRUCT2]] = !DIExpression(DW_OP_LLVM_fragment, 32, 64)
27 ; CHECK: ![[EXPR_BOOL]] = !DIExpression()
28 ; CHECK: ![[FRAG_BOOL]] = !DIExpression(DW_OP_LLVM_fragment, 0, 1)
21 ; CHECK: call void @llvm.dbg.value(metadata i8 %g.coerce0, metadata ![[VAR_STRUCT:[0-9]+]], metadata !DIExpression(DW_OP_LLVM_fragment, 0, 8))
22 ; CHECK: call void @llvm.dbg.value(metadata i64 %g.coerce1, metadata ![[VAR_STRUCT]], metadata !DIExpression(DW_OP_LLVM_fragment, 32, 64))
23 ; CHECK: call void @llvm.dbg.value(metadata i1 %b, metadata ![[VAR_BOOL:[0-9]+]], metadata !DIExpression())
24 ; CHECK: call void @llvm.dbg.value(metadata i1 %frag, metadata ![[VAR_FRAG:[0-9]+]], metadata !DIExpression(DW_OP_LLVM_fragment, 0, 1))
2925
3026 %struct.foo = type { i8, i64 }
3127