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

Mingming Liu via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 8 11:23:28 PDT 2024


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

>  Otherwise, always importing the fallback would be too much (from Mingming's measurements)

To add some details, I printed the number of `ImportList` map entries after [computeImportForModule](https://github.com/llvm/llvm-project/blob/93e2a9ab1b28e1b89d30b89dc2d5bb6f8cc66dc9/llvm/lib/Transforms/IPO/FunctionImport.cpp#L1005C10-L1005C32) in two settings
1) The default ThinLTO + FDO build
2) The same option as 1, plus adding {noinline, too-large} callee (marking it as declaration type) into the `ImportList` map.

The ratio of map entry is 1 : 2.5, meaning the fallback approach will increase the memory usage of indexing step and eat up a lot of resources. 

Thereby selective import approach is chosen
1. For more complete call-graph, module-summary-analysis pass can retrieve the set of callees from `!prof` metadata
2. To know the function attributes of function declarations (which may not exist on a function declaration but exist on function definitions), a subset of interesting attributes will be serialized in the per-module IR. Postlink pipeline can read the summary and set the function attributes.


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


More information about the llvm-commits mailing list