[llvm-dev] Deleting function IR after codegen

Pete Cooper via llvm-dev llvm-dev at lists.llvm.org
Thu Mar 10 17:33:44 PST 2016


> On Mar 8, 2016, at 11:50 AM, Eric Christopher <echristo at gmail.com> wrote:
> 
> 
> 
> 
> I could attach a patch, but first i’d really like to know if anyone is fundamentally opposed to this.
> 
> 
> Not necessarily. I think that any information that isn't being serialized in MI right now for a function could be as well. Definitely something for GlobalISel to keep in mind.
Probably even depends on the kind of AA.  TBAA is likely mostly useable without instructions around (you could reference the TBAA from the MIs themselves), but I guess BasicAA is still introspecting the instructions enough to make it harder to migrate.
>  
> I should note, a couple of issues have come up in the prototype.
> - llvm::getDISubprogram was walking the function body to find the subprogram.  This is trivial to fix as functions now have !dbg on them.
> 
> This is definitely worth it, please go ahead and do this.
Will do.  Thanks.
>  
> - The AsmPrinter is calling canBeOmittedFromSymbolTable on GlobalValue’s which then walks all their uses.  I think this should be done earlier in codegen as an analysis whose results are available to the AsmPrinter.
> 
> I think this makes sense, but I worry about late added GlobalValues during code gen?
The code which walks them is looking for an ICmpInst with the global on one side.  Basically wants to know if the address is interesting.  Globals added from selection DAG onwards likely won’t have an IR instruction added to compare them, although if for some reason someone added a global and materialized the compare directly in MIs then I guess the current code would be incorrect.
> How would we cope with that? Example: Let's say we start lowering a target specific construct as an MI pass etc and it constructs a global value, when do we run the analysis to make sure that all such things happen? Late as possible I'd assume. Maybe this isn't an issue, but thought I'd bring it up. At any rate, could you provide a bit more detail here?
It does sound like this is going to be tricky.  I was hoping to run this as a Module pass prior to starting the codegen function passes, but there’s nothing to stop CodeGenPrepare from adding a compare to a function, after when I was hoping to run the analysis.  I’ll need to mull this over.
> 
> - BB’s whose addresses are taken, i.e. jump tables, can’t be deleted.  Those functions will just keep their IR around so no changes there.
> 
> 
> Oh well. Conveniently there aren't a lot of these.
Yeah, not ideal, but hopefully not too bad either.

Pete
> 
> -eric
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160310/967d3e2a/attachment.html>


More information about the llvm-dev mailing list