When no debug information is emitted there is no point in emitting a hack introduced in D63361.
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Event Timeline
We try to uphold the invariant that -g flags do not affect generated code, so I don't think we should do this.
Even under -O0? I could change the check to always emit on -O0. With optimizations enabled there is no change in generated code, DSE+DCE removes it anyway.
Is this hack actually needed? I could not reproduce a problem with https://bugs.chromium.org/p/chromium/issues/detail?id=860398#c13 repro, the breakpoint fires for me and I see the variable.
The difference with the hack and without, using clang.exe src.cpp -S -masm=intel -O2 -g -o out.asm is
diff --- +++ @@ -26,10 +26,10 @@ .seh_stackalloc 32 .seh_endprologue .Ltmp0: - #DEBUG_VALUE: test0:x <- [DW_OP_deref] $rcx + #DEBUG_VALUE: test0:x <- [$rcx+0] mov rsi, rcx .Ltmp1: - #DEBUG_VALUE: test0:x <- [DW_OP_deref] $rsi + #DEBUG_VALUE: test0:x <- [$rsi+0] .cv_loc 0 1 9 0 # nrvox.cpp:9:0 call "??0X@@QEAA@XZ" .cv_loc 0 1 10 0 # nrvox.cpp:10:0
You enabled optimizations, so I wouldn't expect there to be any difference. The main purpose of taking the sret pointer and storing it into a local alloca is to make it easier to find in unoptimized builds. Otherwise we have this variable value living in the first register parameter, and at the time, the backend would quickly lose track of it. It's always safer to anchor your variable location info in memory.