aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/Function.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/IR/Function.cpp')
-rw-r--r--llvm/lib/IR/Function.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp
index b1b8404..658aa67 100644
--- a/llvm/lib/IR/Function.cpp
+++ b/llvm/lib/IR/Function.cpp
@@ -518,15 +518,7 @@ void Function::stealArgumentListFrom(Function &Src) {
Src.setValueSubclassData(Src.getSubclassDataFromValue() | (1 << 0));
}
-// dropAllReferences() - This function causes all the subinstructions to "let
-// go" of all references that they are maintaining. This allows one to
-// 'delete' a whole class at a time, even though there may be circular
-// references... first all references are dropped, and all use counts go to
-// zero. Then everything is deleted for real. Note that no operations are
-// valid on an object that has "dropped all references", except operator
-// delete.
-//
-void Function::dropAllReferences() {
+void Function::deleteBodyImpl(bool ShouldDrop) {
setIsMaterializable(false);
for (BasicBlock &BB : *this)
@@ -537,10 +529,18 @@ void Function::dropAllReferences() {
while (!BasicBlocks.empty())
BasicBlocks.begin()->eraseFromParent();
- // Drop uses of any optional data (real or placeholder).
if (getNumOperands()) {
- User::dropAllReferences();
- setNumHungOffUseOperands(0);
+ if (ShouldDrop) {
+ // Drop uses of any optional data (real or placeholder).
+ User::dropAllReferences();
+ setNumHungOffUseOperands(0);
+ } else {
+ // The code needs to match Function::allocHungoffUselist().
+ auto *CPN = ConstantPointerNull::get(PointerType::get(getContext(), 0));
+ Op<0>().set(CPN);
+ Op<1>().set(CPN);
+ Op<2>().set(CPN);
+ }
setValueSubclassData(getSubclassDataFromValue() & ~0xe);
}