Skip to content

Commit 80c575c

Browse files
teresajohnsongithub-actions[bot]
authored andcommitted
Automerge: [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.
2 parents 5bb9f39 + 67a284a commit 80c575c

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

clang/test/CodeGen/distributed-thin-lto/supports-hot-cold-new.ll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@
4646
; RUN: --implicit-check-not "!memprof" --implicit-check-not "!callsite" \
4747
; RUN: --implicit-check-not "memprof"="cold"
4848

49+
;; Ensure the attributes and metadata are stripped when running a non-LTO pipeline.
50+
; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -x ir %t.o -S -emit-llvm -o - | FileCheck %s \
51+
; RUN: --implicit-check-not "!memprof" --implicit-check-not "!callsite" \
52+
; RUN: --implicit-check-not "memprof"="cold"
53+
4954
source_filename = "thinlto-distributed-supports-hot-cold-new.ll"
5055
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
5156
target triple = "x86_64-unknown-linux-gnu"

llvm/lib/Passes/PassBuilderPipelines.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1663,6 +1663,16 @@ PassBuilder::buildPerModuleDefaultPipeline(OptimizationLevel Level,
16631663

16641664
ModulePassManager MPM;
16651665

1666+
// Currently this pipeline is only invoked in an LTO pre link pass or when we
1667+
// are not running LTO. If that changes the below checks may need updating.
1668+
assert(isLTOPreLink(Phase) || Phase == ThinOrFullLTOPhase::None);
1669+
1670+
// If we are invoking this in non-LTO mode, remove any MemProf related
1671+
// attributes and metadata, as we don't know whether we are linking with
1672+
// a library containing the necessary interfaces.
1673+
if (Phase == ThinOrFullLTOPhase::None)
1674+
MPM.addPass(MemProfRemoveInfo());
1675+
16661676
// Convert @llvm.global.annotations to !annotation metadata.
16671677
MPM.addPass(Annotation2MetadataPass());
16681678

llvm/test/LTO/X86/memprof-supports-hot-cold-new.ll

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
; RUN: --implicit-check-not "!memprof" --implicit-check-not "!callsite" \
3535
; RUN: --implicit-check-not "memprof"="cold"
3636

37+
;; Ensure the attributes and metadata are stripped when running a non-LTO pipeline.
38+
; RUN: opt -O3 %t.o -S | FileCheck %s \
39+
; RUN: --implicit-check-not "!memprof" --implicit-check-not "!callsite" \
40+
; RUN: --implicit-check-not "memprof"="cold"
41+
3742
source_filename = "memprof-supports-hot-cold-new.ll"
3843
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
3944
target triple = "x86_64-unknown-linux-gnu"

0 commit comments

Comments
 (0)