From: Tobias Grosser Date: Tue, 29 Jul 2014 06:10:47 +0000 (+0000) Subject: Emit column debug information for loads X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=944dbbe78b4fcea4d26a9496f333d31be3f09f55;p=clang Emit column debug information for loads This allows us to give more precise diagnostics. Diego kindly tested the impact on debug info size: "The increase on average debug sizes is 0.1%. The total file size increase is ~0%." git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214162 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 512b323ba1..d3a01abf72 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -1258,6 +1258,9 @@ void CodeGenFunction::EmitStoreOfScalar(llvm::Value *value, LValue lvalue, /// method emits the address of the lvalue, then loads the result as an rvalue, /// returning the rvalue. RValue CodeGenFunction::EmitLoadOfLValue(LValue LV, SourceLocation Loc) { + if (CGDebugInfo *DI = getDebugInfo()) + DI->EmitLocation(Builder, Loc, true); + if (LV.isObjCWeak()) { // load of a __weak object. llvm::Value *AddrWeakObj = LV.getAddress(); diff --git a/test/CodeGen/debug-info-column.c b/test/CodeGen/debug-info-column.c new file mode 100644 index 0000000000..2a635ac8b2 --- /dev/null +++ b/test/CodeGen/debug-info-column.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -emit-llvm -o - -g %s | FileCheck %s +void foo(float A[100], float B[100]) { + B[12] = A[10] + A[20] + A[30]; +} +// CHECK-LABEL: foo +// CHECK: load float* %arrayidx{{.*}}, !dbg [[LOC0:.*]] +// CHECK: load float* %arrayidx{{.*}}, !dbg [[LOC1:.*]] +// CHECK: load float* %arrayidx{{.*}}, !dbg [[LOC2:.*]] +// CHECK: store float {{.*}} float* %arrayidx{{.*}}, !dbg [[LOC3:.*]] +// CHECK-DAG: [[LOC0]] = metadata !{i32 3, i32 11, metadata {{.*}}, null} +// CHECK-DAG: [[LOC1]] = metadata !{i32 3, i32 19, metadata {{.*}}, null} +// CHECK-DAG: [[LOC2]] = metadata !{i32 3, i32 27, metadata {{.*}}, null} +// CHECK-DAG: [[LOC3]] = metadata !{i32 3, i32 3, metadata {{.*}}, null} diff --git a/test/CodeGen/linetable-endscope.c b/test/CodeGen/linetable-endscope.c index 236f605d7e..b39df78581 100644 --- a/test/CodeGen/linetable-endscope.c +++ b/test/CodeGen/linetable-endscope.c @@ -11,7 +11,7 @@ void foo(char c) { int i; - // CHECK: ![[CONV]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null} + // CHECK: ![[CONV]] = metadata !{i32 [[@LINE+1]], i32 7, metadata !{{.*}}, null} i = c; // CHECK: ![[RET]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null} } diff --git a/test/CodeGenCXX/PR20038.cpp b/test/CodeGenCXX/PR20038.cpp index c24685d696..f72219f7a7 100644 --- a/test/CodeGenCXX/PR20038.cpp +++ b/test/CodeGenCXX/PR20038.cpp @@ -11,6 +11,6 @@ extern bool b; // CHECK: [[DTOR_CALL1_LOC]] = metadata !{i32 [[@LINE+2]], i32 0, metadata [[FUN1_BLOCK:.*]], null} // CHECK: [[FUN1_BLOCK]] = metadata !{{{[^,]*}}, {{[^,]*}}, metadata [[FUN1]], void fun1() { b && (C(), 1); } -// CHECK: [[DTOR_CALL2_LOC]] = metadata !{i32 [[@LINE+2]], i32 0, metadata [[FUN2_BLOCK1:.*]], null} +// CHECK: [[DTOR_CALL2_LOC]] = metadata !{i32 [[@LINE+2]], i32 28, metadata [[FUN2_BLOCK1:.*]], null} // CHECK: [[FUN2_BLOCK1]] = metadata !{{{[^,]*}}, {{[^,]*}}, metadata [[FUN2]], bool fun2() { return (C(), b) && 0; } diff --git a/test/CodeGenObjC/arc-linetable.m b/test/CodeGenObjC/arc-linetable.m index 2d56ab3dfb..9d6c5b39a8 100644 --- a/test/CodeGenObjC/arc-linetable.m +++ b/test/CodeGenObjC/arc-linetable.m @@ -76,7 +76,7 @@ typedef signed char BOOL; - (int)testMultiline:(NSString *)foo { // CHECK: ![[MSG4]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null} int r = [self testSideEffect :foo]; - // CHECK: ![[EXP4]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null} + // CHECK: ![[EXP4]] = metadata !{i32 [[@LINE+1]], i32 10, metadata !{{.*}}, null} return r; // CHECK: ![[RET4]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null} } @@ -94,7 +94,7 @@ typedef signed char BOOL; } - (int)testNoCleanupSideEffect { - // CHECK: ![[MSG7]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null} + // CHECK: ![[MSG7]] = metadata !{i32 [[@LINE+1]], i32 4, metadata !{{.*}}, null} [self testVoid :@"foo"]; // CHECK: ![[RET7]] = metadata !{i32 [[@LINE+1]], i32 0, metadata !{{.*}}, null} return 1; @@ -102,7 +102,7 @@ typedef signed char BOOL; - (void)testCleanupVoid:(BOOL)skip withDelegate: (AppDelegate *) delegate { static BOOL skip_all; - // CHECK: ![[SKIP1]] = metadata !{i32 [[@LINE+1]], i32 0, + // CHECK: ![[SKIP1]] = metadata !{i32 [[@LINE+1]], i32 8, if (!skip_all) { if (!skip) { return;