[llvm] fa306f1 - [WebAssembly] WebAssemblyLowerEmscriptenEHSjLj: Fix signature of malloc in wasm64 mode
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 17 18:16:44 PDT 2022
Author: Sam Clegg
Date: 2022-08-17T18:16:34-07:00
New Revision: fa306f13962d72ffd35b719ca9f85325f75cabbe
URL: https://github.com/llvm/llvm-project/commit/fa306f13962d72ffd35b719ca9f85325f75cabbe
DIFF: https://github.com/llvm/llvm-project/commit/fa306f13962d72ffd35b719ca9f85325f75cabbe.diff
LOG: [WebAssembly] WebAssemblyLowerEmscriptenEHSjLj: Fix signature of malloc in wasm64 mode
Differential Revision: https://reviews.llvm.org/D132091
Added:
Modified:
llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
llvm/test/CodeGen/WebAssembly/lower-wasm-sjlj.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
index 741753454027..fa468df23fee 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp
@@ -1290,9 +1290,11 @@ bool WebAssemblyLowerEmscriptenEHSjLj::runSjLjOnFunction(Function &F) {
"setjmpTableSize", Entry->getTerminator());
SetjmpTableSize->setDebugLoc(FirstDL);
// setjmpTable = (int *) malloc(40);
- Instruction *SetjmpTable = CallInst::CreateMalloc(
- SetjmpTableSize, IRB.getInt32Ty(), IRB.getInt32Ty(), IRB.getInt32(40),
- nullptr, nullptr, "setjmpTable");
+ Type *IntPtrTy = getAddrIntType(&M);
+ Constant *size = ConstantInt::get(IntPtrTy, 40);
+ Instruction *SetjmpTable =
+ CallInst::CreateMalloc(SetjmpTableSize, IntPtrTy, IRB.getInt32Ty(), size,
+ nullptr, nullptr, "setjmpTable");
SetjmpTable->setDebugLoc(FirstDL);
// CallInst::CreateMalloc may return a bitcast instruction if the result types
// mismatch. We need to set the debug loc for the original call too.
diff --git a/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll b/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
index 3873ce9b5dc2..0fddbc079760 100644
--- a/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
+++ b/llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
@@ -24,7 +24,7 @@ entry:
call void @longjmp(%struct.__jmp_buf_tag* %arraydecay1, i32 1) #1
unreachable
; CHECK: entry:
-; CHECK-NEXT: %[[MALLOCCALL:.*]] = tail call i8* @malloc(i32 40)
+; CHECK-NEXT: %[[MALLOCCALL:.*]] = tail call i8* @malloc([[PTR]] 40)
; CHECK-NEXT: %[[SETJMP_TABLE:.*]] = bitcast i8* %[[MALLOCCALL]] to i32*
; CHECK-NEXT: store i32 0, i32* %[[SETJMP_TABLE]]
; CHECK-NEXT: %[[SETJMP_TABLE_SIZE:.*]] = add i32 4, 0
@@ -311,7 +311,6 @@ declare void @_longjmp(%struct.__jmp_buf_tag*, i32) #1
declare i32 @__gxx_personality_v0(...)
declare i8* @__cxa_begin_catch(i8*)
declare void @__cxa_end_catch()
-declare i8* @malloc(i32)
declare void @free(i8*)
; JS glue functions and invoke wrappers declaration
diff --git a/llvm/test/CodeGen/WebAssembly/lower-wasm-sjlj.ll b/llvm/test/CodeGen/WebAssembly/lower-wasm-sjlj.ll
index 3c18a3ceaf3b..0e86ddb736be 100644
--- a/llvm/test/CodeGen/WebAssembly/lower-wasm-sjlj.ll
+++ b/llvm/test/CodeGen/WebAssembly/lower-wasm-sjlj.ll
@@ -27,7 +27,7 @@ entry:
unreachable
; CHECK: entry:
-; CHECK-NEXT: %malloccall = tail call i8* @malloc(i32 40)
+; CHECK-NEXT: %malloccall = tail call i8* @malloc([[PTR]] 40)
; CHECK-NEXT: %setjmpTable = bitcast i8* %malloccall to i32*
; CHECK-NEXT: store i32 0, i32* %setjmpTable, align 4
; CHECK-NEXT: %setjmpTableSize = add i32 4, 0
@@ -152,7 +152,6 @@ declare void @longjmp(%struct.__jmp_buf_tag*, i32) #1
declare i32 @__gxx_personality_v0(...)
declare i8* @__cxa_begin_catch(i8*)
declare void @__cxa_end_catch()
-declare i8* @malloc(i32)
declare void @free(i8*)
; JS glue function declarations
More information about the llvm-commits
mailing list