[lld] feddf11 - [lld][WebAssemlby] Convert test to check disassembly output. NFC

Sam Clegg via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 20 09:32:08 PST 2022


Author: Sam Clegg
Date: 2022-01-20T09:32:01-08:00
New Revision: feddf1150227eb43500106cfd6cf01456f2b87e4

URL: https://github.com/llvm/llvm-project/commit/feddf1150227eb43500106cfd6cf01456f2b87e4
DIFF: https://github.com/llvm/llvm-project/commit/feddf1150227eb43500106cfd6cf01456f2b87e4.diff

LOG: [lld][WebAssemlby] Convert test to check disassembly output. NFC

Differential Revision: https://reviews.llvm.org/D117739

Added: 
    

Modified: 
    lld/test/wasm/shared.s
    lld/test/wasm/shared64.s

Removed: 
    


################################################################################
diff  --git a/lld/test/wasm/shared.s b/lld/test/wasm/shared.s
index 7861485470ffa..01dc8d51474d9 100644
--- a/lld/test/wasm/shared.s
+++ b/lld/test/wasm/shared.s
@@ -1,6 +1,7 @@
 # RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s
 # RUN: wasm-ld --experimental-pic -shared -o %t.wasm %t.o
 # RUN: obj2yaml %t.wasm | FileCheck %s
+# RUN: llvm-objdump --disassemble-symbols=__wasm_call_ctors,__wasm_apply_data_relocs --no-show-raw-insn --no-leading-addr %t.wasm | FileCheck %s --check-prefixes DIS
 
 .functype func_external () -> ()
 
@@ -205,16 +206,46 @@ get_local_func_address:
 # CHECK-NEXT:         Functions:       [ 3, 2 ]
 
 # check the generated code in __wasm_call_ctors and __wasm_apply_data_relocs functions
-# TODO(sbc): Disassemble and verify instructions.
-
-# CHECK:        - Type:            CODE
-# CHECK-NEXT:     Functions:
-# CHECK-NEXT:       - Index:           0
-# CHECK-NEXT:         Locals:          []
-# CHECK-NEXT:         Body:            10010B
-# CHECK-NEXT:       - Index:           1
-# CHECK-NEXT:         Locals:          []
-# CHECK-NEXT:         Body:            230141046A2304360200230141086A230241016A3602002301410C6A230141006A360200230141106A2305360200230141146A230641046A3602000B
+
+# DIS:      <__wasm_call_ctors>:
+# DIS-EMPTY:
+# DIS-NEXT:                 call    1
+# DIS-NEXT:                 end
+
+# DIS:      <__wasm_apply_data_relocs>:
+# DIS-EMPTY:
+# DIS-NEXT:                 global.get      1
+# DIS-NEXT:                 i32.const       4
+# DIS-NEXT:                 i32.add
+# DIS-NEXT:                 global.get      4
+# DIS-NEXT:                 i32.store       0
+# DIS-NEXT:                 global.get      1
+# DIS-NEXT:                 i32.const       8
+# DIS-NEXT:                 i32.add
+# DIS-NEXT:                 global.get      2
+# DIS-NEXT:                 i32.const       1
+# DIS-NEXT:                 i32.add
+# DIS-NEXT:                 i32.store       0
+# DIS-NEXT:                 global.get      1
+# DIS-NEXT:                 i32.const       12
+# DIS-NEXT:                 i32.add
+# DIS-NEXT:                 global.get      1
+# DIS-NEXT:                 i32.const       0
+# DIS-NEXT:                 i32.add
+# DIS-NEXT:                 i32.store       0
+# DIS-NEXT:                 global.get      1
+# DIS-NEXT:                 i32.const       16
+# DIS-NEXT:                 i32.add
+# DIS-NEXT:                 global.get      5
+# DIS-NEXT:                 i32.store       0
+# DIS-NEXT:                 global.get      1
+# DIS-NEXT:                 i32.const       20
+# DIS-NEXT:                 i32.add
+# DIS-NEXT:                 global.get      6
+# DIS-NEXT:                 i32.const       4
+# DIS-NEXT:                 i32.add
+# DIS-NEXT:                 i32.store       0
+# DIS-NEXT:                 end
 
 # check the data segment initialized with __memory_base global as offset
 

diff  --git a/lld/test/wasm/shared64.s b/lld/test/wasm/shared64.s
index 86d5a521ab334..080b05213a04a 100644
--- a/lld/test/wasm/shared64.s
+++ b/lld/test/wasm/shared64.s
@@ -1,6 +1,7 @@
 # RUN: llvm-mc -filetype=obj -triple=wasm64-unknown-unknown -o %t.o %s
 # RUN: wasm-ld -mwasm64 --experimental-pic -shared -o %t.wasm %t.o
 # RUN: obj2yaml %t.wasm | FileCheck %s
+# RUN: llvm-objdump --disassemble-symbols=__wasm_call_ctors,__wasm_apply_data_relocs --no-show-raw-insn --no-leading-addr %t.wasm | FileCheck %s --check-prefixes DIS
 
 .functype func_external () -> ()
 
@@ -212,16 +213,46 @@ get_local_func_address:
 # CHECK-NEXT:         Functions:       [ 3, 2 ]
 
 # check the generated code in __wasm_call_ctors and __wasm_apply_data_relocs functions
-# TODO(sbc): Disassemble and verify instructions.
-
-# CHECK:        - Type:            CODE
-# CHECK-NEXT:     Functions:
-# CHECK-NEXT:       - Index:           0
-# CHECK-NEXT:         Locals:          []
-# CHECK-NEXT:         Body:            10010B
-# CHECK-NEXT:       - Index:           1
-# CHECK-NEXT:         Locals:          []
-# CHECK-NEXT:         Body:            230142047C23053702002301420C7C230242017C370200230142147C230141006A360200230142187C2306370200230142207C230741046A3602000B
+
+# DIS:      <__wasm_call_ctors>:
+# DIS-EMPTY:
+# DIS-NEXT:                 call    1
+# DIS-NEXT:                 end
+
+# DIS:      <__wasm_apply_data_relocs>:
+# DIS-EMPTY:
+# DIS-NEXT:                 global.get      1
+# DIS-NEXT:                 i64.const       4
+# DIS-NEXT:                 i64.add
+# DIS-NEXT:                 global.get      5
+# DIS-NEXT:                 i64.store       0:p2align=2
+# DIS-NEXT:                 global.get      1
+# DIS-NEXT:                 i64.const       12
+# DIS-NEXT:                 i64.add
+# DIS-NEXT:                 global.get      2
+# DIS-NEXT:                 i64.const       1
+# DIS-NEXT:                 i64.add
+# DIS-NEXT:                 i64.store       0:p2align=2
+# DIS-NEXT:                 global.get      1
+# DIS-NEXT:                 i64.const       20
+# DIS-NEXT:                 i64.add
+# DIS-NEXT:                 global.get      1
+# DIS-NEXT:                 i32.const       0
+# DIS-NEXT:                 i32.add
+# DIS-NEXT:                 i32.store       0
+# DIS-NEXT:                 global.get      1
+# DIS-NEXT:                 i64.const       24
+# DIS-NEXT:                 i64.add
+# DIS-NEXT:                 global.get      6
+# DIS-NEXT:                 i64.store       0:p2align=2
+# DIS-NEXT:                 global.get      1
+# DIS-NEXT:                 i64.const       32
+# DIS-NEXT:                 i64.add
+# DIS-NEXT:                 global.get      7
+# DIS-NEXT:                 i32.const       4
+# DIS-NEXT:                 i32.add
+# DIS-NEXT:                 i32.store       0
+# DIS-NEXT:                 end
 
 # check the data segment initialized with __memory_base global as offset
 


        


More information about the llvm-commits mailing list