COFF Debug info shows variable at the wrong lexical scope. · Issue #43205 · llvm/llvm-project (original) (raw)

Bugzilla Link 43860
Version trunk
OS All
CC @dwblaikie,@gregbedwell,@JDevlieghere,@jmorse,@walkerkd,@pogo59,@rnk

Extended Description

Given the following test case:

//------------------------------------------------------------
// inlined.cpp
//------------------------------------------------------------

int inlineFunction(int Param) __attribute__((always_inline));
int inlineFunction(int Param) {
  int Var_1 = Param;
  {
    int Var_2 = Param + Var_1;
    Var_1 = Var_2;
  }
  return Var_1;
}

int testInlined(int Param_1, int Param_2) {
  int A = Param_1;
  A += inlineFunction(Param_2);
  return A;
}

//------------------------------------------------------------

Using the following command line options to generate debug info
(DWARF) and (COFF):

clang -c -g -O0 inlined.cpp -o inlined-dwarf.o
clang -c -g -O0 inlined.cpp -o inlined-coff.o -gcodeview --target=x86_64-windows

Looking at the output generated by llvm-dwarfdump and llvm-readobj,
the COFF debug info shows the variable 'Var_2' at the same lexical
scope as the variable 'Var_1' in the 'testInlined' as results of the
function 'inlineFunction' being inlined.

llvm-dwarfdump --debug-info inlined-dwarf.o