From 893844e4b3332c6e8e85cf3f020f31bee6fda4ab Mon Sep 17 00:00:00 2001 From: walkingeyerobot Date: Wed, 10 Jul 2024 17:29:57 -0400 Subject: [PATCH 1/2] fix ConstantFoldFP128 params 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). --- llvm/lib/Analysis/ConstantFolding.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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()); From b309dba4fc4c3db7e89c0b6fe2cfa206bbbe9c9e Mon Sep 17 00:00:00 2001 From: walkingeyerobot Date: Wed, 10 Jul 2024 23:56:51 -0400 Subject: [PATCH 2/2] fix formatting --- llvm/lib/Analysis/ConstantFolding.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp index ca82f10f1ffd4..d223d504e712e 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()) {