Emit a value debug intrinsic (with OP_deref) when an alloca address is
passed to a function call after going through a bitcast.
This generates an FP or SP-relative location for the local variable in
the following case:
int x; use((void *)&x;
Differential D70752
LowerDbgDeclare: look through bitcasts. eugenis on Nov 26 2019, 4:38 PM. Authored by
Details
Emit a value debug intrinsic (with OP_deref) when an alloca address is This generates an FP or SP-relative location for the local variable in int x; use((void *)&x;
Diff Detail
Event Timeline
Comment Actions I also find worklist a more common and recognizable pattern, but I don't mind recursion either. Btw, this function terribly incomplete. This is not the only case when it destroys perfectly good debug info. For example, storing an address of a local variable to memory does not generate a dbg.value. In the following example "y" has no location at -O3: int *p; void publish_and_wait(); void f() { int y; p = &y; publish_and_wait(); } I'm looking at this because HWASan tries to use debug info to recover stack frame layout at run time. This works as long as we get at least one frame pointer based location for a non-promoted variable. I'm considering disabling this optimization altogether in functions with sanitize_hwaddress attribute; or maybe adding a dbg.value with DW_OP_deref to all allocas in such functions.
Comment Actions It's not that the worklist is terribly complicated to understand either, but when I see a worklist I'm expecting a tricky algorithm that couldn't be implemented with recursion and then need to stop and spend some time that it's really doing something simple. Not a big deal though. In the grand scheme of things both approaches are fine. The recursion has the advantage that we can give the helper function a descriptive name. Comment Actions I don't have a strong opinion either way, but since we seem to have 2-1 in favor of the worklist I'll leave it as is. I've updated the test case to include two bitcasts of the same alloca.
|
I think the worklist is overkill here, since it will contain at most one element. How about turning the loop body into a helper function/lambda and calling it recursively?