[llvm] [AArch64] Don't forcefully add ORE to O0 pipeline (PR #191476)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 10 10:48:48 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-aarch64
Author: Alexis Engelke (aengelke)
<details>
<summary>Changes</summary>
Construct the OptimizationRemarkEmitter in AArch64StackTagging on demand
if not available and requires, this avoids computing several analysis in
all pipelines.
---
Full diff: https://github.com/llvm/llvm-project/pull/191476.diff
3 Files Affected:
- (modified) llvm/lib/Target/AArch64/AArch64StackTagging.cpp (+12-4)
- (modified) llvm/test/CodeGen/AArch64/O0-pipeline.ll (+1-6)
- (modified) llvm/test/CodeGen/AArch64/O3-pipeline.ll (-4)
``````````diff
diff --git a/llvm/lib/Target/AArch64/AArch64StackTagging.cpp b/llvm/lib/Target/AArch64/AArch64StackTagging.cpp
index 787928246eaed..7ef18fa18255d 100644
--- a/llvm/lib/Target/AArch64/AArch64StackTagging.cpp
+++ b/llvm/lib/Target/AArch64/AArch64StackTagging.cpp
@@ -333,7 +333,7 @@ class AArch64StackTagging : public FunctionPass {
AU.addRequired<StackSafetyGlobalInfoWrapperPass>();
if (MergeInit)
AU.addRequired<AAResultsWrapperPass>();
- AU.addRequired<OptimizationRemarkEmitterWrapperPass>();
+ AU.addUsedIfAvailable<OptimizationRemarkEmitterWrapperPass>();
}
};
@@ -518,12 +518,20 @@ bool AArch64StackTagging::runOnFunction(Function &Fn) {
DL = &Fn.getDataLayout();
if (MergeInit)
AA = &getAnalysis<AAResultsWrapperPass>().getAAResults();
- OptimizationRemarkEmitter &ORE =
- getAnalysis<OptimizationRemarkEmitterWrapperPass>().getORE();
+
+ std::unique_ptr<OptimizationRemarkEmitter> DeleteORE;
+ OptimizationRemarkEmitter *ORE = nullptr;
+ if (auto *P = getAnalysisIfAvailable<OptimizationRemarkEmitterWrapperPass>())
+ ORE = &P->getORE();
+
+ if (ORE == nullptr) {
+ DeleteORE = std::make_unique<OptimizationRemarkEmitter>(F);
+ ORE = DeleteORE.get();
+ }
memtag::StackInfoBuilder SIB(SSI, DEBUG_TYPE);
for (Instruction &I : instructions(F))
- SIB.visit(ORE, I);
+ SIB.visit(*ORE, I);
memtag::StackInfo &SInfo = SIB.get();
if (SInfo.AllocasToInstrument.empty())
diff --git a/llvm/test/CodeGen/AArch64/O0-pipeline.ll b/llvm/test/CodeGen/AArch64/O0-pipeline.ll
index 32dbe49df0c1d..c0918a1949499 100644
--- a/llvm/test/CodeGen/AArch64/O0-pipeline.ll
+++ b/llvm/test/CodeGen/AArch64/O0-pipeline.ll
@@ -11,8 +11,8 @@
; CHECK-NEXT: Target Transform Information
; CHECK-NEXT: Library Function Lowering Analysis
; CHECK-NEXT: Create Garbage Collector Module Metadata
-; CHECK-NEXT: Profile summary info
; CHECK-NEXT: Assumption Cache Tracker
+; CHECK-NEXT: Profile summary info
; CHECK-NEXT: Machine Branch Probability Analysis
; CHECK-NEXT: ModulePass Manager
; CHECK-NEXT: Pre-ISel Intrinsic Lowering
@@ -26,11 +26,6 @@
; CHECK-NEXT: Instrument function entry/exit with calls to e.g. mcount() (post inlining)
; CHECK-NEXT: Scalarize Masked Memory Intrinsics
; CHECK-NEXT: Expand reduction intrinsics
-; CHECK-NEXT: Dominator Tree Construction
-; CHECK-NEXT: Natural Loop Information
-; CHECK-NEXT: Lazy Branch Probability Analysis
-; CHECK-NEXT: Lazy Block Frequency Analysis
-; CHECK-NEXT: Optimization Remark Emitter
; CHECK-NEXT: AArch64 Stack Tagging
; CHECK-NEXT: Exception handling preparation
; CHECK-NEXT: Prepare inline asm insts
diff --git a/llvm/test/CodeGen/AArch64/O3-pipeline.ll b/llvm/test/CodeGen/AArch64/O3-pipeline.ll
index ff4f28a3a50c1..546949aa4e209 100644
--- a/llvm/test/CodeGen/AArch64/O3-pipeline.ll
+++ b/llvm/test/CodeGen/AArch64/O3-pipeline.ll
@@ -83,10 +83,6 @@
; CHECK-NEXT: Dominator Tree Construction
; CHECK-NEXT: Basic Alias Analysis (stateless AA impl)
; CHECK-NEXT: Function Alias Analysis Results
-; CHECK-NEXT: Natural Loop Information
-; CHECK-NEXT: Lazy Branch Probability Analysis
-; CHECK-NEXT: Lazy Block Frequency Analysis
-; CHECK-NEXT: Optimization Remark Emitter
; CHECK-NEXT: AArch64 Stack Tagging
; CHECK-NEXT: Complex Deinterleaving Pass
; CHECK-NEXT: Function Alias Analysis Results
``````````
</details>
https://github.com/llvm/llvm-project/pull/191476
More information about the llvm-commits
mailing list