If dbg.declare from non-entry block is using alloca from entry block then use offset...
authorDevang Patel <dpatel@apple.com>
Wed, 15 Sep 2010 14:48:53 +0000 (14:48 +0000)
committerDevang Patel <dpatel@apple.com>
Wed, 15 Sep 2010 14:48:53 +0000 (14:48 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@113967 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

index 1e77a66a0665d9865a65a2c440c6026b704d69ad..db3ca11173816f9d142cfe165001cba8a73673a9 100644 (file)
@@ -4117,9 +4117,21 @@ SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I, unsigned Intrinsic) {
       DAG.AddDbgValue(SDV, N.getNode(), isParameter);
     } else {
       // If Address is an arugment then try to emits its dbg value using
-      // virtual register info from the FuncInfo.ValueMap. Otherwise add undef
-      // to help track missing debug info.
+      // virtual register info from the FuncInfo.ValueMap. 
       if (!EmitFuncArgumentDbgValue(Address, Variable, 0, N)) {
+        // If variable is pinned by a alloca in dominating bb then
+        // use StaticAllocaMap.
+        if (const AllocaInst *AI = dyn_cast<AllocaInst>(Address)) {
+          DenseMap<const AllocaInst*, int>::iterator SI =
+            FuncInfo.StaticAllocaMap.find(AI);
+          if (SI != FuncInfo.StaticAllocaMap.end()) {
+            SDV = DAG.getDbgValue(Variable, SI->second,
+                                  0, dl, SDNodeOrder);
+            DAG.AddDbgValue(SDV, 0, false);
+            return 0;
+          }
+        }
+        // Otherwise add undef to help track missing debug info.
         SDV = DAG.getDbgValue(Variable, UndefValue::get(Address->getType()),
                               0, dl, SDNodeOrder);
         DAG.AddDbgValue(SDV, 0, false);