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/lib/Passes/PassBuilderPipelines.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/lib/Passes/PassBuilderPipelines.cpp')
-rw-r--r-- | llvm/lib/Passes/PassBuilderPipelines.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp index 98821bb..0585303 100644 --- a/llvm/lib/Passes/PassBuilderPipelines.cpp +++ b/llvm/lib/Passes/PassBuilderPipelines.cpp @@ -130,6 +130,7 @@ #include "llvm/Transforms/Scalar/TailRecursionElimination.h" #include "llvm/Transforms/Scalar/WarnMissedTransforms.h" #include "llvm/Transforms/Utils/AddDiscriminators.h" +#include "llvm/Transforms/Utils/AssignGUID.h" #include "llvm/Transforms/Utils/AssumeBundleBuilder.h" #include "llvm/Transforms/Utils/CanonicalizeAliases.h" #include "llvm/Transforms/Utils/CountVisits.h" @@ -786,6 +787,7 @@ PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level, void PassBuilder::addRequiredLTOPreLinkPasses(ModulePassManager &MPM) { MPM.addPass(CanonicalizeAliasesPass()); MPM.addPass(NameAnonGlobalPass()); + MPM.addPass(AssignGUIDPass()); } void PassBuilder::addPreInlinerPasses(ModulePassManager &MPM, @@ -1234,9 +1236,6 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level, // In pre-link, we just want the instrumented IR. We use the contextual // profile in the post-thinlink phase. // The instrumentation will be removed in post-thinlink after IPO. - // FIXME(mtrofin): move AssignGUIDPass if there is agreement to use this - // mechanism for GUIDs. - MPM.addPass(AssignGUIDPass()); if (IsCtxProfUse) { MPM.addPass(PGOCtxProfFlatteningPass(/*IsPreThinlink=*/true)); return MPM; @@ -1640,6 +1639,11 @@ PassBuilder::buildPerModuleDefaultPipeline(OptimizationLevel Level, ModulePassManager MPM; + /* + MPM.addPass(NameAnonGlobalPass()); + MPM.addPass(AssignGUIDPass()); + */ + // Convert @llvm.global.annotations to !annotation metadata. MPM.addPass(Annotation2MetadataPass()); @@ -2208,6 +2212,11 @@ PassBuilder::buildO0DefaultPipeline(OptimizationLevel Level, ModulePassManager MPM; + /* + MPM.addPass(NameAnonGlobalPass()); + MPM.addPass(AssignGUIDPass()); + */ + // Perform pseudo probe instrumentation in O0 mode. This is for the // consistency between different build modes. For example, a LTO build can be // mixed with an O0 prelink and an O2 postlink. Loading a sample profile in |