[llvm] e252293 - [WebAssembly] Add cbrt function signatures

Thomas Lively via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 13 13:19:19 PST 2020


Author: Thomas Lively
Date: 2020-02-13T13:18:42-08:00
New Revision: e252293d0629066225228596a9ef9d397513eb99

URL: https://github.com/llvm/llvm-project/commit/e252293d0629066225228596a9ef9d397513eb99
DIFF: https://github.com/llvm/llvm-project/commit/e252293d0629066225228596a9ef9d397513eb99.diff

LOG: [WebAssembly] Add cbrt function signatures

Summary:
Fixes a crash in the backend where optimizations produce calls to the
cbrt runtime functions. Fixes PR 44227.

Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D74259

Added: 
    

Modified: 
    llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp
    llvm/test/CodeGen/WebAssembly/libcalls.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp
index 1ad7720e9db9..6456026f4ba7 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp
@@ -178,6 +178,9 @@ struct RuntimeLibcallSignatureTable {
     Table[RTLIB::SQRT_F32] = f32_func_f32;
     Table[RTLIB::SQRT_F64] = f64_func_f64;
     Table[RTLIB::SQRT_F128] = func_iPTR_i64_i64;
+    Table[RTLIB::CBRT_F32] = f32_func_f32;
+    Table[RTLIB::CBRT_F64] = f64_func_f64;
+    Table[RTLIB::CBRT_F128] = func_iPTR_i64_i64;
     Table[RTLIB::LOG_F32] = f32_func_f32;
     Table[RTLIB::LOG_F64] = f64_func_f64;
     Table[RTLIB::LOG_F128] = func_iPTR_i64_i64;

diff  --git a/llvm/test/CodeGen/WebAssembly/libcalls.ll b/llvm/test/CodeGen/WebAssembly/libcalls.ll
index 37929fe8cf64..db1ab5c98884 100644
--- a/llvm/test/CodeGen/WebAssembly/libcalls.ll
+++ b/llvm/test/CodeGen/WebAssembly/libcalls.ll
@@ -73,9 +73,11 @@ define i32 @f64libcalls(double %x, double %y, i32 %z) {
  %e = call double @llvm.log.f64(double %d)
  ; CHECK: f64.call $push{{[0-9]}}=, exp
  %f = call double @llvm.exp.f64(double %e)
+ ; CHECK: f64.call $push{{[0-9]}}=, cbrt
+ %g = call fast double @llvm.pow.f64(double %f, double 0x3FD5555555555555)
  ; CHECK: i32.call $push{{[0-9]}}=, lround
- %g = call i32 @llvm.lround(double %f)
- ret i32 %g
+ %h = call i32 @llvm.lround(double %g)
+ ret i32 %h
 }
 
 ; fcmp ord and unord (RTLIB::O_F32 / RTLIB::UO_F32 etc) are a special case (see


        


More information about the llvm-commits mailing list