Skip to content

Commit

Permalink
[llvm] Fix for failing test from fdbd84c
Browse files Browse the repository at this point in the history
When handling a DSOLocalEquivalent operand change:

- Remove assertion checking that the `To` type and current type are the
  same type. This is not always a requirement.
- Add a missing bitcast from an old DSOLocalEquivalent to the type of
  the new one.
  • Loading branch information
PiJoules committed Dec 1, 2020
1 parent 6c3fa97 commit 19bdc8e
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions llvm/lib/IR/Constants.cpp
Expand Up @@ -1851,15 +1851,14 @@ void DSOLocalEquivalent::destroyConstantImpl() {

Value *DSOLocalEquivalent::handleOperandChangeImpl(Value *From, Value *To) {
assert(From == getGlobalValue() && "Changing value does not match operand.");
assert(To->getType() == getType() && "Mismatched types");
assert(isa<Constant>(To) && "Can only replace the operands with a constant");

// The replacement is with another global value.
if (const auto *ToObj = dyn_cast<GlobalValue>(To)) {
DSOLocalEquivalent *&NewEquiv =
getContext().pImpl->DSOLocalEquivalents[ToObj];
if (NewEquiv)
return NewEquiv;
return llvm::ConstantExpr::getBitCast(NewEquiv, getType());
}

// If the argument is replaced with a null value, just replace this constant
Expand Down

0 comments on commit 19bdc8e

Please sign in to comment.