llvm/llvm/test/tools/llvm-debuginfo-analyzer/WebAssembly/02-wasm-logical-lines.test

; REQUIRES: webassembly-registered-target

; Test case 2 - Assembler instructions.

; hello-world.cpp
;  1  extern int printf(const char * format, ... );
;  2
;  3  int main()
;  4  {
;  5    printf("Hello, World\n");
;  6    return 0;
;  7  }

; Logical lines.
; The logical views shows the intermixed lines and assembler instructions,
; allowing to compare the code generated by the different toolchains.

; RUN: llvm-mc -arch=wasm32 -filetype=obj \
; RUN:         %p/Inputs/hello-world-clang.s -o %t.hello-world-clang.o

; RUN: llvm-debuginfo-analyzer --attribute=level,format,producer \
; RUN:                         --print=lines,instructions \
; RUN:                         %t.hello-world-clang.o 2>&1 | \
; RUN: FileCheck --strict-whitespace -check-prefix=ONE %s

; ONE:      Logical View:
; ONE-NEXT: [000]           {File} '{{.*}}hello-world-clang.o' -> WASM
; ONE-EMPTY:
; ONE-NEXT: [001]             {CompileUnit} 'hello-world.cpp'
; ONE-NEXT: [002]               {Producer} 'clang version 19{{.*}}'
; ONE-NEXT: [002]     3         {Function} extern not_inlined 'main' -> 'int'
; ONE-NEXT: [003]     4           {Line}
; ONE-NEXT: [003]                 {Code} 'nop'
; ONE-NEXT: [003]                 {Code} 'rethrow 	127'
; ONE-NEXT: [003]                 {Code} 'global.get	0'
; ONE-NEXT: [003]                 {Code} 'local.set	0'
; ONE-NEXT: [003]                 {Code} 'i32.const	16'
; ONE-NEXT: [003]                 {Code} 'local.set	1'
; ONE-NEXT: [003]                 {Code} 'local.get	0'
; ONE-NEXT: [003]                 {Code} 'local.get	1'
; ONE-NEXT: [003]                 {Code} 'i32.sub'
; ONE-NEXT: [003]                 {Code} 'local.set	2'
; ONE-NEXT: [003]                 {Code} 'local.get	2'
; ONE-NEXT: [003]                 {Code} 'global.set	0'
; ONE-NEXT: [003]                 {Code} 'i32.const	0'
; ONE-NEXT: [003]                 {Code} 'local.set	3'
; ONE-NEXT: [003]                 {Code} 'local.get	2'
; ONE-NEXT: [003]                 {Code} 'local.get	3'
; ONE-NEXT: [003]                 {Code} 'i32.store	12'
; ONE-NEXT: [003]     5           {Line}
; ONE-NEXT: [003]                 {Code} 'i32.const	0'
; ONE-NEXT: [003]                 {Code} 'local.set	4'
; ONE-NEXT: [003]                 {Code} 'i32.const	0'
; ONE-NEXT: [003]                 {Code} 'local.set	5'
; ONE-NEXT: [003]                 {Code} 'local.get	4'
; ONE-NEXT: [003]                 {Code} 'local.get	5'
; ONE-NEXT: [003]                 {Code} 'call	0'
; ONE-NEXT: [003]                 {Code} 'drop'
; ONE-NEXT: [003]     6           {Line}
; ONE-NEXT: [003]                 {Code} 'i32.const	0'
; ONE-NEXT: [003]                 {Code} 'local.set	6'
; ONE-NEXT: [003]                 {Code} 'i32.const	16'
; ONE-NEXT: [003]                 {Code} 'local.set	7'
; ONE-NEXT: [003]                 {Code} 'local.get	2'
; ONE-NEXT: [003]                 {Code} 'local.get	7'
; ONE-NEXT: [003]                 {Code} 'i32.add'
; ONE-NEXT: [003]                 {Code} 'local.set	8'
; ONE-NEXT: [003]                 {Code} 'local.get	8'
; ONE-NEXT: [003]                 {Code} 'global.set	0'
; ONE-NEXT: [003]                 {Code} 'local.get	6'
; ONE-NEXT: [003]                 {Code} 'return'
; ONE-NEXT: [003]                 {Code} 'end'
; ONE-NEXT: [003]     6           {Line}
; ONE-NEXT: [003]                 {Code} 'return'