This is an archive of the discontinued LLVM Phabricator instance.

[nfc][thinlto] Handle global constant importing separately
ClosedPublic

Authored by mtrofin on Apr 26 2023, 2:43 PM.

Details

Summary

This makes the logic for referenced globals reusable for import criteria
that don't use thresholds - in fact, we currently didn't consider any
thresholds when importing.

Diff Detail

Event Timeline

mtrofin created this revision.Apr 26 2023, 2:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 26 2023, 2:43 PM
mtrofin requested review of this revision.Apr 26 2023, 2:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 26 2023, 2:43 PM
tejohnson added inline comments.Apr 27 2023, 8:06 AM
llvm/lib/Transforms/IPO/FunctionImport.cpp
259

Can we make this a member of GlobalsImporter to avoid having to pass in DefinedGVSummaries and isPrevailing?

283

Can you add a brief description in comment for class?

305

Some comments as to why we are doing this in the destructor would be helpful. But would it be clearer to just do this greedily from onImportingSummary? In fact, in that case we wouldn't even need a Worklist - onImportingSummary can just call itself recursively.

331

Nit: I think per LLVM coding standards the outer for and if should also have braces since the innermost if statement is nontrivial and has braces. It would improve readability imo.

332

Nit: prefer early continue if !GVS to avoid extra level of nesting. It might be nice to add a comment there about how we don't currently perform importing of any functions referenced by global variables (e.g. virtual functions in vtables). I suppose if we wanted to handle those in the future, we could arrange for this to return a set of those functions.

mtrofin updated this revision to Diff 517651.Apr 27 2023, 11:09 AM
mtrofin marked 5 inline comments as done.

feedback

mtrofin added inline comments.Apr 27 2023, 11:13 AM
llvm/lib/Transforms/IPO/FunctionImport.cpp
305

Done, w/o recursion

This revision is now accepted and ready to land.Apr 27 2023, 11:22 AM