117 lines · plain
1; REQUIRES: webassembly-registered-target2 3; Test case 5 - Incorrect lexical scope variable.4 5; pr-43860.cpp6; 1 #include "definitions.h"7; 2 forceinline int InlineFunction(int Param) {8; 3 int Var_1 = Param;9; 4 {10; 5 int Var_2 = Param + Var_1;11; 6 Var_1 = Var_2;12; 7 }13; 8 return Var_1;14; 9 }15; 1016; 11 int test(int Param_1, int Param_2) {17; 12 int A = Param_1;18; 13 A += InlineFunction(Param_2);19; 14 return A;20; 15 }21 22; The above test is used to illustrate a variable issue found in the23; Clang compiler.24; PR43860: https://bugs.llvm.org/show_bug.cgi?id=4386025; PR43205: https://github.com/llvm/llvm-project/issues/4320526 27; In the following logical views, we can see that the DWARF debug28; information generated by the Clang compiler shows the variables29; 'Var_1' and 'Var_2' are at the same lexical scope (4) in the function30; 'InlineFuction'.31; The DWARF generated by GCC/Clang show those variables at the correct32; lexical scope: '3' and '4' respectively.33 34; RUN: llvm-mc -arch=wasm32 -filetype=obj \35; RUN: %p/Inputs/pr-43860-clang.s -o %t.pr-43860-clang.o36 37; RUN: llvm-debuginfo-analyzer --attribute=language,level,format,producer \38; RUN: --output-sort=name \39; RUN: --print=symbols \40; RUN: %t.pr-43860-clang.o \41; RUN: %p/../DWARF/Inputs/pr-43860-dwarf-gcc.o 2>&1 | \42; RUN: FileCheck --strict-whitespace -check-prefix=ONE %s43 44; ONE: Logical View:45; ONE-NEXT: [000] {File} '{{.*}}pr-43860-clang.o' -> WASM46; ONE-EMPTY:47; ONE-NEXT: [001] {CompileUnit} 'pr-43860.cpp'48; ONE-NEXT: [002] {Producer} 'clang version 19{{.*}}'49; ONE-NEXT: [002] {Language} 'DW_LANG_C_plus_plus_14'50; ONE-NEXT: [002] 2 {Function} extern inlined 'InlineFunction' -> 'int'51; ONE-NEXT: [003] {Block}52; ONE-NEXT: [004] 5 {Variable} 'Var_2' -> 'int'53; ONE-NEXT: [003] 2 {Parameter} 'Param' -> 'int'54; ONE-NEXT: [003] 3 {Variable} 'Var_1' -> 'int'55; ONE-NEXT: [002] 11 {Function} extern not_inlined 'test' -> 'int'56; ONE-NEXT: [003] 12 {Variable} 'A' -> 'int'57; ONE-NEXT: [003] 13 {InlinedFunction} inlined 'InlineFunction' -> 'int'58; ONE-NEXT: [004] {Block}59; ONE-NEXT: [005] {Variable} 'Var_2' -> 'int'60; ONE-NEXT: [004] {Parameter} 'Param' -> 'int'61; ONE-NEXT: [004] {Variable} 'Var_1' -> 'int'62; ONE-NEXT: [003] 11 {Parameter} 'Param_1' -> 'int'63; ONE-NEXT: [003] 11 {Parameter} 'Param_2' -> 'int'64; ONE-EMPTY:65; ONE-NEXT: Logical View:66; ONE-NEXT: [000] {File} 'pr-43860-dwarf-gcc.o' -> elf64-x86-6467; ONE-EMPTY:68; ONE-NEXT: [001] {CompileUnit} 'pr-43860.cpp'69; ONE-NEXT: [002] {Producer} 'GNU C++14 10.3.0 {{.*}}'70; ONE-NEXT: [002] {Language} 'DW_LANG_C_plus_plus'71; ONE-NEXT: [002] 2 {Function} extern declared_inlined 'InlineFunction' -> 'int'72; ONE-NEXT: [003] {Block}73; ONE-NEXT: [004] 5 {Variable} 'Var_2' -> 'int'74; ONE-NEXT: [003] 2 {Parameter} 'Param' -> 'int'75; ONE-NEXT: [003] 3 {Variable} 'Var_1' -> 'int'76; ONE-NEXT: [002] 11 {Function} extern not_inlined 'test' -> 'int'77; ONE-NEXT: [003] 12 {Variable} 'A' -> 'int'78; ONE-NEXT: [003] 13 {InlinedFunction} declared_inlined 'InlineFunction' -> 'int'79; ONE-NEXT: [004] {Block}80; ONE-NEXT: [005] {Variable} 'Var_2' -> 'int'81; ONE-NEXT: [004] {Parameter} 'Param' -> 'int'82; ONE-NEXT: [004] {Variable} 'Var_1' -> 'int'83; ONE-NEXT: [003] 11 {Parameter} 'Param_1' -> 'int'84; ONE-NEXT: [003] 11 {Parameter} 'Param_2' -> 'int'85 86; Using the selection facilities, we can produce a simple tabular output87; showing just the logical elements that have in their name the 'var'88; pattern. The logical view is sorted by the variables name.89 90; RUN: llvm-debuginfo-analyzer --attribute=level,format \91; RUN: --output-sort=name \92; RUN: --select-regex --select-nocase \93; RUN: --select=Var \94; RUN: --report=list \95; RUN: --print=symbols \96; RUN: %t.pr-43860-clang.o \97; RUN: %p/../DWARF/Inputs/pr-43860-dwarf-gcc.o 2>&1 | \98; RUN: FileCheck --strict-whitespace -check-prefix=TWO %s99 100; TWO: Logical View:101; TWO-NEXT: [000] {File} '{{.*}}pr-43860-clang.o' -> WASM102; TWO-EMPTY:103; TWO-NEXT: [001] {CompileUnit} 'pr-43860.cpp'104; TWO-NEXT: [004] {Variable} 'Var_1' -> 'int'105; TWO-NEXT: [003] 3 {Variable} 'Var_1' -> 'int'106; TWO-NEXT: [005] {Variable} 'Var_2' -> 'int'107; TWO-NEXT: [004] 5 {Variable} 'Var_2' -> 'int'108; TWO-EMPTY:109; TWO-NEXT: Logical View:110; TWO-NEXT: [000] {File} 'pr-43860-dwarf-gcc.o' -> elf64-x86-64111; TWO-EMPTY:112; TWO-NEXT: [001] {CompileUnit} 'pr-43860.cpp'113; TWO-NEXT: [004] {Variable} 'Var_1' -> 'int'114; TWO-NEXT: [003] 3 {Variable} 'Var_1' -> 'int'115; TWO-NEXT: [005] {Variable} 'Var_2' -> 'int'116; TWO-NEXT: [004] 5 {Variable} 'Var_2' -> 'int'117