]> granicus.if.org Git - llvm/commitdiff
[DebugInfo] Add comments to phi dbg.value tracking code, NFC
authorReid Kleckner <rnk@google.com>
Tue, 27 Sep 2016 18:45:31 +0000 (18:45 +0000)
committerReid Kleckner <rnk@google.com>
Tue, 27 Sep 2016 18:45:31 +0000 (18:45 +0000)
LLVM developers might be surprised to learn that there are blocks
without valid insertion points (catchswitch), so it seems worth calling
that out explicitly.  Also add a FIXME about what we should really be
doing if we ever need to make optimized Windows EH code debuggable.

While I'm here, make auto usage more consistent with LLVM standards and
avoid an unecessary call to insertBefore.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282521 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Utils/Local.cpp

index 9b28f837d706c65459d485818960216d337219ab..5c46111822b56faa4cd28bd28614e1dd37a876ff 100644 (file)
@@ -1147,13 +1147,15 @@ void llvm::ConvertDebugDeclareToDebugValue(DbgDeclareInst *DDI,
   if (PhiHasDebugValue(DIVar, DIExpr, APN))
     return;
 
-  auto BB = APN->getParent();
+  BasicBlock *BB = APN->getParent();
   auto InsertionPt = BB->getFirstInsertionPt();
-  if (InsertionPt != BB->end()) {
-    Instruction *DbgValue = Builder.insertDbgValueIntrinsic(
-        APN, 0, DIVar, DIExpr, DDI->getDebugLoc(), (Instruction *)nullptr);
-    DbgValue->insertBefore(&*InsertionPt);
-  }
+
+  // The block may be a catchswitch block, which does not have a valid
+  // insertion point.
+  // FIXME: Insert dbg.value markers in the successors when appropriate.
+  if (InsertionPt != BB->end())
+    Builder.insertDbgValueIntrinsic(APN, 0, DIVar, DIExpr, DDI->getDebugLoc(),
+                                    &*InsertionPt);
 }
 
 /// Determine whether this alloca is either a VLA or an array.