[llvm] [PGO] Preserve analysis results when nothing was instrumented (PR #93421)

Pavel Samolysov via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 16 00:54:48 PDT 2024


samolisov wrote:

@mikaelholmen Thank you very much! I've added the flag and now can reproduce the issue.

@teresajohnson @aeubanks Could you help? I opened [the second PR](https://github.com/llvm/llvm-project/pull/93917) to create the `$__llvm_profile_raw_version` and `@__llvm_profile_raw_version` variables **only** when there were actually generated instructions to instrument the module. But currently I saw a "chicken-egg" problem: even though the module was not instrumented, the preamble:

```
$__llvm_profile_raw_version = comdat any

@__llvm_profile_raw_version = hidden constant i64 72057594037927946, comdat
```

is still generated and this changes the hash of the module what leads to error emission in the *PassManager*:

```
...
#11 0x0000556e634bf56e void llvm::PassInstrumentation::runAfterPass<llvm::Module, llvm::detail::PassConcept<llvm::Module, llvm::AnalysisManager<llvm::Module>>>(llvm::detail::PassConcept<llvm::Module, llvm::AnalysisManager<llvm::Module>> const&, llvm::Module const&, llvm::PreservedAnalyses const&) const
#12 0x0000556e634bc555 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&)
#13 0x0000556e5f196d9d llvm::runPassPipeline
...
```

I see the following two ways: either to combine both patches into one or just to revert the current changes (what has already been done) to not brake the pipelines. So, I think we may discuss the changed focusing on whether the global variable `__llvm_profile_raw_version` should be generated in any way or only when the module has actually been modified?

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


More information about the llvm-commits mailing list