Jaydeep Chauhan via llvm-dev
2020-Feb-12 20:24 UTC
[llvm-dev] Wrong Debuginfo generated for global variable with target bpf
Hi All, Please consider below test case for discussion $cat global.h extern int gvar; $ cat p1.c #include "global.h" int gvar=11; int foo() { return gvar; } $./clang p1.c -g -O0 -target bpf -c ... ... 0x0000002a: DW_TAG_variable DW_AT_name ("gvar") DW_AT_type (0x0000003f "int") DW_AT_external (true) DW_AT_decl_file ("/home/llvm-project/build/bin/p1.c") DW_AT_decl_line (2) DW_AT_location (DW_OP_addr 0x0) 0x0000003f: DW_TAG_base_type DW_AT_name ("int") DW_AT_encoding (DW_ATE_signed) DW_AT_byte_size (0x04) 0x00000046: DW_TAG_variable DW_AT_name ("gvar") DW_AT_type (0x0000003f "int") DW_AT_external (true) DW_AT_decl_file ("/home/llvm-project/build/bin/./global.h") DW_AT_decl_line (1) DW_AT_declaration (true) DW_AT_location (DW_OP_addr 0x0) ... ... In above test case for variable "gvar" debuginfo is created twice. Look like it is considering variable "gvar" of source file and header file variable different.Also for second time in "gvar" debuginfo declaration as well as location attributes is there. This is happen with for target bpf only.And this behavior is may be because of https://reviews.llvm.org/D70696#1774931 this changes. Please devs share your valuable suggestion/thoughts on this. Thanks, Jaydeep.