llvm.org GIT mirror llvm / 646a736
[Debugify] Set a DI version module flag for llc compatibility Setting the "Debug Info Version" module flag makes it possible to pipe synthetic debug info into llc, which is useful for testing backends. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@333237 91177308-0d34-0410-b5e6-96231b3b80d8 Vedant Kumar 1 year, 3 months ago
5 changed file(s) with 36 addition(s) and 33 deletion(s). Raw diff Collapse all Expand all
5050
5151 ; CHECK-DAG: !llvm.dbg.cu = !{![[CU:.*]]}
5252 ; CHECK-DAG: !llvm.debugify = !{![[NUM_INSTS:.*]], ![[NUM_VARS:.*]]}
53 ; CHECK-DAG: "Debug Info Version"
5354
5455 ; CHECK-DAG: ![[CU]] = distinct !DICompileUnit(language: DW_LANG_C, file: {{.*}}, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: {{.*}})
5556 ; CHECK-DAG: !DIFile(filename: "", directory: "/")
1313 ; CHECK-NEXT: store i32 0, i32* %P
1414
1515 ; Check that all four original local variables have their values preserved.
16 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i8* %p, metadata !8, metadata !DIExpression()), !dbg !14
17 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i32* %P, metadata !10, metadata !DIExpression()), !dbg !15
18 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i32* %P, metadata !11, metadata !DIExpression(DW_OP_deref)), !dbg !18
19 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i32* %P, metadata !13, metadata !DIExpression(DW_OP_deref, DW_OP_plus_uconst, 1, DW_OP_stack_value)), !dbg !19
16 ; CHECK-NEXT: @llvm.dbg.value(metadata i8* %p, metadata ![[p:.*]], metadata !DIExpression())
17 ; CHECK-NEXT: @llvm.dbg.value(metadata i32* %P, metadata ![[P:.*]], metadata !DIExpression())
18 ; CHECK-NEXT: @llvm.dbg.value(metadata i32* %P, metadata ![[DEAD:.*]], metadata !DIExpression(DW_OP_deref))
19 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i32* %P, metadata ![[DEAD2:.*]], metadata !DIExpression(DW_OP_deref, DW_OP_plus_uconst, 1, DW_OP_stack_value))
2020 %p = tail call i8* @malloc(i32 4)
2121 %P = bitcast i8* %p to i32*
2222 %DEAD = load i32, i32* %P
2727 ret i32* %P
2828 }
2929
30 ; CHECK: !8 = !DILocalVariable(name: "1", scope: !5, file: !1, line: 1, type: !9)
31 ; CHECK: !10 = !DILocalVariable(name: "2", scope: !5, file: !1, line: 2, type: !9)
32 ; CHECK: !11 = !DILocalVariable(name: "3", scope: !5, file: !1, line: 3, type: !12)
33 ; CHECK: !13 = !DILocalVariable(name: "4", scope: !5, file: !1, line: 4, type: !12)
34 ; CHECK-DAG: !14 = !DILocation(line: 1, column: 1, scope: !5)
35 ; CHECK-DAG: !15 = !DILocation(line: 2, column: 1, scope: !5)
36 ; CHECK-DAG: !18 = !DILocation(line: 3, column: 1, scope: !5)
37 ; CHECK-DAG: !19 = !DILocation(line: 4, column: 1, scope: !5)
38 ; CHECK-DAG: !16 = !DILocation(line: 6, column: 1, scope: !5)
39 ; CHECK-DAG: !17 = !DILocation(line: 7, column: 1, scope: !5)
30 ; CHECK: ![[p]] = !DILocalVariable(name: "1"
31 ; CHECK: ![[P]] = !DILocalVariable(name: "2"
32 ; CHECK: ![[DEAD]] = !DILocalVariable(name: "3"
33 ; CHECK: ![[DEAD2]] = !DILocalVariable(name: "4"
22 define i64 @test_sext_zext(i16 %A) {
33 ; CHECK-LABEL: @test_sext_zext(
44 ; CHECK-NEXT: [[C2:%.*]] = zext i16 %A to i64
5 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 [[C2]], metadata !8, metadata !DIExpression()), !dbg !13
6 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 [[C2]], metadata !10, metadata !DIExpression()), !dbg !12
5 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 [[C2]], {{.*}}, metadata !DIExpression())
6 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 [[C2]], {{.*}}, metadata !DIExpression())
77 %c1 = zext i16 %A to i32
88 %c2 = sext i32 %c1 to i64
99 ret i64 %c2
1111
1212 define void @test_or(i64 %A) {
1313 ; CHECK-LABEL: @test_or(
14 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, metadata !17, metadata !DIExpression(DW_OP_constu, 256, DW_OP_or, DW_OP_stack_value)), !dbg !18
14 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_constu, 256, DW_OP_or, DW_OP_stack_value))
1515 %1 = or i64 %A, 256
1616 ret void
1717 }
1818
1919 define void @test_xor(i32 %A) {
2020 ; CHECK-LABEL: @test_xor(
21 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 %A, metadata !22, metadata !DIExpression(DW_OP_constu, 1, DW_OP_xor, DW_OP_stack_value)), !dbg !23
21 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 %A, {{.*}}, metadata !DIExpression(DW_OP_constu, 1, DW_OP_xor, DW_OP_stack_value))
2222 %1 = xor i32 %A, 1
2323 ret void
2424 }
2525
2626 define void @test_sub_neg(i64 %A) {
2727 ; CHECK-LABEL: @test_sub_neg(
28 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, metadata !27, metadata !DIExpression(DW_OP_plus_uconst, 1, DW_OP_stack_value)), !dbg !28
28 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_plus_uconst, 1, DW_OP_stack_value))
2929 %1 = sub i64 %A, -1
3030 ret void
3131 }
3232
3333 define void @test_sub_pos(i64 %A) {
3434 ; CHECK-LABEL: @test_sub_pos(
35 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, metadata !32, metadata !DIExpression(DW_OP_constu, 1, DW_OP_minus, DW_OP_stack_value)), !dbg !33
35 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_constu, 1, DW_OP_minus, DW_OP_stack_value))
3636 %1 = sub i64 %A, 1
3737 ret void
3838 }
3939
4040 define void @test_shl(i64 %A) {
4141 ; CHECK-LABEL: @test_shl(
42 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, metadata !37, metadata !DIExpression(DW_OP_constu, 7, DW_OP_shl, DW_OP_stack_value)), !dbg !38
42 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_constu, 7, DW_OP_shl, DW_OP_stack_value))
4343 %1 = shl i64 %A, 7
4444 ret void
4545 }
4646
4747 define void @test_lshr(i64 %A) {
4848 ; CHECK-LABEL: @test_lshr(
49 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, metadata !42, metadata !DIExpression(DW_OP_constu, 7, DW_OP_shr, DW_OP_stack_value)), !dbg !43
49 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_constu, 7, DW_OP_shr, DW_OP_stack_value))
5050 %1 = lshr i64 %A, 7
5151 ret void
5252 }
5353
5454 define void @test_ashr(i64 %A) {
5555 ; CHECK-LABEL: @test_ashr(
56 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, metadata !47, metadata !DIExpression(DW_OP_constu, 7, DW_OP_shra, DW_OP_stack_value)), !dbg !48
56 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_constu, 7, DW_OP_shra, DW_OP_stack_value))
5757 %1 = ashr i64 %A, 7
5858 ret void
5959 }
6060
6161 define void @test_mul(i64 %A) {
6262 ; CHECK-LABEL: @test_mul(
63 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, metadata !52, metadata !DIExpression(DW_OP_constu, 7, DW_OP_mul, DW_OP_stack_value)), !dbg !53
63 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_constu, 7, DW_OP_mul, DW_OP_stack_value))
6464 %1 = mul i64 %A, 7
6565 ret void
6666 }
6767
6868 define void @test_sdiv(i64 %A) {
6969 ; CHECK-LABEL: @test_sdiv(
70 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, metadata !57, metadata !DIExpression(DW_OP_constu, 7, DW_OP_div, DW_OP_stack_value)), !dbg !58
70 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_constu, 7, DW_OP_div, DW_OP_stack_value))
7171 %1 = sdiv i64 %A, 7
7272 ret void
7373 }
7474
7575 define void @test_srem(i64 %A) {
7676 ; CHECK-LABEL: @test_srem(
77 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, metadata !62, metadata !DIExpression(DW_OP_constu, 7, DW_OP_mod, DW_OP_stack_value)), !dbg !63
77 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_constu, 7, DW_OP_mod, DW_OP_stack_value))
7878 %1 = srem i64 %A, 7
7979 ret void
8080 }
8181
8282 define void @test_ptrtoint(i64* %P) {
8383 ; CHECK-LABEL: @test_ptrtoint
84 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i64* %P, metadata !67, metadata !DIExpression()), !dbg !68
84 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i64* %P, {{.*}}, metadata !DIExpression())
8585 %1 = ptrtoint i64* %P to i64
8686 ret void
8787 }
8888
8989 define void @test_and(i64 %A) {
9090 ; CHECK-LABEL: @test_and(
91 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, metadata !72, metadata !DIExpression(DW_OP_constu, 256, DW_OP_and, DW_OP_stack_value)), !dbg !73
91 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_constu, 256, DW_OP_and, DW_OP_stack_value))
9292 %1 = and i64 %A, 256
9393 ret void
9494 }
1818 br i1 %S2, label %loop.exit, label %loop.interior
1919 loop.exit: ; preds = %post.if
2020 ; CHECK: %X3.lcssa = phi i32
21 ; CHECK2: call void @llvm.dbg.value(metadata i32 %X3.lcssa, metadata !11, metadata !DIExpression()), !dbg !19
21 ; CHECK2: call void @llvm.dbg.value(metadata i32 %X3.lcssa
2222 ; CHECK: %X4 = add i32 3, %X3.lcssa
2323 %X4 = add i32 3, %X3 ; [#uses=0]
2424 ret void
120120 addDebugifyOperand(NextVar - 1); // Original number of variables.
121121 assert(NMD->getNumOperands() == 2 &&
122122 "llvm.debugify should have exactly 2 operands!");
123
124 // Claim that this synthetic debug info is valid.
125 StringRef DIVersionKey = "Debug Info Version";
126 if (!M.getModuleFlag(DIVersionKey))
127 M.addModuleFlag(Module::Warning, DIVersionKey, DEBUG_METADATA_VERSION);
128
123129 return true;
124130 }
125131
269275 Module &M = *F.getParent();
270276 auto FuncIt = F.getIterator();
271277 return checkDebugifyMetadata(M, make_range(FuncIt, std::next(FuncIt)),
272 NameOfWrappedPass, "CheckFunctionDebugify", Strip);
273 }
274
275 CheckDebugifyFunctionPass(bool Strip = false, StringRef NameOfWrappedPass = "")
278 NameOfWrappedPass, "CheckFunctionDebugify",
279 Strip);
280 }
281
282 CheckDebugifyFunctionPass(bool Strip = false,
283 StringRef NameOfWrappedPass = "")
276284 : FunctionPass(ID), Strip(Strip), NameOfWrappedPass(NameOfWrappedPass) {}
277285
278286 void getAnalysisUsage(AnalysisUsage &AU) const override {