Generalize llvm::replaceDbgDeclare and actually support the use-case that

is mentioned in the documentation (inserting a deref before the plus_uconst).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@320203 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Adrian Prantl
2017-12-08 21:58:18 +00:00
parent 2cac108e97
commit 0375b23748
11 changed files with 56 additions and 27 deletions
+5 -3
View File
@@ -558,7 +558,7 @@ Value *SafeStack::moveStaticAllocasToUnsafeStack(
// Replace alloc with the new location.
replaceDbgDeclare(Arg, BasePointer, BasePointer->getNextNode(), DIB,
/*Deref=*/false, -Offset);
DIExpression::NoDeref, -Offset, DIExpression::NoDeref);
Arg->replaceAllUsesWith(NewArg);
IRB.SetInsertPoint(cast<Instruction>(NewArg)->getNextNode());
IRB.CreateMemCpy(Off, Arg, Size, Arg->getParamAlignment());
@@ -573,7 +573,8 @@ Value *SafeStack::moveStaticAllocasToUnsafeStack(
if (Size == 0)
Size = 1; // Don't create zero-sized stack objects.
replaceDbgDeclareForAlloca(AI, BasePointer, DIB, /*Deref=*/false, -Offset);
replaceDbgDeclareForAlloca(AI, BasePointer, DIB, DIExpression::NoDeref,
-Offset, DIExpression::NoDeref);
replaceDbgValueForAlloca(AI, BasePointer, DIB, -Offset);
// Replace uses of the alloca with the new location.
@@ -663,7 +664,8 @@ void SafeStack::moveDynamicAllocasToUnsafeStack(
if (AI->hasName() && isa<Instruction>(NewAI))
NewAI->takeName(AI);
replaceDbgDeclareForAlloca(AI, NewAI, DIB, /*Deref=*/false);
replaceDbgDeclareForAlloca(AI, NewAI, DIB, DIExpression::NoDeref, 0,
DIExpression::NoDeref);
AI->replaceAllUsesWith(NewAI);
AI->eraseFromParent();
}