diff options
author | Yingwei Zheng <dtcxzyw2333@gmail.com> | 2023-10-15 17:00:50 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-15 17:00:50 +0800 |
commit | 9451004987e84c2bc2f109dd56ceab3844505a7f (patch) | |
tree | a939b96fd289a244e5a206ade82d48fc4e6558c4 /llvm/unittests/Analysis/TargetLibraryInfoTest.cpp | |
parent | e1bb0598b2c0ecb098c7032716e3ae10f10a4da7 (diff) | |
download | llvm-9451004987e84c2bc2f109dd56ceab3844505a7f.zip llvm-9451004987e84c2bc2f109dd56ceab3844505a7f.tar.gz llvm-9451004987e84c2bc2f109dd56ceab3844505a7f.tar.bz2 |
[InstCombine][TLI] Fix function prototype of `labs` (#69077)
`i64 @labs(i32)` is incorrectly recognized as `LibFunc_labs` because
type ID `Long` matches both `i32` and `i64`. This PR requires the type
of argument to match the return value.
Fixes #69059.
Diffstat (limited to 'llvm/unittests/Analysis/TargetLibraryInfoTest.cpp')
-rw-r--r-- | llvm/unittests/Analysis/TargetLibraryInfoTest.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/unittests/Analysis/TargetLibraryInfoTest.cpp b/llvm/unittests/Analysis/TargetLibraryInfoTest.cpp index 8c2328e..292b5ca 100644 --- a/llvm/unittests/Analysis/TargetLibraryInfoTest.cpp +++ b/llvm/unittests/Analysis/TargetLibraryInfoTest.cpp @@ -69,6 +69,16 @@ TEST_F(TargetLibraryInfoTest, InvalidProto) { M->getOrInsertFunction(TLI.getName(LF), InvalidFTy).getCallee()); EXPECT_FALSE(isLibFunc(F, LF)); } + + // i64 @labs(i32) + { + auto *InvalidLabsFTy = FunctionType::get(Type::getInt64Ty(Context), + {Type::getInt32Ty(Context)}, + /*isVarArg=*/false); + auto *F = cast<Function>( + M->getOrInsertFunction("labs", InvalidLabsFTy).getCallee()); + EXPECT_FALSE(isLibFunc(F, LibFunc_labs)); + } } // Check that we do accept know-correct prototypes. |