diff options
author | Owen Rodley <orodley@google.com> | 2025-03-31 16:16:35 +1100 |
---|---|---|
committer | Owen Rodley <orodley@google.com> | 2025-08-05 09:54:41 +1000 |
commit | 3da1ceb81c1f17248babf0c0e2c07f23bd6b138b (patch) | |
tree | 03c39df6e5390d3eddcf5efac79f194c622f7a33 /llvm/tools/opt/NewPMDriver.cpp | |
parent | 9b195dc3ef66de2c1ff0048822b24a322ec3c52a (diff) | |
download | llvm-users/orodley/guid-2.zip llvm-users/orodley/guid-2.tar.gz llvm-users/orodley/guid-2.tar.bz2 |
Store GUIDs in metadatausers/orodley/guid-2
See https://discourse.llvm.org/t/rfc-keep-globalvalue-guids-stable/84801
for context.
This takes the existing AssignGUID pass from CtxProfAnalysis, and runs
it by default, at the appropriate stages of the LTO pipeline. It also
changes GlobalValue::getGUID() to retrieve the GUID from the metadata
instead of computing it.
We don't yet have the supporting downstream changes to make a dedicated
GUID table in bitcode, nor do we use the metadata as part of ThinLTO --
it retains its existing mechanisms of recomputing GUIDs from separately
saved data. That will be changed later.
Diffstat (limited to 'llvm/tools/opt/NewPMDriver.cpp')
-rw-r--r-- | llvm/tools/opt/NewPMDriver.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/tools/opt/NewPMDriver.cpp b/llvm/tools/opt/NewPMDriver.cpp index b9b8929..5586969 100644 --- a/llvm/tools/opt/NewPMDriver.cpp +++ b/llvm/tools/opt/NewPMDriver.cpp @@ -39,6 +39,7 @@ #include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h" #include "llvm/Transforms/Instrumentation/AddressSanitizer.h" #include "llvm/Transforms/Scalar/LoopPassManager.h" +#include "llvm/Transforms/Utils/AssignGUID.h" #include "llvm/Transforms/Utils/Debugify.h" #include "llvm/Transforms/Utils/ProfileVerify.h" @@ -514,14 +515,21 @@ bool llvm::runPassPipeline( case OK_NoOutput: break; // No output pass needed. case OK_OutputAssembly: + if (EmitSummaryIndex) { + MPM.addPass(AssignGUIDPass()); + } MPM.addPass(PrintModulePass( Out->os(), "", ShouldPreserveAssemblyUseListOrder, EmitSummaryIndex)); break; case OK_OutputBitcode: + if (EmitSummaryIndex) { + MPM.addPass(AssignGUIDPass()); + } MPM.addPass(BitcodeWriterPass(Out->os(), ShouldPreserveBitcodeUseListOrder, EmitSummaryIndex, EmitModuleHash)); break; case OK_OutputThinLTOBitcode: + MPM.addPass(AssignGUIDPass()); MPM.addPass(ThinLTOBitcodeWriterPass( Out->os(), ThinLTOLinkOut ? &ThinLTOLinkOut->os() : nullptr, ShouldPreserveBitcodeUseListOrder)); |