llvm/llvm/test/tools/llvm-debuginfo-analyzer/WebAssembly/06-wasm-full-logical-view.test

; REQUIRES: webassembly-registered-target

; Test case 6 - Full logical view

; test.cpp
;  1  using INTPTR = const int *;
;  2  int foo(INTPTR ParamPtr, unsigned ParamUnsigned, bool ParamBool) {
;  3    if (ParamBool) {
;  4      typedef int INTEGER;
;  5      const INTEGER CONSTANT = 7;
;  6      return CONSTANT;
;  7    }
;  8    return ParamUnsigned;
;  9  }

; Print low level details.
; The following command prints low level information that includes
; offsets within the debug information section, debug location
; operands, linkage names, etc.

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

; RUN: llvm-debuginfo-analyzer --attribute=all \
; RUN:                         --print=all \
; RUN:                         %t.test-clang.o 2>&1 | \
; RUN: FileCheck --strict-whitespace -check-prefix=ONE %s

; ONE:      Logical View:
; ONE-NEXT: [0x0000000000][000]            {File} '{{.*}}test-clang.o' -> WASM
; ONE-EMPTY:
; ONE-NEXT: [0x000000000b][001]              {CompileUnit} 'test.cpp'
; ONE-NEXT: [0x000000000b][002]                {Producer} 'clang version 19{{.*}}'
; ONE-NEXT:                                    {Directory} '{{.*}}/general'
; ONE-NEXT:                                    {File} 'test.cpp'
; ONE-NEXT:                                    {Public} 'foo' [0x0000000002:0x000000007f]
; ONE-NEXT: [0x000000000b][002]                {Range} Lines 2:9 [0x0000000002:0x000000007f]
; ONE-NEXT: [0x00000000b3][002]                {BaseType} 'bool'
; ONE-NEXT: [0x0000000090][002]                {BaseType} 'int'
; ONE-NEXT: [0x00000000ac][002]                {BaseType} 'unsigned int'
; ONE-EMPTY:
; ONE-NEXT: [0x0000000097][002]   {Source} '{{.*}}general/test.cpp'
; ONE-NEXT: [0x0000000097][002]      1         {TypeAlias} 'INTPTR' -> [0x00000000a2]'* const int'
; ONE-NEXT: [0x0000000026][002]      2         {Function} extern not_inlined 'foo' -> [0x0000000090]'int'
; ONE-NEXT: [0x0000000026][003]                  {Range} Lines 2:9 [0x0000000002:0x000000007f]
; ONE-NEXT: [0x0000000026][003]                  {Linkage}  0x3 '_Z3fooPKijb'
; ONE-NEXT: [0x000000006c][003]                  {Block}
; ONE-NEXT: [0x000000006c][004]                    {Range} Lines 5:0 [0x000000004c:0x0000000064]
; ONE-NEXT: [0x0000000075][004]      5             {Variable} 'CONSTANT' -> [0x00000000ba]'const INTEGER'
; ONE-NEXT: [0x0000000075][005]                      {Coverage} 100.00%
; ONE-NEXT: [0x0000000076][005]                      {Location}
; ONE-NEXT: [0x0000000076][006]                        {Entry} fbreg 12
; ONE-NEXT: [0x000000004c][004]      5             {Line} {NewStatement} '{{.*}}/general/test.cpp'
; ONE-NEXT: [0x000000004c][004]                    {Code} 'i32.const	7'
; ONE-NEXT: [0x000000004e][004]                    {Code} 'local.set	10'
; ONE-NEXT: [0x0000000050][004]                    {Code} 'local.get	5'
; ONE-NEXT: [0x0000000052][004]                    {Code} 'local.get	10'
; ONE-NEXT: [0x0000000054][004]                    {Code} 'i32.store	12'
; ONE-NEXT: [0x0000000057][004]      6             {Line} {NewStatement} '{{.*}}/general/test.cpp'
; ONE-NEXT: [0x0000000057][004]                    {Code} 'i32.const	7'
; ONE-NEXT: [0x0000000059][004]                    {Code} 'local.set	11'
; ONE-NEXT: [0x000000005b][004]                    {Code} 'local.get	5'
; ONE-NEXT: [0x000000005d][004]                    {Code} 'local.get	11'
; ONE-NEXT: [0x000000005f][004]                    {Code} 'i32.store	28'
; ONE-NEXT: [0x0000000062][004]                    {Code} 'br      	1'
; ONE-NEXT: [0x0000000064][004]      0             {Line} '{{.*}}/general/test.cpp'
; ONE-NEXT: [0x0000000064][004]                    {Code} 'end'
; ONE-NEXT: [0x000000005e][003]      2           {Parameter} 'ParamBool' -> [0x00000000b3]'bool'
; ONE-NEXT: [0x000000005e][004]                    {Coverage} 100.00%
; ONE-NEXT: [0x000000005f][004]                    {Location}
; ONE-NEXT: [0x000000005f][005]                      {Entry} fbreg 19
; ONE-NEXT: [0x0000000042][003]      2           {Parameter} 'ParamPtr' -> [0x0000000097]'INTPTR'
; ONE-NEXT: [0x0000000042][004]                    {Coverage} 100.00%
; ONE-NEXT: [0x0000000043][004]                    {Location}
; ONE-NEXT: [0x0000000043][005]                      {Entry} fbreg 24
; ONE-NEXT: [0x0000000050][003]      2           {Parameter} 'ParamUnsigned' -> [0x00000000ac]'unsigned int'
; ONE-NEXT: [0x0000000050][004]                    {Coverage} 100.00%
; ONE-NEXT: [0x0000000051][004]                    {Location}
; ONE-NEXT: [0x0000000051][005]                      {Entry} fbreg 20
; ONE-NEXT: [0x0000000084][003]      4           {TypeAlias} 'INTEGER' -> [0x0000000090]'int'
; ONE-NEXT: [0x0000000002][003]      2           {Line} {NewStatement} '{{.*}}/general/test.cpp'
; ONE-NEXT: [0x0000000002][003]                  {Code} 'nop'
; ONE-NEXT: [0x0000000003][003]                  {Code} 'end'
; ONE-NEXT: [0x0000000004][003]                  {Code} 'i64.div_s'
; ONE-NEXT: [0x0000000005][003]                  {Code} 'global.get	0'
; ONE-NEXT: [0x000000000b][003]                  {Code} 'local.set	3'
; ONE-NEXT: [0x000000000d][003]                  {Code} 'i32.const	32'
; ONE-NEXT: [0x000000000f][003]                  {Code} 'local.set	4'
; ONE-NEXT: [0x0000000011][003]                  {Code} 'local.get	3'
; ONE-NEXT: [0x0000000013][003]                  {Code} 'local.get	4'
; ONE-NEXT: [0x0000000015][003]                  {Code} 'i32.sub'
; ONE-NEXT: [0x0000000016][003]                  {Code} 'local.set	5'
; ONE-NEXT: [0x0000000018][003]                  {Code} 'local.get	5'
; ONE-NEXT: [0x000000001a][003]                  {Code} 'local.get	0'
; ONE-NEXT: [0x000000001c][003]                  {Code} 'i32.store	24'
; ONE-NEXT: [0x000000001f][003]                  {Code} 'local.get	5'
; ONE-NEXT: [0x0000000021][003]                  {Code} 'local.get	1'
; ONE-NEXT: [0x0000000023][003]                  {Code} 'i32.store	20'
; ONE-NEXT: [0x0000000026][003]                  {Code} 'local.get	2'
; ONE-NEXT: [0x0000000028][003]                  {Code} 'local.set	6'
; ONE-NEXT: [0x000000002a][003]                  {Code} 'local.get	5'
; ONE-NEXT: [0x000000002c][003]                  {Code} 'local.get	6'
; ONE-NEXT: [0x000000002e][003]                  {Code} 'i32.store8	19'
; ONE-NEXT: [0x0000000031][003]      3           {Line} {NewStatement} {PrologueEnd} '{{.*}}/general/test.cpp'
; ONE-NEXT: [0x0000000031][003]                  {Code} 'local.get	5'
; ONE-NEXT: [0x0000000033][003]                  {Code} 'i32.load8_u	19'
; ONE-NEXT: [0x0000000036][003]                  {Code} 'local.set	7'
; ONE-NEXT: [0x0000000038][003]      3           {Line} '{{.*}}/general/test.cpp'
; ONE-NEXT: [0x0000000038][003]                  {Code} 'i32.const	1'
; ONE-NEXT: [0x000000003a][003]                  {Code} 'local.set	8'
; ONE-NEXT: [0x000000003c][003]                  {Code} 'local.get	7'
; ONE-NEXT: [0x000000003e][003]                  {Code} 'local.get	8'
; ONE-NEXT: [0x0000000040][003]                  {Code} 'i32.and'
; ONE-NEXT: [0x0000000041][003]                  {Code} 'local.set	9'
; ONE-NEXT: [0x0000000043][003]                  {Code} 'block'
; ONE-NEXT: [0x0000000045][003]                  {Code} 'block'
; ONE-NEXT: [0x0000000047][003]                  {Code} 'local.get	9'
; ONE-NEXT: [0x0000000049][003]                  {Code} 'i32.eqz'
; ONE-NEXT: [0x000000004a][003]                  {Code} 'br_if   	0'
; ONE-NEXT: [0x0000000065][003]      8           {Line} {NewStatement} '{{.*}}/general/test.cpp'
; ONE-NEXT: [0x0000000065][003]                  {Code} 'local.get	5'
; ONE-NEXT: [0x0000000067][003]                  {Code} 'i32.load	20'
; ONE-NEXT: [0x000000006a][003]                  {Code} 'local.set	12'
; ONE-NEXT: [0x000000006c][003]      8           {Line} '{{.*}}/general/test.cpp'
; ONE-NEXT: [0x000000006c][003]                  {Code} 'local.get	5'
; ONE-NEXT: [0x000000006e][003]                  {Code} 'local.get	12'
; ONE-NEXT: [0x0000000070][003]                  {Code} 'i32.store	28'
; ONE-NEXT: [0x0000000073][003]      0           {Line} '{{.*}}/general/test.cpp'
; ONE-NEXT: [0x0000000073][003]                  {Code} 'end'
; ONE-NEXT: [0x0000000074][003]      9           {Line} {NewStatement} '{{.*}}/general/test.cpp'
; ONE-NEXT: [0x0000000074][003]                  {Code} 'local.get	5'
; ONE-NEXT: [0x0000000076][003]                  {Code} 'i32.load	28'
; ONE-NEXT: [0x0000000079][003]                  {Code} 'local.set	13'
; ONE-NEXT: [0x000000007b][003]                  {Code} 'local.get	13'
; ONE-NEXT: [0x000000007d][003]                  {Code} 'return'
; ONE-NEXT: [0x000000007e][003]                  {Code} 'end'
; ONE-NEXT: [0x000000007f][003]      9           {Line} {NewStatement} {EndSequence} '{{.*}}/general/test.cpp'
; ONE-NEXT: [0x000000007f][003]                  {Code} 'unreachable'
; ONE-EMPTY:
; ONE-NEXT: -----------------------------
; ONE-NEXT: Element      Total    Printed
; ONE-NEXT: -----------------------------
; ONE-NEXT: Scopes           3          3
; ONE-NEXT: Symbols          4          4
; ONE-NEXT: Types            5          5
; ONE-NEXT: Lines           73         73
; ONE-NEXT: -----------------------------
; ONE-NEXT: Total           85         85
; ONE-EMPTY:
; ONE-NEXT: Scope Sizes:
; ONE-NEXT:        180 (100.00%) : [0x000000000b][001]              {CompileUnit} 'test.cpp'
; ONE-NEXT:        105 ( 58.33%) : [0x0000000026][002]      2         {Function} extern not_inlined 'foo' -> [0x0000000090]'int'
; ONE-NEXT:         23 ( 12.78%) : [0x000000006c][003]                  {Block}
; ONE-EMPTY:
; ONE-NEXT: Totals by lexical level:
; ONE-NEXT: [001]:        180 (100.00%)
; ONE-NEXT: [002]:        105 ( 58.33%)
; ONE-NEXT: [003]:         23 ( 12.78%)