[llvm] 664a5c6 - [WebAssembly] Fix return type of __builtin_return_address under wasm64
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 3 08:34:23 PDT 2022
Author: Sam Clegg
Date: 2022-10-03T08:31:52-07:00
New Revision: 664a5c6d03f33e69e4a7d98d9bc51017877b61ad
URL: https://github.com/llvm/llvm-project/commit/664a5c6d03f33e69e4a7d98d9bc51017877b61ad
DIFF: https://github.com/llvm/llvm-project/commit/664a5c6d03f33e69e4a7d98d9bc51017877b61ad.diff
LOG: [WebAssembly] Fix return type of __builtin_return_address under wasm64
Differential Revision: https://reviews.llvm.org/D135005
Added:
Modified:
llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp
llvm/test/CodeGen/WebAssembly/return-address-emscripten.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp
index 0b3e534315d5f..4fe339ce52931 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp
@@ -71,6 +71,7 @@ enum RuntimeLibcallSignature {
i64_i64_func_i64_i64_i64_i64_iPTR,
i64_i64_i64_i64_func_i64_i64_i64_i64,
i64_i64_func_i64_i64_i32,
+ iPTR_func_i32,
iPTR_func_iPTR_i32_iPTR,
iPTR_func_iPTR_iPTR_iPTR,
f32_func_f32_f32_f32,
@@ -329,7 +330,7 @@ struct RuntimeLibcallSignatureTable {
Table[RTLIB::STACKPROTECTOR_CHECK_FAIL] = func;
// Return address handling
- Table[RTLIB::RETURN_ADDRESS] = i32_func_i32;
+ Table[RTLIB::RETURN_ADDRESS] = iPTR_func_i32;
// Element-wise Atomic memory
// TODO: Fix these when we implement atomic support
@@ -785,6 +786,10 @@ void llvm::getLibcallSignature(const WebAssemblySubtarget &Subtarget,
Params.push_back(wasm::ValType::I64);
Params.push_back(wasm::ValType::I32);
break;
+ case iPTR_func_i32:
+ Rets.push_back(PtrTy);
+ Params.push_back(wasm::ValType::I32);
+ break;
case iPTR_func_iPTR_i32_iPTR:
Rets.push_back(PtrTy);
Params.push_back(PtrTy);
diff --git a/llvm/test/CodeGen/WebAssembly/return-address-emscripten.ll b/llvm/test/CodeGen/WebAssembly/return-address-emscripten.ll
index 6280efe08c4f2..712f4aaf3235b 100644
--- a/llvm/test/CodeGen/WebAssembly/return-address-emscripten.ll
+++ b/llvm/test/CodeGen/WebAssembly/return-address-emscripten.ll
@@ -1,11 +1,10 @@
-; RUN: llc < %s -asm-verbose=false | FileCheck %s
-
-target triple = "wasm32-unknown-emscripten"
+; RUN: llc -mtriple=wasm32-unknown-emscripten < %s -asm-verbose=false | FileCheck -DPTR=32 %s
+; RUN: llc -mtriple=wasm64-unknown-emscripten < %s -asm-verbose=false | FileCheck -DPTR=64 %s
; This tests the implementation of __builtin_return_address on emscripten
; CHECK-LABEL: test_returnaddress:
-; CHECK-NEXT: .functype test_returnaddress () -> (i32){{$}}
+; CHECK-NEXT: .functype test_returnaddress () -> (i[[PTR]]){{$}}
; CHECK-NEXT: {{^}} i32.const 0{{$}}
; CHECK-NEXT: {{^}} call emscripten_return_address{{$}}
; CHECK-NEXT: {{^}} end_function{{$}}
More information about the llvm-commits
mailing list