[Function] Properly remove use when clearing personality
Summary:
We need to actually remove the use of the personality function,
otherwise we can run into trouble if we want to e.g. delete
the personality function because ther's no way to get rid of
its uses. Do this by resetting to ConstantPointerNull value
that the operands are set to when first allocated.
Reviewers: vsk, dexonsmith
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15752
llvm-svn: 256345
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp
index f5974a6..cfb40b1 100644
--- a/llvm/lib/IR/Function.cpp
+++ b/llvm/lib/IR/Function.cpp
@@ -942,8 +942,7 @@
}
void Function::setPersonalityFn(Constant *Fn) {
- if (Fn)
- setHungoffOperand<0>(Fn);
+ setHungoffOperand<0>(Fn);
setValueSubclassDataBit(3, Fn != nullptr);
}
@@ -953,8 +952,7 @@
}
void Function::setPrefixData(Constant *PrefixData) {
- if (PrefixData)
- setHungoffOperand<1>(PrefixData);
+ setHungoffOperand<1>(PrefixData);
setValueSubclassDataBit(1, PrefixData != nullptr);
}
@@ -964,8 +962,7 @@
}
void Function::setPrologueData(Constant *PrologueData) {
- if (PrologueData)
- setHungoffOperand<2>(PrologueData);
+ setHungoffOperand<2>(PrologueData);
setValueSubclassDataBit(2, PrologueData != nullptr);
}
@@ -986,9 +983,13 @@
template <int Idx>
void Function::setHungoffOperand(Constant *C) {
- assert(C && "Cannot set hungoff operand to nullptr");
- allocHungoffUselist();
- Op<Idx>().set(C);
+ if (C) {
+ allocHungoffUselist();
+ Op<Idx>().set(C);
+ } else if (getNumOperands()) {
+ Op<Idx>().set(
+ ConstantPointerNull::get(Type::getInt1PtrTy(getContext(), 0)));
+ }
}
void Function::setValueSubclassDataBit(unsigned Bit, bool On) {