[llvm-commits] [llvm] r93757 - in /llvm/trunk: lib/Transforms/Utils/ValueMapper.cpp test/FrontendC/2010-01-18-Inlined-Debug.c

Devang Patel dpatel at apple.com
Mon Jan 18 11:52:14 PST 2010


Author: dpatel
Date: Mon Jan 18 13:52:14 2010
New Revision: 93757

URL: http://llvm.org/viewvc/llvm-project?rev=93757&view=rev
Log:
While mapping llvm.dbg.declare intrinsic manually map its operand, if possible,
because it points to an alloca instruction through metadata.


Added:
    llvm/trunk/test/FrontendC/2010-01-18-Inlined-Debug.c
Modified:
    llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp

Modified: llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp?rev=93757&r1=93756&r2=93757&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/ValueMapper.cpp Mon Jan 18 13:52:14 2010
@@ -16,6 +16,7 @@
 #include "llvm/DerivedTypes.h"  // For getNullValue(Type::Int32Ty)
 #include "llvm/Constants.h"
 #include "llvm/Function.h"
+#include "llvm/IntrinsicInst.h"
 #include "llvm/Metadata.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/ErrorHandling.h"
@@ -130,4 +131,21 @@
     assert(V && "Referenced value not in value map!");
     *op = V;
   }
+
+  // Map llvm.dbg.declare instruction's first operand, which points to
+  // alloca instruction through MDNode. Since MDNodes are not counted as normal
+  // uses, this will fall through cracks otherwise.
+  const DbgDeclareInst *DDI = dyn_cast<DbgDeclareInst>(I);
+  if (!DDI) return;
+  
+  Value *AddrInsn = DDI->getAddress();
+  if (!AddrInsn) return;
+  
+  ValueMapTy::iterator VMI = ValueMap.find(AddrInsn);
+  if (VMI == ValueMap.end()) return;
+  
+  Value *Elts[] =  { VMI->second };
+  MDNode *NewAddr = MDNode::get(AddrInsn->getContext(), Elts, 1);
+  I->setOperand(1, NewAddr);
 }
+

Added: llvm/trunk/test/FrontendC/2010-01-18-Inlined-Debug.c
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2010-01-18-Inlined-Debug.c?rev=93757&view=auto

==============================================================================
--- llvm/trunk/test/FrontendC/2010-01-18-Inlined-Debug.c (added)
+++ llvm/trunk/test/FrontendC/2010-01-18-Inlined-Debug.c Mon Jan 18 13:52:14 2010
@@ -0,0 +1,12 @@
+// PR: 6058
+// RUN: %llvmgcc -g -S %s -o - | llc -O0 -o /dev/null
+
+static inline int foo(double) __attribute__ ((always_inline));
+static inline int foo(double __x) { return __x; }
+
+void bar(double x) {
+  foo(x);
+}
+
+
+





More information about the llvm-commits mailing list