summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Nemet <anemet@apple.com>2016-07-21 01:07:13 +0000
committerAdam Nemet <anemet@apple.com>2016-07-21 01:07:13 +0000
commit7cfd5971ab09bde7ec4f14e1f995414380ea4179 (patch)
tree5e54e45c8fee1fdf4e88499f095e254715bb8de7
parentca8210a952f6f072292cb0d0f196b7e69f4914f3 (diff)
downloadbcm5719-llvm-7cfd5971ab09bde7ec4f14e1f995414380ea4179.tar.gz
bcm5719-llvm-7cfd5971ab09bde7ec4f14e1f995414380ea4179.zip
[OptDiag,LV] Add hotness attribute to applied-optimization remarks
Test coverage is provided by modifying the function in the FP-math testcase that we are allowed to vectorize. llvm-svn: 276223
-rw-r--r--llvm/include/llvm/Analysis/OptimizationDiagnosticInfo.h15
-rw-r--r--llvm/include/llvm/IR/DiagnosticInfo.h5
-rw-r--r--llvm/lib/Analysis/OptimizationDiagnosticInfo.cpp15
-rw-r--r--llvm/lib/Transforms/Vectorize/LoopVectorize.cpp14
-rw-r--r--llvm/test/Transforms/LoopVectorize/X86/no_fpmath_with_hotness.ll8
5 files changed, 44 insertions, 13 deletions
diff --git a/llvm/include/llvm/Analysis/OptimizationDiagnosticInfo.h b/llvm/include/llvm/Analysis/OptimizationDiagnosticInfo.h
index dfa6177048b..65ca2921615 100644
--- a/llvm/include/llvm/Analysis/OptimizationDiagnosticInfo.h
+++ b/llvm/include/llvm/Analysis/OptimizationDiagnosticInfo.h
@@ -43,6 +43,21 @@ public:
return *this;
}
+ /// Emit an optimization-applied message.
+ ///
+ /// \p PassName is the name of the pass emitting the message. If -Rpass= is
+ /// given and \p PassName matches the regular expression in -Rpass, then the
+ /// remark will be emitted. \p Fn is the function triggering the remark, \p
+ /// DLoc is the debug location where the diagnostic is generated. \p V is the
+ /// IR Value that identifies the code region. \p Msg is the message string to
+ /// use.
+ void emitOptimizationRemark(const char *PassName, const DebugLoc &DLoc,
+ const Value *V, const Twine &Msg);
+
+ /// \brief Same as above but derives the IR Value for the code region and the
+ /// debug location from the Loop parameter \p L.
+ void emitOptimizationRemark(const char *PassName, Loop *L, const Twine &Msg);
+
/// Emit an optimization-missed message.
///
/// \p PassName is the name of the pass emitting the message. If
diff --git a/llvm/include/llvm/IR/DiagnosticInfo.h b/llvm/include/llvm/IR/DiagnosticInfo.h
index b8667fcfdb8..cbd328c2251 100644
--- a/llvm/include/llvm/IR/DiagnosticInfo.h
+++ b/llvm/include/llvm/IR/DiagnosticInfo.h
@@ -433,9 +433,10 @@ public:
/// Note that this class does not copy this message, so this reference
/// must be valid for the whole life time of the diagnostic.
DiagnosticInfoOptimizationRemark(const char *PassName, const Function &Fn,
- const DebugLoc &DLoc, const Twine &Msg)
+ const DebugLoc &DLoc, const Twine &Msg,
+ Optional<uint64_t> Hotness = None)
: DiagnosticInfoOptimizationBase(DK_OptimizationRemark, DS_Remark,
- PassName, Fn, DLoc, Msg) {}
+ PassName, Fn, DLoc, Msg, Hotness) {}
static bool classof(const DiagnosticInfo *DI) {
return DI->getKind() == DK_OptimizationRemark;
diff --git a/llvm/lib/Analysis/OptimizationDiagnosticInfo.cpp b/llvm/lib/Analysis/OptimizationDiagnosticInfo.cpp
index cae2253b00c..e658755aa1e 100644
--- a/llvm/lib/Analysis/OptimizationDiagnosticInfo.cpp
+++ b/llvm/lib/Analysis/OptimizationDiagnosticInfo.cpp
@@ -27,6 +27,21 @@ Optional<uint64_t> OptimizationRemarkEmitter::computeHotness(const Value *V) {
return BFI->getBlockProfileCount(cast<BasicBlock>(V));
}
+void OptimizationRemarkEmitter::emitOptimizationRemark(const char *PassName,
+ const DebugLoc &DLoc,
+ const Value *V,
+ const Twine &Msg) {
+ LLVMContext &Ctx = F->getContext();
+ Ctx.diagnose(DiagnosticInfoOptimizationRemark(PassName, *F, DLoc, Msg,
+ computeHotness(V)));
+}
+
+void OptimizationRemarkEmitter::emitOptimizationRemark(const char *PassName,
+ Loop *L,
+ const Twine &Msg) {
+ emitOptimizationRemark(PassName, L->getStartLoc(), L->getHeader(), Msg);
+}
+
void OptimizationRemarkEmitter::emitOptimizationRemarkMissed(
const char *PassName, const DebugLoc &DLoc, const Value *V,
const Twine &Msg) {
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 5befef967b8..b6ba0796ed6 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -6575,9 +6575,9 @@ bool LoopVectorizePass::processLoop(Loop *L) {
InnerLoopUnroller Unroller(L, PSE, LI, DT, TLI, TTI, AC, ORE, IC);
Unroller.vectorize(&LVL, CM.MinBWs, CM.VecValuesToIgnore);
- emitOptimizationRemark(F->getContext(), LV_NAME, *F, L->getStartLoc(),
- Twine("interleaved loop (interleaved count: ") +
- Twine(IC) + ")");
+ ORE->emitOptimizationRemark(LV_NAME, L,
+ Twine("interleaved loop (interleaved count: ") +
+ Twine(IC) + ")");
} else {
// If we decided that it is *legal* to vectorize the loop, then do it.
InnerLoopVectorizer LB(L, PSE, LI, DT, TLI, TTI, AC, ORE, VF.Width, IC);
@@ -6591,10 +6591,10 @@ bool LoopVectorizePass::processLoop(Loop *L) {
AddRuntimeUnrollDisableMetaData(L);
// Report the vectorization decision.
- emitOptimizationRemark(F->getContext(), LV_NAME, *F, L->getStartLoc(),
- Twine("vectorized loop (vectorization width: ") +
- Twine(VF.Width) + ", interleaved count: " +
- Twine(IC) + ")");
+ ORE->emitOptimizationRemark(
+ LV_NAME, L, Twine("vectorized loop (vectorization width: ") +
+ Twine(VF.Width) + ", interleaved count: " + Twine(IC) +
+ ")");
}
// Mark the loop as already vectorized to avoid vectorizing again.
diff --git a/llvm/test/Transforms/LoopVectorize/X86/no_fpmath_with_hotness.ll b/llvm/test/Transforms/LoopVectorize/X86/no_fpmath_with_hotness.ll
index 7cb38f62cbb..f86ea525737 100644
--- a/llvm/test/Transforms/LoopVectorize/X86/no_fpmath_with_hotness.ll
+++ b/llvm/test/Transforms/LoopVectorize/X86/no_fpmath_with_hotness.ll
@@ -3,7 +3,7 @@
; CHECK: remark: no_fpmath.c:6:11: loop not vectorized: cannot prove it is safe to reorder floating-point operations (hotness: 300)
; CHECK: remark: no_fpmath.c:6:14: loop not vectorized:
-; CHECK: remark: no_fpmath.c:17:14: vectorized loop (vectorization width: 2, interleaved count: 2)
+; CHECK: remark: no_fpmath.c:17:14: vectorized loop (vectorization width: 2, interleaved count: 2) (hotness: 300)
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.10.0"
@@ -40,10 +40,10 @@ for.body: ; preds = %for.body.preheader,
}
; Function Attrs: nounwind readonly ssp uwtable
-define double @cond_sum_loop_hint(i32* nocapture readonly %v, i32 %n) #0 !dbg !20 {
+define double @cond_sum_loop_hint(i32* nocapture readonly %v, i32 %n) #0 !dbg !20 !prof !29{
entry:
%cmp.7 = icmp sgt i32 %n, 0, !dbg !19
- br i1 %cmp.7, label %for.body.preheader, label %for.cond.cleanup, !dbg !21
+ br i1 %cmp.7, label %for.body.preheader, label %for.cond.cleanup, !dbg !21, !prof !30
for.body.preheader: ; preds = %entry
br label %for.body, !dbg !22
@@ -67,7 +67,7 @@ for.body: ; preds = %for.body.preheader,
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !21
%lftr.wideiv = trunc i64 %indvars.iv.next to i32, !dbg !21
%exitcond = icmp eq i32 %lftr.wideiv, %n, !dbg !21
- br i1 %exitcond, label %for.cond.cleanup.loopexit, label %for.body, !dbg !21, !llvm.loop !26
+ br i1 %exitcond, label %for.cond.cleanup.loopexit, label %for.body, !dbg !21, !llvm.loop !26, !prof !31
}
attributes #0 = { nounwind }
OpenPOWER on IntegriCloud