[lld] 962acf0 - [lld][WebAssembly] Use llvm-objdump to test __wasm_init_memory
Thomas Lively via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 14 18:08:09 PDT 2021
Author: Thomas Lively
Date: 2021-09-14T18:07:59-07:00
New Revision: 962acf0a27fbdb945b7b790cc57ba4ae4729879f
URL: https://github.com/llvm/llvm-project/commit/962acf0a27fbdb945b7b790cc57ba4ae4729879f
DIFF: https://github.com/llvm/llvm-project/commit/962acf0a27fbdb945b7b790cc57ba4ae4729879f.diff
LOG: [lld][WebAssembly] Use llvm-objdump to test __wasm_init_memory
Rather than depending on the hex dump from obj2yaml. Now the test shows the
expected function body in a human readable format.
Differential Revision: https://reviews.llvm.org/D109730
Added:
Modified:
lld/test/wasm/data-segments.ll
Removed:
################################################################################
diff --git a/lld/test/wasm/data-segments.ll b/lld/test/wasm/data-segments.ll
index e47f38753d829..abfcc35277671 100644
--- a/lld/test/wasm/data-segments.ll
+++ b/lld/test/wasm/data-segments.ll
@@ -19,19 +19,23 @@
; atomics, bulk memory, shared memory => passive segments
; RUN: wasm-ld -no-gc-sections --no-entry --shared-memory --max-memory=131072 %t.atomics.bulk-mem.o -o %t.atomics.bulk-mem.wasm
-; RUN: obj2yaml %t.atomics.bulk-mem.wasm | FileCheck %s --check-prefixes PASSIVE,PASSIVE32
+; RUN: obj2yaml %t.atomics.bulk-mem.wasm | FileCheck %s --check-prefix PASSIVE
+; RUN: llvm-objdump --disassemble-symbols=__wasm_init_memory --no-show-raw-insn --no-leading-addr %t.atomics.bulk-mem.wasm | FileCheck %s --check-prefixes DIS,NOPIC-DIS -DPTR=i32
; atomics, bulk memory, shared memory, wasm64 => passive segments
; RUN: wasm-ld -mwasm64 -no-gc-sections --no-entry --shared-memory --max-memory=131072 %t.atomics.bulk-mem64.o -o %t.atomics.bulk-mem64.wasm
-; RUN: obj2yaml %t.atomics.bulk-mem64.wasm | FileCheck %s --check-prefixes PASSIVE,PASSIVE64
+; RUN: obj2yaml %t.atomics.bulk-mem64.wasm | FileCheck %s --check-prefix PASSIVE
+; RUN: llvm-objdump --disassemble-symbols=__wasm_init_memory --no-show-raw-insn --no-leading-addr %t.atomics.bulk-mem64.wasm | FileCheck %s --check-prefixes DIS,NOPIC-DIS -DPTR=i64
; Also test in combination with PIC/pie
; RUN: wasm-ld --experimental-pic -pie -no-gc-sections --no-entry --shared-memory --max-memory=131072 %t.atomics.bulk-mem.pic.o -o %t.pic.wasm
; RUN: obj2yaml %t.pic.wasm | FileCheck %s --check-prefixes PASSIVE-PIC,PASSIVE32-PIC
+; RUN: llvm-objdump --disassemble-symbols=__wasm_init_memory --no-show-raw-insn --no-leading-addr %t.pic.wasm | FileCheck %s --check-prefixes DIS,PIC-DIS -DPTR=i32
; Also test in combination with PIC/pie + wasm64
; RUN: wasm-ld -mwasm64 --experimental-pic -pie -no-gc-sections --no-entry --shared-memory --max-memory=131072 %t.atomics.bulk-mem.pic-mem64.o -o %t.pic-mem64.wasm
; RUN: obj2yaml %t.pic-mem64.wasm | FileCheck %s --check-prefixes PASSIVE-PIC,PASSIVE64-PIC
+; RUN: llvm-objdump --disassemble-symbols=__wasm_init_memory --no-show-raw-insn --no-leading-addr %t.pic-mem64.wasm | FileCheck %s --check-prefixes DIS,PIC-DIS -DPTR=i64
@a = hidden global [6 x i8] c"hello\00", align 1
@b = hidden global [8 x i8] c"goodbye\00", align 1
@@ -84,8 +88,7 @@
; PASSIVE-NEXT: Body: 0B
; PASSIVE-NEXT: - Index: 2
; PASSIVE-NEXT: Locals: []
-; PASSIVE32-NEXT: Body: 02400240024041B4D60041004101FE4802000E020001020B4180084100410DFC08000041900841004114FC08010041B4D6004102FE17020041B4D600417FFE0002001A0C010B41B4D6004101427FFE0102001A0BFC0900FC09010B
-; PASSIVE64-NEXT: Body: 02400240024042B4D60041004101FE4802000E020001020B4280084100410DFC08000042900841004114FC08010042B4D6004102FE17020042B4D600417FFE0002001A0C010B42B4D6004101427FFE0102001A0BFC0900FC09010B
+; PASSIVE-NEXT: Body: {{.*}}
; PASSIVE-NEXT: - Type: DATA
; PASSIVE-NEXT: Segments:
; PASSIVE-NEXT: - SectionOffset: 3
@@ -120,9 +123,8 @@
; PASSIVE-PIC-NEXT: Locals:
; PASSIVE32-PIC-NEXT: - Type: I32
; PASSIVE64-PIC-NEXT: - Type: I64
-; PASSIVE-PIC-NEXT: Count: 1
-; PASSIVE32-PIC-NEXT: Body: 230141B4CE006A2100024002400240200041004101FE4802000E020001020B410023016A4100410DFC080000411023016A41004114FC08010020004102FE1702002000417FFE0002001A0C010B20004101427FFE0102001A0BFC0900FC09010B
-; PASSIVE64-PIC-NEXT: Body: 230142B4CE007C2100024002400240200041004101FE4802000E020001020B420023017C4100410DFC080000421023017C41004114FC08010020004102FE1702002000417FFE0002001A0C010B20004101427FFE0102001A0BFC0900FC09010B
+; PASSIVE-PIC-NEXT: Count: 1
+; PASSIVE-PIC-NEXT: Body: {{.*}}
; PASSIVE-PIC-NEXT: - Index: 3
; PASSIVE-PIC-NEXT: Locals: []
; PASSIVE-PIC-NEXT: Body: 0B
@@ -145,3 +147,70 @@
; PASSIVE-PIC-NEXT: Name: __wasm_init_memory
; PASSIVE-PIC-NEXT: - Index: 3
; PASSIVE-PIC-NEXT: Name: __wasm_apply_data_relocs
+
+; DIS-LABEL: <__wasm_init_memory>:
+
+; PIC-DIS: .local [[PTR]]
+; PIC-DIS-NEXT: global.get 1
+; PIC-DIS-NEXT: [[PTR]].const 10036
+; PIC-DIS-NEXT: [[PTR]].add
+; PIC-DIS-NEXT: local.set 0
+
+; DIS: block
+; DIS-NEXT: block
+; DIS-NEXT: block
+
+; NOPIC-DIS-NEXT: [[PTR]].const 11060
+; PIC-DIS-NEXT: local.get 0
+
+; DIS-NEXT: i32.const 0
+; DIS-NEXT: i32.const 1
+; DIS-NEXT: i32.atomic.rmw.cmpxchg 0
+; DIS-NEXT: br_table {0, 1, 2} # 1: down to label1
+; DIS-NEXT: # 2: down to label0
+; DIS-NEXT: end
+
+; NOPIC-DIS-NEXT: [[PTR]].const 1024
+; PIC-DIS-NEXT: [[PTR]].const 0
+; PIC-DIS-NEXT: global.get 1
+; PIC-DIS-NEXT: [[PTR]].add
+
+; DIS-NEXT: i32.const 0
+; DIS-NEXT: i32.const 13
+; DIS-NEXT: memory.init 0, 0
+
+; NOPIC-DIS-NEXT: [[PTR]].const 1040
+; PIC-DIS-NEXT: [[PTR]].const 16
+; PIC-DIS-NEXT: global.get 1
+; PIC-DIS-NEXT: [[PTR]].add
+
+; DIS-NEXT: i32.const 0
+; DIS-NEXT: i32.const 20
+; DIS-NEXT: memory.init 1, 0
+
+; NOPIC-DIS-NEXT: [[PTR]].const 11060
+; PIC-DIS-NEXT: local.get 0
+
+; DIS-NEXT: i32.const 2
+; DIS-NEXT: i32.atomic.store 0
+
+; NOPIC-DIS-NEXT: [[PTR]].const 11060
+; PIC-DIS-NEXT: local.get 0
+
+; DIS-NEXT: i32.const -1
+; DIS-NEXT: memory.atomic.notify 0
+; DIS-NEXT: drop
+; DIS-NEXT: br 1 # 1: down to label1
+; DIS-NEXT: end
+
+; NOPIC-DIS-NEXT: [[PTR]].const 11060
+; PIC-DIS-NEXT: local.get 0
+
+; DIS-NEXT: i32.const 1
+; DIS-NEXT: i64.const -1
+; DIS-NEXT: memory.atomic.wait32 0
+; DIS-NEXT: drop
+; DIS-NEXT: end
+; DIS-NEXT: data.drop 0
+; DIS-NEXT: data.drop 1
+; DIS-NEXT: end
More information about the llvm-commits
mailing list