Skip to content

Commit 24617b5

Browse files
getLibFunc accepts an Opcode and a ScalarFTy.
1 parent e239e37 commit 24617b5

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

llvm/include/llvm/Analysis/TargetLibraryInfo.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ class TargetLibraryInfoImpl {
156156
/// FDecl is assumed to have a parent Module when using this function.
157157
bool getLibFunc(const Function &FDecl, LibFunc &F) const;
158158

159-
/// Searches for a function name using the opcode of \p I. Currently, only the
160-
/// frem instruction is supported.
161-
bool getLibFunc(const Instruction &I, LibFunc &F) const;
159+
/// Searches for a function name using an Instruction \p Opcode.
160+
/// Currently, only the frem instruction is supported.
161+
bool getLibFunc(unsigned int Opcode, Type *ScalarTy, LibFunc &F) const;
162162

163163
/// Forces a function to be marked as unavailable.
164164
void setUnavailable(LibFunc F) {
@@ -364,10 +364,10 @@ class TargetLibraryInfo {
364364
getLibFunc(*(CB.getCalledFunction()), F);
365365
}
366366

367-
/// Searches for a function name using the opcode of \p I. Currently, only the
368-
/// frem instruction is supported.
369-
bool getLibFunc(const Instruction &I, LibFunc &F) const {
370-
return Impl->getLibFunc(I, F);
367+
/// Searches for a function name using an Instruction \p Opcode.
368+
/// Currently, only the frem instruction is supported.
369+
bool getLibFunc(unsigned int Opcode, Type *ScalarTy, LibFunc &F) const {
370+
return Impl->getLibFunc(Opcode, ScalarTy, F);
371371
}
372372

373373
/// Disables all builtins.

llvm/lib/Analysis/TargetLibraryInfo.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,12 +1149,11 @@ bool TargetLibraryInfoImpl::getLibFunc(const Function &FDecl,
11491149
return isValidProtoForLibFunc(*FDecl.getFunctionType(), F, *M);
11501150
}
11511151

1152-
bool TargetLibraryInfoImpl::getLibFunc(const Instruction &I, LibFunc &F) const {
1153-
if (I.getOpcode() != Instruction::FRem)
1154-
return false;
1155-
1156-
Type *ScalarTy = I.getType()->getScalarType();
1157-
if (!ScalarTy->isDoubleTy() && !ScalarTy->isFloatTy())
1152+
bool TargetLibraryInfoImpl::getLibFunc(unsigned int Opcode, Type *ScalarTy,
1153+
LibFunc &F) const {
1154+
// Must be a double or a float frem instruction.
1155+
if (Opcode != Instruction::FRem ||
1156+
(!ScalarTy->isDoubleTy() && !ScalarTy->isFloatTy()))
11581157
return false;
11591158

11601159
F = ScalarTy->isDoubleTy() ? LibFunc_fmod : LibFunc_fmodf;

llvm/unittests/Analysis/TargetLibraryInfoTest.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -639,8 +639,6 @@ class TLITestAarch64 : public ::testing::Test {
639639
TLITestAarch64() : TargetTriple(Triple("aarch64-unknown-linux-gnu")) {
640640
TLII = std::make_unique<TargetLibraryInfoImpl>(
641641
TargetLibraryInfoImpl(TargetTriple));
642-
TLII->addVectorizableFunctionsFromVecLib(TargetLibraryInfoImpl::NoLibrary,
643-
TargetTriple);
644642
TLI = std::make_unique<TargetLibraryInfo>(TargetLibraryInfo(*TLII));
645643
}
646644

@@ -650,7 +648,7 @@ class TLITestAarch64 : public ::testing::Test {
650648
Value *V = Constant::getNullValue(Ty);
651649
Instruction *FRem = BinaryOperator::Create(Instruction::FRem, V, V);
652650
LibFunc Func;
653-
if (!TLI->getLibFunc(*FRem, Func))
651+
if (!TLI->getLibFunc(FRem->getOpcode(), FRem->getType(), Func))
654652
return "";
655653
FRem->deleteValue();
656654
return TLI->getName(Func);

0 commit comments

Comments
 (0)