Add simplify_type<const WeakVH>; simplify IndVarSimplify

r240214 fixed some UB in IndVarSimplify, and it needed a temporary
`WeakVH` to do it.  Add `simplify_type<const WeakVH>` so that this
temporary isn't necessary.

llvm-svn: 240599
This commit is contained in:
Duncan P. N. Exon Smith 2015-06-24 22:23:21 +00:00
parent fcda6f8c6b
commit 817ac8f40a
2 changed files with 10 additions and 9 deletions

View File

@ -159,11 +159,13 @@ public:
// Specialize simplify_type to allow WeakVH to participate in
// dyn_cast, isa, etc.
template<> struct simplify_type<WeakVH> {
typedef Value* SimpleType;
static SimpleType getSimplifiedValue(WeakVH &WVH) {
return WVH;
}
template <> struct simplify_type<WeakVH> {
typedef Value *SimpleType;
static SimpleType getSimplifiedValue(WeakVH &WVH) { return WVH; }
};
template <> struct simplify_type<const WeakVH> {
typedef Value *SimpleType;
static SimpleType getSimplifiedValue(const WeakVH &WVH) { return WVH; }
};
/// \brief Value handle that asserts if the Value is deleted.

View File

@ -2013,11 +2013,10 @@ bool IndVarSimplify::runOnLoop(Loop *L, LPPassManager &LPM) {
// Now that we're done iterating through lists, clean up any instructions
// which are now dead.
while (!DeadInsts.empty()) {
Value *V = static_cast<Value *>(DeadInsts.pop_back_val());
if (Instruction *Inst = dyn_cast_or_null<Instruction>(V))
while (!DeadInsts.empty())
if (Instruction *Inst =
dyn_cast_or_null<Instruction>(DeadInsts.pop_back_val()))
RecursivelyDeleteTriviallyDeadInstructions(Inst, TLI);
}
// The Rewriter may not be used from this point on.