Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
; RUN: --implicit-check-not "!memprof" --implicit-check-not "!callsite" \
; RUN: --implicit-check-not "memprof"="cold"

;; Ensure the attributes and metadata are stripped when running a non-LTO pipeline.
; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -x ir %t.o -S -emit-llvm -o - | FileCheck %s \
; RUN: --implicit-check-not "!memprof" --implicit-check-not "!callsite" \
; RUN: --implicit-check-not "memprof"="cold"

source_filename = "thinlto-distributed-supports-hot-cold-new.ll"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
Expand Down
10 changes: 10 additions & 0 deletions llvm/lib/Passes/PassBuilderPipelines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
5 changes: 5 additions & 0 deletions llvm/test/LTO/X86/memprof-supports-hot-cold-new.ll
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
; RUN: --implicit-check-not "!memprof" --implicit-check-not "!callsite" \
; RUN: --implicit-check-not "memprof"="cold"

;; Ensure the attributes and metadata are stripped when running a non-LTO pipeline.
; RUN: opt -O3 %t.o -S | FileCheck %s \
; RUN: --implicit-check-not "!memprof" --implicit-check-not "!callsite" \
; RUN: --implicit-check-not "memprof"="cold"

source_filename = "memprof-supports-hot-cold-new.ll"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
Expand Down