[llvm] 24924a8 - [SimplifyCFG] Move token type check into canReplaceOperandWithVariable()
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 28 06:53:47 PDT 2025
Author: Nikita Popov
Date: 2025-08-28T15:53:37+02:00
New Revision: 24924a8be1bb7c6083303330ecc0e7dc647247d3
URL: https://github.com/llvm/llvm-project/commit/24924a8be1bb7c6083303330ecc0e7dc647247d3
DIFF: https://github.com/llvm/llvm-project/commit/24924a8be1bb7c6083303330ecc0e7dc647247d3.diff
LOG: [SimplifyCFG] Move token type check into canReplaceOperandWithVariable()
We cannot form phis/selects of token type, so this should be checked
inside canReplaceOperandWithVariable().
Added:
Modified:
llvm/lib/Transforms/Utils/Local.cpp
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index ac344904f90f0..9d759bc244e3d 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -3838,8 +3838,8 @@ void llvm::maybeMarkSanitizerLibraryCallNoBuiltin(
bool llvm::canReplaceOperandWithVariable(const Instruction *I, unsigned OpIdx) {
const auto *Op = I->getOperand(OpIdx);
- // We can't have a PHI with a metadata type.
- if (Op->getType()->isMetadataTy())
+ // We can't have a PHI with a metadata or token type.
+ if (Op->getType()->isMetadataTy() || Op->getType()->isTokenTy())
return false;
// swifterror pointers can only be used by a load, store, or as a swifterror
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index ef110a6922f05..93ace4d50cbdc 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -2260,10 +2260,6 @@ static bool canSinkInstructions(
for (unsigned OI = 0, OE = I0->getNumOperands(); OI != OE; ++OI) {
Value *Op = I0->getOperand(OI);
- if (Op->getType()->isTokenTy())
- // Don't touch any operand of token type.
- return false;
-
auto SameAsI0 = [&I0, OI](const Instruction *I) {
assert(I->getNumOperands() == I0->getNumOperands());
return I->getOperand(OI) == I0->getOperand(OI);
@@ -2764,8 +2760,7 @@ bool CompatibleSets::shouldBelongToSameSet(ArrayRef<InvokeInst *> Invokes) {
Use &U1 = std::get<1>(Ops);
if (U0 == U1)
return false;
- return U0->getType()->isTokenTy() ||
- !canReplaceOperandWithVariable(cast<Instruction>(U0.getUser()),
+ return !canReplaceOperandWithVariable(cast<Instruction>(U0.getUser()),
U0.getOperandNo());
};
assert(Invokes.size() == 2 && "Always called with exactly two candidates.");
More information about the llvm-commits
mailing list