From: Reid Kleckner Date: Tue, 27 Sep 2016 18:45:31 +0000 (+0000) Subject: [DebugInfo] Add comments to phi dbg.value tracking code, NFC X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a02ae2b916538279201e6aa19acf0c8b85617a38;p=llvm [DebugInfo] Add comments to phi dbg.value tracking code, NFC 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 --- diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp index 9b28f837d70..5c46111822b 100644 --- a/lib/Transforms/Utils/Local.cpp +++ b/lib/Transforms/Utils/Local.cpp @@ -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.