llvm.org GIT mirror llvm / 1b346b7
Enable code to emit dbg.declare as DEBUG_VALUE comments (fast isel, X86). This doesn't seem to break any functionality, but will introduce cases where -g affects the generated code. I'll be fixing that. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93811 91177308-0d34-0410-b5e6-96231b3b80d8 Dale Johannesen 9 years ago
3 changed file(s) with 68 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
342342 if (MDNode *Dbg = DI->getMetadata("dbg"))
343343 MMI->setVariableDbgInfo(DI->getVariable(), FI, Dbg);
344344 }
345 // Building the map above is target independent. Generating DEBUG_VALUE
346 // inline is target dependent; do this now.
347 (void)TargetSelectInstruction(cast(I));
345348 return true;
346349 }
347350 case Intrinsic::eh_exception: {
11521152 // FIXME: Handle more intrinsics.
11531153 switch (I.getIntrinsicID()) {
11541154 default: return false;
1155 case Intrinsic::dbg_declare: {
1156 DbgDeclareInst *DI = cast(&I);
1157 X86AddressMode AM;
1158 if (!X86SelectAddress(DI->getAddress(), AM))
1159 return false;
1160 const TargetInstrDesc &II = TII.get(TargetInstrInfo::DEBUG_VALUE);
1161 addFullAddress(BuildMI(MBB, DL, II), AM).addImm(0).
1162 addMetadata(DI->getVariable());
1163 return true;
1164 }
11551165 case Intrinsic::trap: {
11561166 BuildMI(MBB, DL, TII.get(X86::TRAP));
11571167 return true;
0 ; RUN: llc -O0 < %s | FileCheck %s
1 ; ModuleID = 'try.c'
2 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32"
3 target triple = "i386-apple-darwin9.8"
4 ; Currently, dbg.declare generates a DEBUG_VALUE comment. Eventually it will
5 ; generate DWARF and this test will need to be modified or removed.
6
7 @Y = common global i32 0 ; [#uses=1]
8
9 define i32 @test() nounwind {
10 entry:
11 ; CHECK: DEBUG_VALUE:
12 %retval = alloca i32 ; [#uses=2]
13 %X = alloca i32 ; [#uses=5]
14 %0 = alloca i32 ; [#uses=2]
15 %"alloca point" = bitcast i32 0 to i32 ; [#uses=0]
16 call void @llvm.dbg.declare(metadata !{i32* %X}, metadata !3), !dbg !7
17 store i32 4, i32* %X, align 4, !dbg !8
18 %1 = load i32* %X, align 4, !dbg !9 ; [#uses=1]
19 call void @use(i32 %1) nounwind, !dbg !9
20 %2 = load i32* @Y, align 4, !dbg !10 ; [#uses=1]
21 %3 = add nsw i32 %2, 2, !dbg !10 ; [#uses=1]
22 store i32 %3, i32* %X, align 4, !dbg !10
23 %4 = load i32* %X, align 4, !dbg !11 ; [#uses=1]
24 call void @use(i32 %4) nounwind, !dbg !11
25 %5 = load i32* %X, align 4, !dbg !12 ; [#uses=1]
26 store i32 %5, i32* %0, align 4, !dbg !12
27 %6 = load i32* %0, align 4, !dbg !12 ; [#uses=1]
28 store i32 %6, i32* %retval, align 4, !dbg !12
29 br label %return, !dbg !12
30
31 return: ; preds = %entry
32 %retval1 = load i32* %retval, !dbg !12 ; [#uses=1]
33 ret i32 %retval1, !dbg !12
34 }
35
36 declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
37
38 declare void @use(i32)
39
40 !llvm.dbg.gv = !{!0}
41
42 !0 = metadata !{i32 458804, i32 0, metadata !1, metadata !"Y", metadata !"Y", metadata !"Y", metadata !1, i32 2, metadata !2, i1 false, i1 true, i32* @Y} ; [ DW_TAG_variable ]
43 !1 = metadata !{i32 458769, i32 0, i32 1, metadata !"try.c", metadata !"/Volumes/MacOS9/tests/", metadata !"4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ]
44 !2 = metadata !{i32 458788, metadata !1, metadata !"int", metadata !1, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ]
45 !3 = metadata !{i32 459008, metadata !4, metadata !"X", metadata !1, i32 4, metadata !2} ; [ DW_TAG_auto_variable ]
46 !4 = metadata !{i32 458798, i32 0, metadata !1, metadata !"", metadata !"", metadata !"test", metadata !1, i32 3, metadata !5, i1 false, i1 true, i32 0, i32 0, null} ; [ DW_TAG_subprogram ]
47 !5 = metadata !{i32 458773, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !6, i32 0} ; [ DW_TAG_subroutine_type ]
48 !6 = metadata !{metadata !2}
49 !7 = metadata !{i32 3, i32 0, metadata !4, null}
50 !8 = metadata !{i32 4, i32 0, metadata !4, null}
51 !9 = metadata !{i32 5, i32 0, metadata !4, null}
52 !10 = metadata !{i32 6, i32 0, metadata !4, null}
53 !11 = metadata !{i32 7, i32 0, metadata !4, null}
54 !12 = metadata !{i32 8, i32 0, metadata !4, null}