Skip to content

Commit 01a82fa

Browse files
committed
RuntimeLibcalls: Fix dropping first libcall entry
Fixes regression reported after #144973, which happened to be acosf.
1 parent dd96465 commit 01a82fa

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

lld/test/wasm/lto/Inputs/libcall-archive.ll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,12 @@ define void @memcpy() #0 {
55
ret void
66
}
77

8+
define float @acosf(float %x) {
9+
ret float %x
10+
}
11+
12+
define i128 @__umodti3(i128 %a, i128 %b) {
13+
ret i128 %a
14+
}
15+
816
attributes #0 = { "target-features"="-bulk-memory,-bulk-memory-opt" }

lld/test/wasm/lto/libcall-archive.ll

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,28 @@
88
target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20"
99
target triple = "wasm32-unknown-unknown"
1010

11+
@llvm.used = appending global [2 x ptr] [ptr @test_acosf, ptr @test___umodti3]
12+
1113
define void @_start(ptr %a, ptr %b) #0 {
1214
entry:
1315
call void @llvm.memcpy.p0.p0.i64(ptr %a, ptr %b, i64 1024, i1 false)
1416
ret void
1517
}
1618

19+
; Emit acosf, which currently happens to be the first runtime libcall
20+
; entry.
21+
define float @test_acosf(float %x) {
22+
%acos = call float @llvm.acos.f32(float %x)
23+
ret float %acos
24+
}
25+
26+
; Emit __umodti3, which currently happens to be the last runtime
27+
; libcall entry.
28+
define i128 @test___umodti3(i128 %a, i128 %b) {
29+
%urem = urem i128 %a, %b
30+
ret i128 %urem
31+
}
32+
1733
declare void @llvm.memcpy.p0.p0.i64(ptr nocapture, ptr nocapture, i64, i1)
1834

1935
attributes #0 = { "target-features"="-bulk-memory,-bulk-memory-opt" }
@@ -22,6 +38,12 @@ attributes #0 = { "target-features"="-bulk-memory,-bulk-memory-opt" }
2238
; CHECK-NEXT: Name: name
2339
; CHECK-NEXT: FunctionNames:
2440
; CHECK-NEXT: - Index: 0
25-
; CHECK-NEXT: Name: _start
41+
; CHECK-NEXT: Name: test_acosf
2642
; CHECK-NEXT: - Index: 1
27-
; CHECK-NEXT: Name: memcpy
43+
; CHECK-NEXT: Name: acosf
44+
; CHECK-NEXT: - Index: 2
45+
; CHECK-NEXT: Name: test___umodti3
46+
; CHECK-NEXT: - Index: 3
47+
; CHECK-NEXT: Name: __umodti3
48+
; CHECK-NEXT: - Index: 4
49+
; CHECK-NEXT: Name: _start

llvm/include/llvm/IR/RuntimeLibcalls.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ struct RuntimeLibcallsInfo {
110110
}
111111

112112
ArrayRef<RTLIB::LibcallImpl> getLibcallImpls() const {
113-
// Trim Unsupported from the start
114-
return ArrayRef(LibcallImpls).drop_front();
113+
// Trim UNKNOWN_LIBCALL from the back
114+
return ArrayRef(LibcallImpls).drop_back();
115115
}
116116

117117
/// Get the comparison predicate that's to be used to test the result of the

0 commit comments

Comments
 (0)