-
Notifications
You must be signed in to change notification settings - Fork 13.5k
fix ConstantFoldFP128 params #98394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix ConstantFoldFP128 params #98394
Conversation
I ran into this error while building: ``` /google/src/cloud/mitchfoley/sync_emscripten2/google3/third_party/crosstool/v18/stable/wrappers/bin/clang++ -DGTEST_HAS_RTTI=0 -DHAS_LOGF128 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/usr/local/google/home/mitchfoley/repos/llvm-project/lib/Analysis -I/usr/local/google/home/mitchfoley/repos/llvm-project/llvm/lib/Analysis -I/usr/local/google/home/mitchfoley/repos/llvm-project/include -I/usr/local/google/home/mitchfoley/repos/llvm-project/llvm/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG -fno-exceptions -funwind-tables -fno-rtti -std=c++17 -MD -MT lib/Analysis/CMakeFiles/LLVMAnalysis.dir/ConstantFolding.cpp.o -MF lib/Analysis/CMakeFiles/LLVMAnalysis.dir/ConstantFolding.cpp.o.d -o lib/Analysis/CMakeFiles/LLVMAnalysis.dir/ConstantFolding.cpp.o -c /usr/local/google/home/mitchfoley/repos/llvm-project/llvm/lib/Analysis/ConstantFolding.cpp /usr/local/google/home/mitchfoley/repos/llvm-project/llvm/lib/Analysis/ConstantFolding.cpp:2129:16: error: no matching function for call to 'ConstantFoldFP128' 2129 | return ConstantFoldFP128(logf128, Op->getValueAPF(), Ty); | ^~~~~~~~~~~~~~~~~ /usr/local/google/home/mitchfoley/repos/llvm-project/llvm/lib/Analysis/ConstantFolding.cpp:1787:11: note: candidate function not viable: no known conversion from '_Float128 (_Float128) throw()' (aka '__float128 (__float128) throw()') to 'long double (*)(long double)' for 1st argument 1787 | Constant *ConstantFoldFP128(long double (*NativeFP)(long double), | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` with glibc, logf128 is not available when compiling with clang and it is available with gcc. But, in llvm, has_float128 define isn't set unless you're using clang. So the combination of those means this block ~never actually gets used (unless you're doing something weird like I am).
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write If you have received no comments on your PR for a week, you can request a review If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-llvm-analysis Author: None (walkingeyerobot) ChangesI ran into this error while building:
I'm pretty sure switching from with glibc, logf128 is not available when compiling with clang and it is available with gcc. But, in llvm, has_float128 define isn't set unless you're using clang. So the combination of those means this block ~never actually gets used (unless you're doing something weird like I am). This fixes what happens when this block is used, but doesn't address it actually being used. Full diff: https://github.com/llvm/llvm-project/pull/98394.diff 1 Files Affected:
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 962880f68f076..ca82f10f1ffd4 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -1784,7 +1784,7 @@ Constant *ConstantFoldFP(double (*NativeFP)(double), const APFloat &V,
}
#if defined(HAS_IEE754_FLOAT128) && defined(HAS_LOGF128)
-Constant *ConstantFoldFP128(long double (*NativeFP)(long double),
+Constant *ConstantFoldFP128(float128 (*NativeFP)(float128),
const APFloat &V, Type *Ty) {
llvm_fenv_clearexcept();
float128 Result = NativeFP(V.convertToQuad());
|
cc @MDevereau, who I believe authored this block a few weeks ago. |
See #96287. |
You can test this locally with the following command:git-clang-format --diff dad7442aff5c85ff9141b0d0f231bcd731cbadc6 893844e4b3332c6e8e85cf3f020f31bee6fda4ab --extensions cpp -- llvm/lib/Analysis/ConstantFolding.cpp View the diff from clang-format here.diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index ca82f10f1f..d223d504e7 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -1784,8 +1784,8 @@ Constant *ConstantFoldFP(double (*NativeFP)(double), const APFloat &V,
}
#if defined(HAS_IEE754_FLOAT128) && defined(HAS_LOGF128)
-Constant *ConstantFoldFP128(float128 (*NativeFP)(float128),
- const APFloat &V, Type *Ty) {
+Constant *ConstantFoldFP128(float128 (*NativeFP)(float128), const APFloat &V,
+ Type *Ty) {
llvm_fenv_clearexcept();
float128 Result = NativeFP(V.convertToQuad());
if (llvm_fenv_testexcept()) {
|
I ran into this error while building:
I'm pretty sure switching from
long double
tofloat128
is correct here, and that certainly makes it work on my machine.with glibc, logf128 is not available when compiling with clang and it is available with gcc. But, in llvm, has_float128 define isn't set unless you're using clang. So the combination of those means this block ~never actually gets used (unless you're doing something weird like I am).
This fixes what happens when this block is used, but doesn't address it actually being used.