aboutsummaryrefslogtreecommitdiff
path: root/llvm/test/CodeGen
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2026-02-12 13:33:18 -0800
committerGitHub <noreply@github.com>2026-02-12 13:33:18 -0800
commitc1e90fa663ca46c70d079503b83340d5e38105a4 (patch)
treeed1a037707ab83f88af5d384c496706fe1ebe2df /llvm/test/CodeGen
parenta8be67e6f3da18b70961a72c56a3f802b4ab4da9 (diff)
downloadllvm-main.zip
llvm-main.tar.gz
llvm-main.tar.bz2
[WebAssembly] Error on Wasm SjLj if +exception-handling is missing (#181070)HEADmain
This checks every user function of `setjmp` or `longjmp` and if any of them does not have `+exception-handling` target feature, errors out. Hopefully this gives a clearer error message to the users in case they do not provide consistent SjLj flags at compile time vs. link time. Closes #178135 and closes https://github.com/emscripten-core/emscripten/issues/26165.
Diffstat (limited to 'llvm/test/CodeGen')
-rw-r--r--llvm/test/CodeGen/WebAssembly/lower-em-sjlj-alloca.ll6
-rw-r--r--llvm/test/CodeGen/WebAssembly/lower-wasm-ehsjlj-phi.ll2
-rw-r--r--llvm/test/CodeGen/WebAssembly/lower-wasm-ehsjlj.ll4
-rw-r--r--llvm/test/CodeGen/WebAssembly/lower-wasm-sjlj-no-eh-feature.ll23
-rw-r--r--llvm/test/CodeGen/WebAssembly/lower-wasm-sjlj.ll6
-rw-r--r--llvm/test/CodeGen/WebAssembly/wasm-eh-sjlj-setjmp-within-catch.ll2
6 files changed, 33 insertions, 10 deletions
diff --git a/llvm/test/CodeGen/WebAssembly/lower-em-sjlj-alloca.ll b/llvm/test/CodeGen/WebAssembly/lower-em-sjlj-alloca.ll
index 3264fe9..2c50275 100644
--- a/llvm/test/CodeGen/WebAssembly/lower-em-sjlj-alloca.ll
+++ b/llvm/test/CodeGen/WebAssembly/lower-em-sjlj-alloca.ll
@@ -1,12 +1,12 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
-; RUN: opt -S -wasm-lower-em-ehsjlj -wasm-enable-sjlj -mtriple=wasm32-unknown-emscripten < %s | FileCheck %s
+; RUN: opt -S -wasm-lower-em-ehsjlj -wasm-enable-sjlj -mattr=+exception-handling -mtriple=wasm32-unknown-emscripten < %s | FileCheck %s
@buf = external global i8
declare i32 @setjmp(ptr) returns_twice
declare void @dummy()
define void @test_static() {
-; CHECK-LABEL: define void @test_static() personality ptr @__gxx_wasm_personality_v0 {
+; CHECK-LABEL: define void @test_static() {{.*}} personality ptr @__gxx_wasm_personality_v0 {
; CHECK-NEXT: [[ENTRY:.*]]:
; CHECK-NEXT: [[X:%.*]] = alloca i32, align 4
; CHECK-NEXT: [[FUNCTIONINVOCATIONID:%.*]] = alloca i32, align 4
@@ -69,7 +69,7 @@ else:
define void @test_dynamic(i32 %size) {
; CHECK-LABEL: define void @test_dynamic(
-; CHECK-SAME: i32 [[SIZE:%.*]]) personality ptr @__gxx_wasm_personality_v0 {
+; CHECK-SAME: i32 [[SIZE:%.*]]) {{.*}} personality ptr @__gxx_wasm_personality_v0 {
; CHECK-NEXT: [[ENTRY:.*]]:
; CHECK-NEXT: [[FUNCTIONINVOCATIONID:%.*]] = alloca i32, align 4
; CHECK-NEXT: br label %[[SETJMP_DISPATCH:.*]]
diff --git a/llvm/test/CodeGen/WebAssembly/lower-wasm-ehsjlj-phi.ll b/llvm/test/CodeGen/WebAssembly/lower-wasm-ehsjlj-phi.ll
index 97f6d79..5e8ebcf 100644
--- a/llvm/test/CodeGen/WebAssembly/lower-wasm-ehsjlj-phi.ll
+++ b/llvm/test/CodeGen/WebAssembly/lower-wasm-ehsjlj-phi.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -wasm-lower-em-ehsjlj -wasm-enable-eh -wasm-enable-sjlj -S | FileCheck %s
+; RUN: opt < %s -wasm-lower-em-ehsjlj -wasm-enable-eh -wasm-enable-sjlj -mattr=+exception-handling -S | FileCheck %s
target triple = "wasm32-unknown-emscripten"
diff --git a/llvm/test/CodeGen/WebAssembly/lower-wasm-ehsjlj.ll b/llvm/test/CodeGen/WebAssembly/lower-wasm-ehsjlj.ll
index 9de6652..d5ae37d7 100644
--- a/llvm/test/CodeGen/WebAssembly/lower-wasm-ehsjlj.ll
+++ b/llvm/test/CodeGen/WebAssembly/lower-wasm-ehsjlj.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -wasm-lower-em-ehsjlj -wasm-enable-eh -wasm-enable-sjlj -S | FileCheck %s
+; RUN: opt < %s -wasm-lower-em-ehsjlj -wasm-enable-eh -wasm-enable-sjlj -mattr=+exception-handling -S | FileCheck %s
; RUN: llc < %s -wasm-enable-eh -wasm-enable-sjlj -exception-model=wasm -mattr=+exception-handling -verify-machineinstrs
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
@@ -109,7 +109,7 @@ catch: ; preds = %catch.start
catchret from %2 to label %catchret.dest
; CHECK: catch: ; preds = %catch.start
; CHECK-NEXT: %exn = load ptr, ptr %exn.slot, align 4
-; CHECK-NEXT: %5 = call ptr @__cxa_begin_catch(ptr %exn) #3 [ "funclet"(token %2) ]
+; CHECK-NEXT: %5 = call ptr @__cxa_begin_catch(ptr %exn) {{.*}} [ "funclet"(token %2) ]
; CHECK-NEXT: invoke void @__cxa_end_catch() [ "funclet"(token %2) ]
; CHECK-NEXT: to label %.noexc unwind label %catch.dispatch.longjmp
diff --git a/llvm/test/CodeGen/WebAssembly/lower-wasm-sjlj-no-eh-feature.ll b/llvm/test/CodeGen/WebAssembly/lower-wasm-sjlj-no-eh-feature.ll
new file mode 100644
index 0000000..c929560
--- /dev/null
+++ b/llvm/test/CodeGen/WebAssembly/lower-wasm-sjlj-no-eh-feature.ll
@@ -0,0 +1,23 @@
+; RUN: not --crash opt < %s -wasm-lower-em-ehsjlj -wasm-enable-sjlj -S 2>&1 | FileCheck %s
+
+target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
+target triple = "wasm32-unknown-unknown"
+
+%struct.__jmp_buf_tag = type { [6 x i32], i32, [32 x i32] }
+
+; CHECK: LLVM ERROR: Function setjmp_longjmp is using setjmp/longjmp but does not have +exception-handling target feature
+define void @setjmp_longjmp() {
+entry:
+ %buf = alloca [1 x %struct.__jmp_buf_tag], align 16
+ %call = call i32 @setjmp(ptr %buf) #0
+ call void @longjmp(ptr %buf, i32 1) #1
+ unreachable
+}
+
+; Function Attrs: returns_twice
+declare i32 @setjmp(ptr) #0
+; Function Attrs: noreturn
+declare void @longjmp(ptr, i32) #1
+
+attributes #0 = { returns_twice }
+attributes #1 = { noreturn }
diff --git a/llvm/test/CodeGen/WebAssembly/lower-wasm-sjlj.ll b/llvm/test/CodeGen/WebAssembly/lower-wasm-sjlj.ll
index e1cb859..a4819b2 100644
--- a/llvm/test/CodeGen/WebAssembly/lower-wasm-sjlj.ll
+++ b/llvm/test/CodeGen/WebAssembly/lower-wasm-sjlj.ll
@@ -1,6 +1,6 @@
-; RUN: opt < %s -wasm-lower-em-ehsjlj -wasm-enable-sjlj -S | FileCheck %s -DPTR=i32
-; RUN: opt < %s -wasm-lower-em-ehsjlj -wasm-enable-sjlj -S --mattr=+atomics,+bulk-memory | FileCheck %s -DPTR=i32
-; RUN: opt < %s -wasm-lower-em-ehsjlj -wasm-enable-sjlj --mtriple=wasm64-unknown-unknown -data-layout="e-m:e-p:64:64-i64:64-n32:64-S128" -S | FileCheck %s -DPTR=i64
+; RUN: opt < %s -wasm-lower-em-ehsjlj -wasm-enable-sjlj -mattr=+exception-handling -S | FileCheck %s -DPTR=i32
+; RUN: opt < %s -wasm-lower-em-ehsjlj -wasm-enable-sjlj -S --mattr=+atomics,+bulk-memory,+exception-handling | FileCheck %s -DPTR=i32
+; RUN: opt < %s -wasm-lower-em-ehsjlj -wasm-enable-sjlj -mattr=+exception-handling --mtriple=wasm64-unknown-unknown -data-layout="e-m:e-p:64:64-i64:64-n32:64-S128" -S | FileCheck %s -DPTR=i64
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
target triple = "wasm32-unknown-unknown"
diff --git a/llvm/test/CodeGen/WebAssembly/wasm-eh-sjlj-setjmp-within-catch.ll b/llvm/test/CodeGen/WebAssembly/wasm-eh-sjlj-setjmp-within-catch.ll
index f0d622a..ed9b629 100644
--- a/llvm/test/CodeGen/WebAssembly/wasm-eh-sjlj-setjmp-within-catch.ll
+++ b/llvm/test/CodeGen/WebAssembly/wasm-eh-sjlj-setjmp-within-catch.ll
@@ -1,4 +1,4 @@
-; RUN: not --crash opt < %s -wasm-lower-em-ehsjlj -wasm-enable-eh -wasm-enable-sjlj -S 2>&1 | FileCheck %s
+; RUN: not --crash opt < %s -wasm-lower-em-ehsjlj -wasm-enable-eh -wasm-enable-sjlj -mattr=+exception-handling -S 2>&1 | FileCheck %s
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
target triple = "wasm32-unknown-unknown"