2
0
Эх сурвалжийг харах

Fix SROA leaving some llvm.dbg.declare(undef) behind.

Tristan Labelle 6 жил өмнө
parent
commit
31e0d477eb

+ 11 - 6
lib/Transforms/Scalar/SROA.cpp

@@ -4446,6 +4446,17 @@ void SROA::deleteDeadInstructions(
     Instruction *I = DeadInsts.pop_back_val();
     Instruction *I = DeadInsts.pop_back_val();
     DEBUG(dbgs() << "Deleting dead instruction: " << *I << "\n");
     DEBUG(dbgs() << "Deleting dead instruction: " << *I << "\n");
 
 
+    // HLSL Change Begins
+    // If the instruction is an alloca, find the possible dbg.declare connected
+    // to it, and remove it too. We must do this before calling RAUW or we will
+    // not be able to find it.
+    if (AllocaInst *AI = dyn_cast<AllocaInst>(I)) {
+      DeletedAllocas.insert(AI);
+      if (DbgDeclareInst *DbgDecl = FindAllocaDbgDeclare(AI))
+        DbgDecl->eraseFromParent();
+    }
+    // HLSL Change Ends
+
     I->replaceAllUsesWith(UndefValue::get(I->getType()));
     I->replaceAllUsesWith(UndefValue::get(I->getType()));
 
 
     for (Use &Operand : I->operands())
     for (Use &Operand : I->operands())
@@ -4456,12 +4467,6 @@ void SROA::deleteDeadInstructions(
           DeadInsts.insert(U);
           DeadInsts.insert(U);
       }
       }
 
 
-    if (AllocaInst *AI = dyn_cast<AllocaInst>(I)) {
-      DeletedAllocas.insert(AI);
-      if (DbgDeclareInst *DbgDecl = FindAllocaDbgDeclare(AI))
-        DbgDecl->eraseFromParent();
-    }
-
     ++NumDeleted;
     ++NumDeleted;
     I->eraseFromParent();
     I->eraseFromParent();
   }
   }