Open c1ed623a-df99-497b-81ca-bca6dae737a4 opened 6 years ago
What Reid said sounds about right.
Another thing we could do/check is that the parameter DILocalVariables end up in the "retainedNodes" list associated with the DISubprogram. So the function type is correct even if no locations are identified inside the function.
We emit debug info for parameters during CodeGenFunction::EmitFunctionProlog, and marking a function naked prevents prologue emission, as expected.
To fix it, we'd need to emit llvm.dbg.value intrinsics instead of llvm.dbg.declare intrinsics, since all we have are SSA registers to talk about, no allocas. We'd need to call DIBuilder::insertDbgValueIntrinsic.
Extended Description
Source file:
extern "C" void naked_function(int value, char name); extern "C" void regular_function(int value, char name);
void attribute((naked, noinline)) naked_function(int value, char* name) { }
void regular_function(int value, char* name) { }
Command line: clang++ -g --shared -fPIC -o libtest.so src.cc
Result: $ readelf -wi libtest.so Contents of the .debug_info section:
Compilation Unit @ offset 0x0: Length: 0x81 (32-bit) Version: 4 Abbrev Offset: 0x0 Pointer Size: 8
<0>: Abbrev Number: 1 (DW_TAG_compile_unit)