Skip to content

Commit 1eb7f05

Browse files
authored
CodeGen: Fix libcall names for exp10 on the various darwins (#92520)
It's really great that we have the same information duplicated in TargetLibraryInfo and RuntimeLibcalls which both assume everything by default. Should fix issue reported after #92287
1 parent 6430939 commit 1eb7f05

File tree

5 files changed

+155
-2
lines changed

5 files changed

+155
-2
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -2050,8 +2050,15 @@ SDValue SelectionDAGLegalize::ExpandSPLAT_VECTOR(SDNode *Node) {
20502050
std::pair<SDValue, SDValue> SelectionDAGLegalize::ExpandLibCall(RTLIB::Libcall LC, SDNode *Node,
20512051
TargetLowering::ArgListTy &&Args,
20522052
bool isSigned) {
2053-
SDValue Callee = DAG.getExternalSymbol(TLI.getLibcallName(LC),
2054-
TLI.getPointerTy(DAG.getDataLayout()));
2053+
EVT CodePtrTy = TLI.getPointerTy(DAG.getDataLayout());
2054+
SDValue Callee;
2055+
if (const char *LibcallName = TLI.getLibcallName(LC))
2056+
Callee = DAG.getExternalSymbol(LibcallName, CodePtrTy);
2057+
else {
2058+
Callee = DAG.getUNDEF(CodePtrTy);
2059+
DAG.getContext()->emitError(Twine("no libcall available for ") +
2060+
Node->getOperationName(&DAG));
2061+
}
20552062

20562063
EVT RetVT = Node->getValueType(0);
20572064
Type *RetTy = RetVT.getTypeForEVT(*DAG.getContext());

llvm/lib/CodeGen/TargetLoweringBase.cpp

+28
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,34 @@ void TargetLoweringBase::InitLibcalls(const Triple &TT) {
227227
CallingConv::ARM_AAPCS_VFP);
228228
}
229229
}
230+
231+
switch (TT.getOS()) {
232+
case Triple::MacOSX:
233+
if (TT.isMacOSXVersionLT(10, 9)) {
234+
setLibcallName(RTLIB::EXP10_F32, nullptr);
235+
setLibcallName(RTLIB::EXP10_F64, nullptr);
236+
} else {
237+
setLibcallName(RTLIB::EXP10_F32, "__exp10f");
238+
setLibcallName(RTLIB::EXP10_F64, "__exp10");
239+
}
240+
break;
241+
case Triple::IOS:
242+
case Triple::TvOS:
243+
case Triple::WatchOS:
244+
case Triple::XROS:
245+
if (!TT.isWatchOS() &&
246+
(TT.isOSVersionLT(7, 0) || (TT.isOSVersionLT(9, 0) && TT.isX86()))) {
247+
setLibcallName(RTLIB::EXP10_F32, nullptr);
248+
setLibcallName(RTLIB::EXP10_F64, nullptr);
249+
} else {
250+
setLibcallName(RTLIB::EXP10_F32, "__exp10f");
251+
setLibcallName(RTLIB::EXP10_F64, "__exp10");
252+
}
253+
254+
break;
255+
default:
256+
break;
257+
}
230258
} else {
231259
setLibcallName(RTLIB::FPEXT_F16_F32, "__gnu_h2f_ieee");
232260
setLibcallName(RTLIB::FPROUND_F32_F16, "__gnu_f2h_ieee");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
; RUN: llc -mtriple=aarch64-linux-gnu < %s | FileCheck -check-prefix=LINUX %s
2+
; RUN: llc -mtriple=aarch64-apple-macos10.9 < %s | FileCheck -check-prefix=APPLE %s
3+
; RUN: llc -mtriple=aarch64-apple-ios7.0 < %s | FileCheck -check-prefix=APPLE %s
4+
; RUN: llc -mtriple=aarch64-apple-tvos7.0 < %s | FileCheck -check-prefix=APPLE %s
5+
; RUN: llc -mtriple=aarch64-apple-watchos7.0 < %s | FileCheck -check-prefix=APPLE %s
6+
; RUN: llc -mtriple=aarch64-apple-xros7.0 < %s | FileCheck -check-prefix=APPLE %s
7+
8+
; RUN: not llc -mtriple=aarch64-apple-macos10.8 -filetype=null %s 2>&1 | FileCheck -check-prefix=ERR %s
9+
; RUN: not llc -mtriple=aarch64-apple-ios6.0 -filetype=null %s 2>&1 | FileCheck -check-prefix=ERR %s
10+
; RUN: not llc -mtriple=aarch64-apple-tvos6.0 -filetype=null %s 2>&1 | FileCheck -check-prefix=ERR %s
11+
; RUN: not llc -mtriple=aarch64-apple-xros6.0 -filetype=null %s 2>&1 | FileCheck -check-prefix=ERR %s
12+
13+
; Check exp10/exp10f is emitted as __exp10/__exp10f on assorted systems.
14+
15+
; ERR: no libcall available for fexp10
16+
17+
define float @test_exp10_f32(float %x) {
18+
; LINUX-LABEL: test_exp10_f32:
19+
; LINUX: // %bb.0:
20+
; LINUX-NEXT: b exp10f
21+
;
22+
; APPLE-LABEL: test_exp10_f32:
23+
; APPLE: ; %bb.0:
24+
; APPLE-NEXT: b ___exp10f
25+
%ret = call float @llvm.exp10.f32(float %x)
26+
ret float %ret
27+
}
28+
29+
define double @test_exp10_f64(double %x) {
30+
; LINUX-LABEL: test_exp10_f64:
31+
; LINUX: // %bb.0:
32+
; LINUX-NEXT: b exp10
33+
;
34+
; APPLE-LABEL: test_exp10_f64:
35+
; APPLE: ; %bb.0:
36+
; APPLE-NEXT: b ___exp10
37+
%ret = call double @llvm.exp10.f64(double %x)
38+
ret double %ret
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
; RUN: llc -mtriple=armv7-linux-gnu < %s | FileCheck -check-prefix=LINUX %s
2+
; RUN: llc -mtriple=armv7-apple-macos10.9 < %s | FileCheck -check-prefix=APPLE %s
3+
; RUN: llc -mtriple=armv7-apple-ios7.0 < %s | FileCheck -check-prefix=APPLE %s
4+
; RUN: llc -mtriple=armv7-apple-tvos7.0 < %s | FileCheck -check-prefix=APPLE %s
5+
; RUN: llc -mtriple=armv7-apple-watchos7.0 < %s | FileCheck -check-prefix=APPLE %s
6+
; RUN: llc -mtriple=armv7-apple-xros7.0 < %s | FileCheck -check-prefix=APPLE %s
7+
8+
; RUN: not llc -mtriple=armv7-apple-macos10.8 -filetype=null %s 2>&1 | FileCheck -check-prefix=ERR %s
9+
; RUN: not llc -mtriple=armv7-apple-ios6.0 -filetype=null %s 2>&1 | FileCheck -check-prefix=ERR %s
10+
; RUN: not llc -mtriple=armv7-apple-tvos6.0 -filetype=null %s 2>&1 | FileCheck -check-prefix=ERR %s
11+
; RUN: not llc -mtriple=armv7-apple-xros6.0 -filetype=null %s 2>&1 | FileCheck -check-prefix=ERR %s
12+
13+
; Check exp10/exp10f is emitted as __exp10/__exp10f on assorted systems.
14+
15+
; ERR: no libcall available for fexp10
16+
17+
define float @test_exp10_f32(float %x) {
18+
; LINUX-LABEL: test_exp10_f32:
19+
; LINUX: @ %bb.0:
20+
; LINUX-NEXT: b exp10f
21+
;
22+
; APPLE-LABEL: test_exp10_f32:
23+
; APPLE: @ %bb.0:
24+
; APPLE-NEXT: b ___exp10f
25+
%ret = call float @llvm.exp10.f32(float %x)
26+
ret float %ret
27+
}
28+
29+
define double @test_exp10_f64(double %x) {
30+
; LINUX-LABEL: test_exp10_f64:
31+
; LINUX: @ %bb.0:
32+
; LINUX-NEXT: b exp10
33+
;
34+
; APPLE-LABEL: test_exp10_f64:
35+
; APPLE: @ %bb.0:
36+
; APPLE-NEXT: b ___exp10
37+
%ret = call double @llvm.exp10.f64(double %x)
38+
ret double %ret
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
2+
; RUN: llc -mtriple=x86_64-linux-gnu < %s | FileCheck -check-prefix=LINUX %s
3+
; RUN: llc -mtriple=x86_64-apple-macos10.9 < %s | FileCheck -check-prefix=APPLE %s
4+
; RUN: llc -mtriple=x86_64-apple-ios9.0 < %s | FileCheck -check-prefix=APPLE %s
5+
; RUN: llc -mtriple=x86_64-apple-tvos9.0 < %s | FileCheck -check-prefix=APPLE %s
6+
; RUN: llc -mtriple=x86_64-apple-watchos9.0 < %s | FileCheck -check-prefix=APPLE %s
7+
; RUN: llc -mtriple=x86_64-apple-xros9.0 < %s | FileCheck -check-prefix=APPLE %s
8+
9+
; RUN: not llc -mtriple=x86_64-apple-macos10.8 -filetype=null %s 2>&1 | FileCheck -check-prefix=ERR %s
10+
; RUN: not llc -mtriple=x86_64-apple-ios8.0 -filetype=null %s 2>&1 | FileCheck -check-prefix=ERR %s
11+
; RUN: not llc -mtriple=x86_64-apple-tvos8.0 -filetype=null %s 2>&1 | FileCheck -check-prefix=ERR %s
12+
; RUN: not llc -mtriple=x86_64-apple-xros8.0 -filetype=null %s 2>&1 | FileCheck -check-prefix=ERR %s
13+
14+
; Check exp10/exp10f is emitted as __exp10/__exp10f on assorted systems.
15+
16+
; ERR: no libcall available for fexp10
17+
18+
define float @test_exp10_f32(float %x) {
19+
; LINUX-LABEL: test_exp10_f32:
20+
; LINUX: # %bb.0:
21+
; LINUX-NEXT: jmp exp10f@PLT # TAILCALL
22+
;
23+
; APPLE-LABEL: test_exp10_f32:
24+
; APPLE: ## %bb.0:
25+
; APPLE-NEXT: jmp ___exp10f ## TAILCALL
26+
%ret = call float @llvm.exp10.f32(float %x)
27+
ret float %ret
28+
}
29+
30+
define double @test_exp10_f64(double %x) {
31+
; LINUX-LABEL: test_exp10_f64:
32+
; LINUX: # %bb.0:
33+
; LINUX-NEXT: jmp exp10@PLT # TAILCALL
34+
;
35+
; APPLE-LABEL: test_exp10_f64:
36+
; APPLE: ## %bb.0:
37+
; APPLE-NEXT: jmp ___exp10 ## TAILCALL
38+
%ret = call double @llvm.exp10.f64(double %x)
39+
ret double %ret
40+
}

0 commit comments

Comments
 (0)