Skip to content

Commit 65f68c3

Browse files
author
badumbatish
committed
[WebAssembly] Fix nits for PR 145829
Addresses reusing same global data, and realignment of test case.
1 parent 91b42d5 commit 65f68c3

File tree

3 files changed

+21
-33
lines changed

3 files changed

+21
-33
lines changed

llvm/test/CodeGen/WebAssembly/eh-lsda.ll

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
; RUN: llc < %s --mtriple=wasm32-unknown-unknown -wasm-disable-explicit-locals -wasm-keep-registers -wasm-enable-eh -exception-model=wasm -mattr=+exception-handling | FileCheck %s -check-prefixes=CHECK,NOPIC -DPTR=32 -DALIGNMENT=4
2-
; RUN: llc < %s --mtriple=wasm64-unknown-unknown -wasm-disable-explicit-locals -wasm-keep-registers -wasm-enable-eh -exception-model=wasm -mattr=+exception-handling | FileCheck %s -check-prefixes=CHECK,NOPIC -DPTR=64 -DALIGNMENT=8
3-
; RUN: llc < %s --mtriple=wasm32-unknown-emscripten -wasm-disable-explicit-locals -wasm-keep-registers -wasm-enable-eh -exception-model=wasm -mattr=+exception-handling | FileCheck %s -check-prefixes=CHECK,NOPIC -DPTR=32 -DALIGNMENT=4
4-
; RUN: llc < %s --mtriple=wasm64-unknown-emscripten -wasm-disable-explicit-locals -wasm-keep-registers -wasm-enable-eh -exception-model=wasm -mattr=+exception-handling | FileCheck %s -check-prefixes=CHECK,NOPIC -DPTR=64 -DALIGNMENT=8
5-
; RUN: llc < %s --mtriple=wasm32-unknown-emscripten -wasm-disable-explicit-locals -wasm-keep-registers -wasm-enable-eh -exception-model=wasm -mattr=+exception-handling -relocation-model=pic | FileCheck %s -check-prefixes=CHECK,PIC -DPTR=32 -DALIGNMENT=4
6-
; RUN: llc < %s --mtriple=wasm64-unknown-emscripten -wasm-disable-explicit-locals -wasm-keep-registers -wasm-enable-eh -exception-model=wasm -mattr=+exception-handling -relocation-model=pic | FileCheck %s -check-prefixes=CHECK,PIC -DPTR=64 -DALIGNMENT=8
1+
; RUN: llc < %s --mtriple=wasm32-unknown-unknown -wasm-disable-explicit-locals -wasm-keep-registers -wasm-enable-eh -exception-model=wasm -mattr=+exception-handling | FileCheck %s -check-prefixes=CHECK,NOPIC -DPTR=32
2+
; RUN: llc < %s --mtriple=wasm64-unknown-unknown -wasm-disable-explicit-locals -wasm-keep-registers -wasm-enable-eh -exception-model=wasm -mattr=+exception-handling | FileCheck %s -check-prefixes=CHECK,NOPIC -DPTR=64
3+
; RUN: llc < %s --mtriple=wasm32-unknown-emscripten -wasm-disable-explicit-locals -wasm-keep-registers -wasm-enable-eh -exception-model=wasm -mattr=+exception-handling | FileCheck %s -check-prefixes=CHECK,NOPIC -DPTR=32
4+
; RUN: llc < %s --mtriple=wasm64-unknown-emscripten -wasm-disable-explicit-locals -wasm-keep-registers -wasm-enable-eh -exception-model=wasm -mattr=+exception-handling | FileCheck %s -check-prefixes=CHECK,NOPIC -DPTR=64
5+
; RUN: llc < %s --mtriple=wasm32-unknown-emscripten -wasm-disable-explicit-locals -wasm-keep-registers -wasm-enable-eh -exception-model=wasm -mattr=+exception-handling -relocation-model=pic | FileCheck %s -check-prefixes=CHECK,PIC -DPTR=32
6+
; RUN: llc < %s --mtriple=wasm64-unknown-emscripten -wasm-disable-explicit-locals -wasm-keep-registers -wasm-enable-eh -exception-model=wasm -mattr=+exception-handling -relocation-model=pic | FileCheck %s -check-prefixes=CHECK,PIC -DPTR=64
77

88
@_ZTIi = external constant ptr
99
@_ZTIf = external constant ptr
@@ -66,18 +66,18 @@ try.cont: ; preds = %entry, %catch.start
6666

6767
; CHECK-LABEL: test1:
6868
; In static linking, we load GCC_except_table as a constant directly.
69-
; NOPIC: i[[PTR]].const $push[[CONTEXT:.*]]=, [[ALIGNMENT]]
69+
; NOPIC: i[[PTR]].const $push[[CONTEXT:.*]]=, {{[48]}}
7070
; NOPIC-NEXT: i[[PTR]].const $push[[EXCEPT_TABLE:.*]]=, GCC_except_table1
7171
; NOPIC-NEXT: i[[PTR]].store __wasm_lpad_context($pop[[CONTEXT]]), $pop[[EXCEPT_TABLE]]
7272

7373
; In case of PIC, we make GCC_except_table symbols a relative on based on
7474
; __memory_base.
7575
; PIC: global.get $push[[CONTEXT:.*]]=, __wasm_lpad_context@GOT
76-
; PIC-NEXT: local.tee $push{{.*}}=, $[[CONTEXT_LOCAL:.*]]=, $pop[[CONTEXT]]
76+
; PIC-NEXT: local.tee $push{{.*}}=, $[[CONTEXT_LOCAL:.*]]=, $pop[[CONTEXT]]
7777
; PIC: global.get $push[[MEMORY_BASE:.*]]=, __memory_base
7878
; PIC-NEXT: i[[PTR]].const $push[[EXCEPT_TABLE_REL:.*]]=, GCC_except_table1@MBREL
7979
; PIC-NEXT: i[[PTR]].add $push[[EXCEPT_TABLE:.*]]=, $pop[[MEMORY_BASE]], $pop[[EXCEPT_TABLE_REL]]
80-
; PIC-NEXT: i[[PTR]].store {{[48]}}($[[CONTEXT_LOCAL]]), $pop[[EXCEPT_TABLE]]
80+
; PIC-NEXT: i[[PTR]].store {{[48]}}($[[CONTEXT_LOCAL]]), $pop[[EXCEPT_TABLE]]
8181

8282
; CHECK: .section .rodata.gcc_except_table,"",@
8383
; CHECK-NEXT: .p2align 2

llvm/test/CodeGen/WebAssembly/exception-legacy.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ define void @throw(ptr %p) {
3434
; CHECK: call foo
3535
; CHECK: catch $[[EXN:[0-9]+]]=, __cpp_exception
3636
; CHECK: global.set __stack_pointer
37-
; CHECK: i32.store __wasm_lpad_context
37+
; CHECK: i32.store __wasm_lpad_context
3838
; CHECK: call $drop=, _Unwind_CallPersonality, $[[EXN]]
3939
; CHECK: block
4040
; CHECK: br_if 0

llvm/test/CodeGen/WebAssembly/offset.ll

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -60,29 +60,6 @@ define i32 @load_i32_with_folded_gep_offset_nuw(ptr %p) {
6060
ret i32 %t
6161
}
6262

63-
@global_data = external global i32
64-
65-
define i32 @load_i32_global_with_folded_gep_offset_nonconst_nuw(i32 %idx) {
66-
; CHECK-LABEL: load_i32_global_with_folded_gep_offset_nonconst_nuw:
67-
; CHECK: i32.const $push0=, 2
68-
; CHECK-NEXT: i32.shl $push1=, $0, $pop0
69-
; CHECK-NOT: i32.add
70-
; CHECK-NEXT: i32.load $push2=, global_data($pop1)
71-
%s = getelementptr nuw i32, ptr @global_data, i32 %idx
72-
%t = load i32, ptr %s
73-
ret i32 %t
74-
}
75-
76-
define i32 @load_i32_global_with_folded_gep_offset_const_nuw() {
77-
; CHECK-LABEL: load_i32_global_with_folded_gep_offset_const_nuw:
78-
; CHECK: i32.const $push0=, 8
79-
; CHECK-NEXT: i32.load $push1=, global_data($pop0)
80-
entry:
81-
%t = load i32, ptr getelementptr nuw (i32, ptr @global_data, i32 2)
82-
ret i32 %t
83-
}
84-
85-
8663
; We can't fold a negative offset though, even with an inbounds gep.
8764

8865
; CHECK-LABEL: load_i32_with_unfolded_gep_negative_offset:
@@ -141,6 +118,17 @@ define i32 @load_i32_from_global_address() {
141118
ret i32 %t
142119
}
143120

121+
define i32 @load_i32_global_with_folded_gep_offset_nonconst_nuw(i32 %idx) {
122+
; CHECK-LABEL: load_i32_global_with_folded_gep_offset_nonconst_nuw:
123+
; CHECK: i32.const $push0=, 2
124+
; CHECK-NEXT: i32.shl $push1=, $0, $pop0
125+
; CHECK-NOT: i32.add
126+
; CHECK-NEXT: i32.load $push2=, gv($pop1)
127+
%s = getelementptr nuw i32, ptr @gv, i32 %idx
128+
%t = load i32, ptr %s
129+
ret i32 %t
130+
}
131+
144132
;===----------------------------------------------------------------------------
145133
; Loads: 64-bit
146134
;===----------------------------------------------------------------------------

0 commit comments

Comments
 (0)