[llvm] [ThinLTO]Record import type in GlobalValueSummary::GVFlags (PR #87597)

Mingming Liu via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 9 10:28:17 PDT 2024


================
@@ -737,6 +737,7 @@ lltok::Kind LLLexer::LexIdentifier() {
   KEYWORD(live);
   KEYWORD(dsoLocal);
   KEYWORD(canAutoHide);
+  KEYWORD(importAsDec);
----------------
minglotus-6 wrote:

> Trying to understand the mechanics of how a "summary" import works before we reserve a flag bit for that case. Couldn't we just mark it as a declaration import which would essentially be a no-op if a declaration/def already exists in the module?

Previously I thought reserving one bit is necessary for postlink to tell one of three scenarios from {definition, declaration, summary}. However now after f2f discussion I think one-bit (just marking one of {definition, declaration}) should work.

To summarize our discussion, one-bit approach works for summary import in a selective manner.

1. The GVFlags could reserve one-bit for ImportType, and making it just declaration or definition.
2. In the indexing step, 'ComputeImportForModule' creates an entry for declaration (when definition import is too costly, etc) if call-graph needs it, or when interesting attributes exists.
3. The postlink optimizer sees IR and combined summary. If definition or declaration is already in the module (which is the case except for indirect callee, since IR verifier requests direct-callee should at least have a declaration), `FunctionImporter` could just read interesting attributes from the summary and set it on the function (def or decl). For the set of summaries without a function (the case for indirect callee for better call-graph sort),  IRMover will be updated in a subsequent patch to import the declaration. 
   * I prototyped the IRMover change. The regression test [shows](https://github.com/llvm/llvm-project/compare/main...minglotus-6:llvm-project:irlinker#diff-5c849764b0a8c2eb1062dc219405316161e757745b67f7aa31f101d0cdca5ed0R32-R34) large indirect callee declaration is imported along with attributes. 

I'm going to update this PR to use one-bit approach.

https://github.com/llvm/llvm-project/pull/87597


More information about the llvm-commits mailing list