[llvm] [StaticDataLayout][MemProf] Record whether the IR is compiled with data access profiles by module flag. (PR #162333)
Mingming Liu via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 7 13:00:51 PDT 2025
================
@@ -798,13 +798,15 @@ bool MemProfUsePass::annotateGlobalVariables(
return false;
if (!DataAccessProf) {
+ M.addModuleFlag(Module::Warning, "EnableDataAccessProf", 0U);
----------------
mingmingl-llvm wrote:
> What if the function doesn't have any variables that get data access profiles? I assume we have an non-missing but empty DataAccessProfiles section so we wouldn't come in here?
The data access profile payload is generated per binary and parsed as a whole in an optimizer pass. There are no selective parsing logic that filters the payload based on the module IR.
So there are basically three cases
1) If `memprof-annotate-static-data-prefix` is false or if the module doesn't have global variables, the module won't have module flag (due to early return at line 797)
2) If 1) is not met and the payload is empty in the memprof file, the condition at line 800 is true and module flag is zero.
3) if 2) is not met (i.e., payload is not empty), the module will have module flag as one.
On the module flag user side, it regards case 3 as 'the module is compiled with data access profile' and treats empty section prefix as unknown, and regards the other two cases as 'the module isn't compiled with data access profiles' and override empty section prefix if needed.
I wonder if it's clearer to combine 1) and 2) so the module flag is always present as long as this pass runs.
https://github.com/llvm/llvm-project/pull/162333
More information about the llvm-commits
mailing list