r223872 - DebugInfo: Correct the location of array accesses

David Blaikie dblaikie at gmail.com
Tue Dec 9 17:03:48 PST 2014


Author: dblaikie
Date: Tue Dec  9 19:03:48 2014
New Revision: 223872

URL: http://llvm.org/viewvc/llvm-project?rev=223872&view=rev
Log:
DebugInfo: Correct the location of array accesses

Especially relevant to ASan when dealing with complex expressions
containing multiple array accesses. See PR21737.

Modified:
    cfe/trunk/lib/CodeGen/CGExpr.cpp
    cfe/trunk/test/CodeGenCXX/debug-info-line.cpp

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=223872&r1=223871&r2=223872&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Tue Dec  9 19:03:48 2014
@@ -2459,6 +2459,8 @@ LValue CodeGenFunction::EmitArraySubscri
   } else {
     // The base must be a pointer, which is not an aggregate.  Emit it.
     llvm::Value *Base = EmitScalarExpr(E->getBase());
+    if (auto *DI = getDebugInfo())
+      DI->EmitLocation(Builder, E->getLocStart());
     if (getLangOpts().isSignedOverflowDefined())
       Address = Builder.CreateGEP(Base, Idx, "arrayidx");
     else

Modified: cfe/trunk/test/CodeGenCXX/debug-info-line.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-line.cpp?rev=223872&r1=223871&r2=223872&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/debug-info-line.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-line.cpp Tue Dec  9 19:03:48 2014
@@ -72,6 +72,15 @@ void f6() {
       = agg_src();
 }
 
+// CHECK-LABEL: define
+void f7() {
+  int *src1();
+  int src2();
+#line 800
+  int x = ( // CHECK: load {{.*}} !dbg [[DBG_F7:!.*]]
+      src1())[src2()];
+}
+
 // CHECK: [[DBG_F1]] = metadata !{i32 100,
 // CHECK: [[DBG_FOO_VALUE]] = metadata !{i32 200,
 // CHECK: [[DBG_FOO_REF]] = metadata !{i32 202,
@@ -81,3 +90,4 @@ void f6() {
 // CHECK: [[DBG_F4]] = metadata !{i32 500,
 // CHECK: [[DBG_F5]] = metadata !{i32 600,
 // CHECK: [[DBG_F6]] = metadata !{i32 700,
+// CHECK: [[DBG_F7]] = metadata !{i32 800,





More information about the cfe-commits mailing list