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
/// 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;
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) {
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);
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.
; 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"
}
; 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
%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 }