[PATCH] D35994: Debug info for variables whos type is shrinked to bool

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 1 07:47:56 PDT 2017


On Tue, Aug 1, 2017 at 12:39 AM Nikola Prica via Phabricator <
reviews at reviews.llvm.org> wrote:

> NikolaPrica added inline comments.
>
>
> ================
> Comment at: lib/Transforms/IPO/GlobalOpt.cpp:1577
> +  for(auto *GV : GVs)
> +    NewGV->addDebugInfo(GV);
> +
> ----------------
> aprantl wrote:
> > I'm not familiar with this transformation: Do we need to add a
> DIExpression to mask out all but the first bit (i.e. can multiple bools be
> packed into the same uint32_t such that it could confuse debuggers)?
> The debug info which is provided here with addDebugInfo later generates
> address of the variable (DW_OP_addr: xxxx) in DW_AT_location. If we provide
> here metadata which is for 1byte variable  the debugger would get confused
> because the enum type is written as 4-byte and he would try to read 4
> bytes. This is just temporary fix until proper way to handle this is found.
>

How does the compiler know the other 3 bytes won't be used when it's
performing this optimization? Based on the fact that they've not been
observed by the code, so aren't needed? Then they could hold any values?

Sounds like that's the right thing, then - to describe this as Adrian was
suggesting, that we should be using a DIExpression to mask out the high
bits (or specifically/said differently, describing this byte as a fragment
of the larger variable). Yeah, it means we don't know what the rest of the
bytes are, and a debugger might not print the enum value (because it only
knows a quarter of the bits), but that's still probably the right thing...

(I'd be somewhat OK handling that in a follow-up commit, but I'll leave
that call up to Adrian either way)

- Dave


>
>
> https://reviews.llvm.org/D35994
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170801/7d0eb254/attachment.html>


More information about the llvm-commits mailing list