aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2024-03-12 12:32:48 +0200
committerGitHub <noreply@github.com>2024-03-12 12:32:48 +0200
commit5a100551d5652da586800c67edd4ccb3b18b10dc (patch)
tree1262daa11210d25f9deace512e167432a53f6256
parent23ffb2bdb96cf5a8eebce86b1ab21acf88979661 (diff)
downloadllvm-5a100551d5652da586800c67edd4ccb3b18b10dc.zip
llvm-5a100551d5652da586800c67edd4ccb3b18b10dc.tar.gz
llvm-5a100551d5652da586800c67edd4ccb3b18b10dc.tar.bz2
[Analysis] Treat ldexpf() as missing on MinGW (#84748)
The function does exist, but it is a plain wrapper over regular ldexp(), so there's no benefit in calling it over regular ldexp(). Therefore, treat it as missing. This fixes builds of Wine for aarch64 with Clang in mingw mode, which regressed recently in 8d976c7f20fe8d92fe6f54af411594e15fac25ae. That commit unlocked transforming calls to ldexp into ldexpf, for some codepaths within Wine. Wine can use compilers in mingw mode without the regular mingw runtime libraries, which caused this to fail. (However, if the transformation to use ldexpf() would have made sense, the right fix would have been for Wine to provide a similar ldexpf->ldexp wrapper just like mingw does.)
-rw-r--r--llvm/lib/Analysis/TargetLibraryInfo.cpp5
-rw-r--r--llvm/test/Transforms/InstCombine/exp2-1.ll1
2 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/TargetLibraryInfo.cpp b/llvm/lib/Analysis/TargetLibraryInfo.cpp
index 835268b..c819558 100644
--- a/llvm/lib/Analysis/TargetLibraryInfo.cpp
+++ b/llvm/lib/Analysis/TargetLibraryInfo.cpp
@@ -456,6 +456,11 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T,
TLI.setUnavailable(LibFunc_uname);
TLI.setUnavailable(LibFunc_unsetenv);
TLI.setUnavailable(LibFunc_utimes);
+
+ // MinGW does have ldexpf, but it is a plain wrapper over regular ldexp.
+ // Therefore it's not beneficial to transform code to use it, i.e.
+ // just pretend that the function is not available.
+ TLI.setUnavailable(LibFunc_ldexpf);
}
// Pick just one set of new/delete variants.
diff --git a/llvm/test/Transforms/InstCombine/exp2-1.ll b/llvm/test/Transforms/InstCombine/exp2-1.ll
index 79aeded..8419854 100644
--- a/llvm/test/Transforms/InstCombine/exp2-1.ll
+++ b/llvm/test/Transforms/InstCombine/exp2-1.ll
@@ -4,6 +4,7 @@
; RUN: opt < %s -passes=instcombine -S -mtriple=unknown | FileCheck %s -check-prefixes=LDEXP32
; RUN: opt < %s -passes=instcombine -S -mtriple=msp430 | FileCheck %s -check-prefixes=LDEXP16
; RUN: opt < %s -passes=instcombine -S -mtriple=i386-pc-win32 | FileCheck %s -check-prefixes=NOLDEXPF
+; RUN: opt < %s -passes=instcombine -S -mtriple=i386-windows-gnu | FileCheck %s -check-prefixes=NOLDEXPF
; RUN: opt < %s -passes=instcombine -S -mtriple=amdgcn-unknown-unknown | FileCheck %s -check-prefixes=NOLDEXP
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"