[llvm-dev] DebugInfo: Global variable expression management

Adrian Prantl via llvm-dev llvm-dev at lists.llvm.org
Wed Dec 5 16:25:04 PST 2018



> On Dec 5, 2018, at 4:20 PM, David Blaikie <dblaikie at gmail.com> wrote:
> 
> 
> Fair, I suppose today if an optimization pass deletes a GlobalVariable, the result is that the debug info still describes the global variable - but without any value. (this is inconsistent, though technically better, than we do with functions - which, if totally deleted, aren't emitted at all - but they track through inlining more than a global variable does, so it's not a perfect comparison) - whereas if we avoided having them in the globals() list, we'd /have/ to update that list, even in cases where the optimization didn't have anything useful to say about the value of the global (eg: "hey, this global has lots of different values throughout its lifetime, but none of them are used, I'm going to delete it" - today, it just deletes it and the debug info is correct. But with this change, it'd have to go wire in a null description to ensure the variable wasn't lost entirely)
> 
> 
>  
> That is messy and may subtly break some assumptions that I haven't thought about yet. Outside of DIBuilder we get through the entire compiler without modifying any MDNodes.
> 
> I guess we only create new ones when it comes to creating complicated dwarf location descriptions/expressions as optimizations change local variables around? So not modification in that case?

Correct. The most common thing we do in the optimizer is to create a new, uniqued, more complex DIExpression and emit a new call @llvm.dbg.value to tie that DIExpression to a DILocalVariable in the instruction stream.

>  
> That said, DICompileUnit is distinct so calling replaceGlobals() on it is probably safe.
> 
> What would the primary benefit of making this change be?
> 
> Oh, just noticed as an aside while I was filing the aforementioned bugs - struck me as weird that they were connected in two places is all. No major thing I can think of.

That's fair.

-- adrian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20181205/38f6f474/attachment.html>


More information about the llvm-dev mailing list