aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2025-10-16 13:50:24 -0700
committerGitHub <noreply@github.com>2025-10-16 13:50:24 -0700
commit67a284a5192bef0f99ee1debecdf72bfbe67a083 (patch)
tree6894ae43c78b58f1d82c13d711c29418b9e7428f /llvm/lib
parent01db10aa594c52adacbddee883151b9b83acf1e8 (diff)
downloadllvm-67a284a5192bef0f99ee1debecdf72bfbe67a083.zip
llvm-67a284a5192bef0f99ee1debecdf72bfbe67a083.tar.gz
llvm-67a284a5192bef0f99ee1debecdf72bfbe67a083.tar.bz2
[MemProf] Remove memprof attrs and metadata in non-LTO pipelines (#163853)
Follow up to PR163841 to use the new pass in the default non-LTO pipeline setup. This is needed so that we don't use the hints to convert allocation calls when we don't know whether we are linking with a library that supports those APIs.
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Passes/PassBuilderPipelines.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp
index 2d68895..3f3939eaf 100644
--- a/llvm/lib/Passes/PassBuilderPipelines.cpp
+++ b/llvm/lib/Passes/PassBuilderPipelines.cpp
@@ -1658,6 +1658,16 @@ PassBuilder::buildPerModuleDefaultPipeline(OptimizationLevel Level,
ModulePassManager MPM;
+ // Currently this pipeline is only invoked in an LTO pre link pass or when we
+ // are not running LTO. If that changes the below checks may need updating.
+ assert(isLTOPreLink(Phase) || Phase == ThinOrFullLTOPhase::None);
+
+ // If we are invoking this in non-LTO mode, remove any MemProf related
+ // attributes and metadata, as we don't know whether we are linking with
+ // a library containing the necessary interfaces.
+ if (Phase == ThinOrFullLTOPhase::None)
+ MPM.addPass(MemProfRemoveInfo());
+
// Convert @llvm.global.annotations to !annotation metadata.
MPM.addPass(Annotation2MetadataPass());