[llvm] r235400 - DebugInfo: Assert dbg.declare/value insts are valid

Duncan P. N. Exon Smith dexonsmith at apple.com
Tue Apr 21 11:24:23 PDT 2015


Author: dexonsmith
Date: Tue Apr 21 13:24:23 2015
New Revision: 235400

URL: http://llvm.org/viewvc/llvm-project?rev=235400&view=rev
Log:
DebugInfo: Assert dbg.declare/value insts are valid

Remove early returns for when `getVariable()` is null, and just assert
that it never happens.  The Verifier already confirms that there's a
valid variable on these intrinsics, so we should assume the debug info
isn't broken.  I also updated a check for a `!dbg` attachment, which the
Verifier similarly guarantees.

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
    llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
    llvm/trunk/lib/Transforms/Utils/Local.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp?rev=235400&r1=235399&r2=235400&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp Tue Apr 21 13:24:23 2015
@@ -1088,8 +1088,8 @@ bool FastISel::selectIntrinsicCall(const
   }
   case Intrinsic::dbg_declare: {
     const DbgDeclareInst *DI = cast<DbgDeclareInst>(II);
-    DIVariable DIVar = DI->getVariable();
-    if (!DIVar || !FuncInfo.MF->getMMI().hasDebugInfo()) {
+    assert(DI->getVariable() && "Missing variable");
+    if (!FuncInfo.MF->getMMI().hasDebugInfo()) {
       DEBUG(dbgs() << "Dropping debug info for " << *DI << "\n");
       return true;
     }

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp?rev=235400&r1=235399&r2=235400&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp Tue Apr 21 13:24:23 2015
@@ -202,8 +202,9 @@ void FunctionLoweringInfo::set(const Fun
       // during the initial isel pass through the IR so that it is done
       // in a predictable order.
       if (const DbgDeclareInst *DI = dyn_cast<DbgDeclareInst>(I)) {
-        DIVariable DIVar = DI->getVariable();
-        if (MMI.hasDebugInfo() && DIVar && DI->getDebugLoc()) {
+        assert(DI->getVariable() && "Missing variable");
+        assert(DI->getDebugLoc() && "Missing location");
+        if (MMI.hasDebugInfo()) {
           // Don't handle byval struct arguments or VLAs, for example.
           // Non-byval arguments are handled here (they refer to the stack
           // temporary alloca at this point).

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=235400&r1=235399&r2=235400&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Tue Apr 21 13:24:23 2015
@@ -4650,8 +4650,8 @@ SelectionDAGBuilder::visitIntrinsicCall(
     MDLocalVariable *Variable = DI.getVariable();
     MDExpression *Expression = DI.getExpression();
     const Value *Address = DI.getAddress();
-    DIVariable DIVar = Variable;
-    if (!Address || !DIVar) {
+    assert(Variable && "Missing variable");
+    if (!Address) {
       DEBUG(dbgs() << "Dropping debug info for " << DI << "\n");
       return nullptr;
     }
@@ -4728,9 +4728,7 @@ SelectionDAGBuilder::visitIntrinsicCall(
   }
   case Intrinsic::dbg_value: {
     const DbgValueInst &DI = cast<DbgValueInst>(I);
-    DIVariable DIVar = DI.getVariable();
-    if (!DIVar)
-      return nullptr;
+    assert(DI.getVariable() && "Missing variable");
 
     MDLocalVariable *Variable = DI.getVariable();
     MDExpression *Expression = DI.getExpression();

Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=235400&r1=235399&r2=235400&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/Local.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/Local.cpp Tue Apr 21 13:24:23 2015
@@ -1000,8 +1000,7 @@ bool llvm::ConvertDebugDeclareToDebugVal
                                            StoreInst *SI, DIBuilder &Builder) {
   DIVariable DIVar = DDI->getVariable();
   DIExpression DIExpr = DDI->getExpression();
-  if (!DIVar)
-    return false;
+  assert(DIVar && "Missing variable");
 
   if (LdStHasDebugValue(DIVar, SI))
     return true;
@@ -1028,8 +1027,7 @@ bool llvm::ConvertDebugDeclareToDebugVal
                                            LoadInst *LI, DIBuilder &Builder) {
   DIVariable DIVar = DDI->getVariable();
   DIExpression DIExpr = DDI->getExpression();
-  if (!DIVar)
-    return false;
+  assert(DIVar && "Missing variable");
 
   if (LdStHasDebugValue(DIVar, LI))
     return true;
@@ -1107,8 +1105,7 @@ bool llvm::replaceDbgDeclareForAlloca(Al
   DebugLoc Loc = DDI->getDebugLoc();
   DIVariable DIVar = DDI->getVariable();
   DIExpression DIExpr = DDI->getExpression();
-  if (!DIVar)
-    return false;
+  assert(DIVar && "Missing variable");
 
   if (Deref) {
     // Create a copy of the original DIDescriptor for user variable, prepending





More information about the llvm-commits mailing list