Skip to content

Commit 24924a8

Browse files
committed
[SimplifyCFG] Move token type check into canReplaceOperandWithVariable()
We cannot form phis/selects of token type, so this should be checked inside canReplaceOperandWithVariable().
1 parent a01933d commit 24924a8

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

llvm/lib/Transforms/Utils/Local.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3838,8 +3838,8 @@ void llvm::maybeMarkSanitizerLibraryCallNoBuiltin(
38383838

38393839
bool llvm::canReplaceOperandWithVariable(const Instruction *I, unsigned OpIdx) {
38403840
const auto *Op = I->getOperand(OpIdx);
3841-
// We can't have a PHI with a metadata type.
3842-
if (Op->getType()->isMetadataTy())
3841+
// We can't have a PHI with a metadata or token type.
3842+
if (Op->getType()->isMetadataTy() || Op->getType()->isTokenTy())
38433843
return false;
38443844

38453845
// swifterror pointers can only be used by a load, store, or as a swifterror

llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2260,10 +2260,6 @@ static bool canSinkInstructions(
22602260

22612261
for (unsigned OI = 0, OE = I0->getNumOperands(); OI != OE; ++OI) {
22622262
Value *Op = I0->getOperand(OI);
2263-
if (Op->getType()->isTokenTy())
2264-
// Don't touch any operand of token type.
2265-
return false;
2266-
22672263
auto SameAsI0 = [&I0, OI](const Instruction *I) {
22682264
assert(I->getNumOperands() == I0->getNumOperands());
22692265
return I->getOperand(OI) == I0->getOperand(OI);
@@ -2764,8 +2760,7 @@ bool CompatibleSets::shouldBelongToSameSet(ArrayRef<InvokeInst *> Invokes) {
27642760
Use &U1 = std::get<1>(Ops);
27652761
if (U0 == U1)
27662762
return false;
2767-
return U0->getType()->isTokenTy() ||
2768-
!canReplaceOperandWithVariable(cast<Instruction>(U0.getUser()),
2763+
return !canReplaceOperandWithVariable(cast<Instruction>(U0.getUser()),
27692764
U0.getOperandNo());
27702765
};
27712766
assert(Invokes.size() == 2 && "Always called with exactly two candidates.");

0 commit comments

Comments
 (0)