Skip to content

Commit 38ccee0

Browse files
authored
[WASM] Fix for wasi libc build break add tan to RuntimeLibcallSignatureTable (#95082)
The wasm backend fetches the tan runtime lib call in `llvm/include/llvm/IR/RuntimeLibcalls.def` via `StaticLibcallNameMap()`, but ignores the runtime function because a function sinature mapping is not specified in RuntimeLibcallSignatureTable(). The fix is to specify the function signatures for float32-128. This is a fix for a build break reported on PR #94559 (comment).
1 parent d586372 commit 38ccee0

File tree

2 files changed

+39
-33
lines changed

2 files changed

+39
-33
lines changed

llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ struct RuntimeLibcallSignatureTable {
201201
Table[RTLIB::COS_F32] = f32_func_f32;
202202
Table[RTLIB::COS_F64] = f64_func_f64;
203203
Table[RTLIB::COS_F128] = i64_i64_func_i64_i64;
204+
Table[RTLIB::TAN_F32] = f32_func_f32;
205+
Table[RTLIB::TAN_F64] = f64_func_f64;
206+
Table[RTLIB::TAN_F128] = i64_i64_func_i64_i64;
204207
Table[RTLIB::SINCOS_F32] = func_f32_iPTR_iPTR;
205208
Table[RTLIB::SINCOS_F64] = func_f64_iPTR_iPTR;
206209
Table[RTLIB::SINCOS_F128] = func_i64_i64_iPTR_iPTR;

llvm/test/CodeGen/WebAssembly/libcalls.ll

+36-33
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ declare fp128 @llvm.nearbyint.f128(fp128)
1212
declare fp128 @llvm.pow.f128(fp128, fp128)
1313
declare fp128 @llvm.powi.f128.i32(fp128, i32)
1414

15+
declare double @llvm.tan.f64(double)
1516
declare double @llvm.cos.f64(double)
1617
declare double @llvm.log10.f64(double)
1718
declare double @llvm.pow.f64(double, double)
@@ -240,42 +241,44 @@ define double @f64libcalls(double %x, double %y, i32 %z) {
240241
; CHECK: .functype f64libcalls (f64, f64, i32) -> (f64)
241242
; CHECK-NEXT: .local i32
242243
; CHECK-NEXT: # %bb.0:
243-
; CHECK-NEXT: global.get $push11=, __stack_pointer
244-
; CHECK-NEXT: i32.const $push12=, 16
245-
; CHECK-NEXT: i32.sub $push18=, $pop11, $pop12
246-
; CHECK-NEXT: local.tee $push17=, 3, $pop18
247-
; CHECK-NEXT: global.set __stack_pointer, $pop17
248-
; CHECK-NEXT: local.get $push22=, 0
249-
; CHECK-NEXT: local.get $push19=, 0
250-
; CHECK-NEXT: call $push0=, cos, $pop19
251-
; CHECK-NEXT: call $push1=, log10, $pop0
252-
; CHECK-NEXT: local.get $push20=, 1
253-
; CHECK-NEXT: call $push2=, pow, $pop1, $pop20
254-
; CHECK-NEXT: local.get $push21=, 2
255-
; CHECK-NEXT: call $push3=, __powidf2, $pop2, $pop21
256-
; CHECK-NEXT: call $push4=, log, $pop3
257-
; CHECK-NEXT: call $push5=, exp, $pop4
258-
; CHECK-NEXT: call $push6=, exp10, $pop5
259-
; CHECK-NEXT: call $push7=, cbrt, $pop6
260-
; CHECK-NEXT: call $push8=, lround, $pop7
261-
; CHECK-NEXT: call $push9=, ldexp, $pop22, $pop8
262-
; CHECK-NEXT: local.get $push23=, 3
263-
; CHECK-NEXT: i32.const $push15=, 12
264-
; CHECK-NEXT: i32.add $push16=, $pop23, $pop15
265-
; CHECK-NEXT: call $push24=, frexp, $pop9, $pop16
266-
; CHECK-NEXT: local.set 0, $pop24
267-
; CHECK-NEXT: local.get $push25=, 3
268-
; CHECK-NEXT: i32.load $push10=, 12($pop25)
269-
; CHECK-NEXT: call escape_value, $pop10
270-
; CHECK-NEXT: local.get $push26=, 3
244+
; CHECK-NEXT: global.get $push12=, __stack_pointer
271245
; CHECK-NEXT: i32.const $push13=, 16
272-
; CHECK-NEXT: i32.add $push14=, $pop26, $pop13
273-
; CHECK-NEXT: global.set __stack_pointer, $pop14
274-
; CHECK-NEXT: local.get $push27=, 0
275-
; CHECK-NEXT: return $pop27
246+
; CHECK-NEXT: i32.sub $push19=, $pop12, $pop13
247+
; CHECK-NEXT: local.tee $push18=, 3, $pop19
248+
; CHECK-NEXT: global.set __stack_pointer, $pop18
249+
; CHECK-NEXT: local.get $push23=, 0
250+
; CHECK-NEXT: local.get $push20=, 0
251+
; CHECK-NEXT: call $push0=, tan, $pop20
252+
; CHECK-NEXT: call $push1=, cos, $pop0
253+
; CHECK-NEXT: call $push2=, log10, $pop1
254+
; CHECK-NEXT: local.get $push21=, 1
255+
; CHECK-NEXT: call $push3=, pow, $pop2, $pop21
256+
; CHECK-NEXT: local.get $push22=, 2
257+
; CHECK-NEXT: call $push4=, __powidf2, $pop3, $pop22
258+
; CHECK-NEXT: call $push5=, log, $pop4
259+
; CHECK-NEXT: call $push6=, exp, $pop5
260+
; CHECK-NEXT: call $push7=, exp10, $pop6
261+
; CHECK-NEXT: call $push8=, cbrt, $pop7
262+
; CHECK-NEXT: call $push9=, lround, $pop8
263+
; CHECK-NEXT: call $push10=, ldexp, $pop23, $pop9
264+
; CHECK-NEXT: local.get $push24=, 3
265+
; CHECK-NEXT: i32.const $push16=, 12
266+
; CHECK-NEXT: i32.add $push17=, $pop24, $pop16
267+
; CHECK-NEXT: call $push25=, frexp, $pop10, $pop17
268+
; CHECK-NEXT: local.set 0, $pop25
269+
; CHECK-NEXT: local.get $push26=, 3
270+
; CHECK-NEXT: i32.load $push11=, 12($pop26)
271+
; CHECK-NEXT: call escape_value, $pop11
272+
; CHECK-NEXT: local.get $push27=, 3
273+
; CHECK-NEXT: i32.const $push14=, 16
274+
; CHECK-NEXT: i32.add $push15=, $pop27, $pop14
275+
; CHECK-NEXT: global.set __stack_pointer, $pop15
276+
; CHECK-NEXT: local.get $push28=, 0
277+
; CHECK-NEXT: return $pop28
276278

277279

278-
%a = call double @llvm.cos.f64(double %x)
280+
%k = call double @llvm.tan.f64(double %x)
281+
%a = call double @llvm.cos.f64(double %k)
279282
%b = call double @llvm.log10.f64(double %a)
280283
%c = call double @llvm.pow.f64(double %b, double %y)
281284
%d = call double @llvm.powi.f64.i32(double %c, i32 %z)

0 commit comments

Comments
 (0)