Skip to content

Commit a300b24

Browse files
Revert "[TLI] Fix replace-with-veclib crash with invalid arguments (#77112)"
This reverts commit 9fdc568, as it linker crashes on some platforms.
1 parent e4d01bb commit a300b24

File tree

3 files changed

+1
-143
lines changed

3 files changed

+1
-143
lines changed

llvm/lib/CodeGen/ReplaceWithVeclib.cpp

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ static bool replaceWithCallToVeclib(const TargetLibraryInfo &TLI,
111111
SmallVector<Type *, 8> ScalarArgTypes;
112112
std::string ScalarName;
113113
Function *FuncToReplace = nullptr;
114-
auto *CI = dyn_cast<CallInst>(&I);
115-
if (CI) {
114+
if (auto *CI = dyn_cast<CallInst>(&I)) {
116115
FuncToReplace = CI->getCalledFunction();
117116
Intrinsic::ID IID = FuncToReplace->getIntrinsicID();
118117
assert(IID != Intrinsic::not_intrinsic && "Not an intrinsic");
@@ -169,36 +168,12 @@ static bool replaceWithCallToVeclib(const TargetLibraryInfo &TLI,
169168
if (!OptInfo)
170169
return false;
171170

172-
// There is no guarantee that the vectorized instructions followed the VFABI
173-
// specification when being created, this is why we need to add extra check to
174-
// make sure that the operands of the vector function obtained via VFABI match
175-
// the operands of the original vector instruction.
176-
if (CI) {
177-
for (auto VFParam : OptInfo->Shape.Parameters) {
178-
if (VFParam.ParamKind == VFParamKind::GlobalPredicate)
179-
continue;
180-
181-
// tryDemangleForVFABI must return valid ParamPos, otherwise it could be
182-
// a bug in the VFABI parser.
183-
assert(VFParam.ParamPos < CI->arg_size() &&
184-
"ParamPos has invalid range.");
185-
Type *OrigTy = CI->getArgOperand(VFParam.ParamPos)->getType();
186-
if (OrigTy->isVectorTy() != (VFParam.ParamKind == VFParamKind::Vector)) {
187-
LLVM_DEBUG(dbgs() << DEBUG_TYPE << ": Will not replace: " << ScalarName
188-
<< ". Wrong type at index " << VFParam.ParamPos
189-
<< ": " << *OrigTy << "\n");
190-
return false;
191-
}
192-
}
193-
}
194-
195171
FunctionType *VectorFTy = VFABI::createFunctionType(*OptInfo, ScalarFTy);
196172
if (!VectorFTy)
197173
return false;
198174

199175
Function *TLIFunc = getTLIFunction(I.getModule(), VectorFTy,
200176
VD->getVectorFnName(), FuncToReplace);
201-
202177
replaceWithTLIFunction(I, *OptInfo, TLIFunc);
203178
LLVM_DEBUG(dbgs() << DEBUG_TYPE << ": Replaced call to `" << ScalarName
204179
<< "` with call to `" << TLIFunc->getName() << "`.\n");
@@ -245,9 +220,6 @@ PreservedAnalyses ReplaceWithVeclib::run(Function &F,
245220
const TargetLibraryInfo &TLI = AM.getResult<TargetLibraryAnalysis>(F);
246221
auto Changed = runImpl(TLI, F);
247222
if (Changed) {
248-
LLVM_DEBUG(dbgs() << "Instructions replaced with vector libraries: "
249-
<< NumCallsReplaced << "\n");
250-
251223
PreservedAnalyses PA;
252224
PA.preserveSet<CFGAnalyses>();
253225
PA.preserve<TargetLibraryAnalysis>();

llvm/unittests/Analysis/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ set(ANALYSIS_TEST_SOURCES
4040
PluginInlineAdvisorAnalysisTest.cpp
4141
PluginInlineOrderAnalysisTest.cpp
4242
ProfileSummaryInfoTest.cpp
43-
ReplaceWithVecLibTest.cpp
4443
ScalarEvolutionTest.cpp
4544
VectorFunctionABITest.cpp
4645
SparsePropagation.cpp

llvm/unittests/Analysis/ReplaceWithVecLibTest.cpp

Lines changed: 0 additions & 113 deletions
This file was deleted.

0 commit comments

Comments
 (0)