mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-01 18:12:49 +00:00
[LV] Also port failure remarks to new OptimizationRemarkEmitter API
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293866 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d69c1efa38
commit
49e45b454f
@ -891,6 +891,14 @@ public:
|
||||
: DiagnosticInfoIROptimization(DK_OptimizationFailure, DS_Warning,
|
||||
nullptr, Fn, DLoc, Msg) {}
|
||||
|
||||
/// \p PassName is the name of the pass emitting this diagnostic. \p
|
||||
/// RemarkName is a textual identifier for the remark (single-word,
|
||||
/// camel-case). \p DLoc is the debug location and \p CodeRegion is the
|
||||
/// region that the optimization operates on (currently basic block is
|
||||
/// supported).
|
||||
DiagnosticInfoOptimizationFailure(const char *PassName, StringRef RemarkName,
|
||||
const DebugLoc &DLoc, Value *CodeRegion);
|
||||
|
||||
static bool classof(const DiagnosticInfo *DI) {
|
||||
return DI->getKind() == DK_OptimizationFailure;
|
||||
}
|
||||
@ -926,19 +934,6 @@ public:
|
||||
|
||||
void print(DiagnosticPrinter &DP) const override;
|
||||
};
|
||||
|
||||
/// Emit a warning when loop vectorization is specified but fails. \p Fn is the
|
||||
/// function triggering the warning, \p DLoc is the debug location where the
|
||||
/// diagnostic is generated. \p Msg is the message string to use.
|
||||
void emitLoopVectorizeWarning(LLVMContext &Ctx, const Function &Fn,
|
||||
const DebugLoc &DLoc, const Twine &Msg);
|
||||
|
||||
/// Emit a warning when loop interleaving is specified but fails. \p Fn is the
|
||||
/// function triggering the warning, \p DLoc is the debug location where the
|
||||
/// diagnostic is generated. \p Msg is the message string to use.
|
||||
void emitLoopInterleaveWarning(LLVMContext &Ctx, const Function &Fn,
|
||||
const DebugLoc &DLoc, const Twine &Msg);
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
#endif // LLVM_IR_DIAGNOSTICINFO_H
|
||||
|
@ -93,8 +93,10 @@ void MappingTraits<DiagnosticInfoOptimizationBase *>::mapping(
|
||||
OptDiag->getKind() ==
|
||||
DK_OptimizationRemarkAnalysisAliasing))
|
||||
;
|
||||
else if (io.mapTag("!Failure", OptDiag->getKind() == DK_OptimizationFailure))
|
||||
;
|
||||
else
|
||||
llvm_unreachable("todo");
|
||||
llvm_unreachable("Unknown remark type");
|
||||
|
||||
// These are read-only for now.
|
||||
DebugLoc DL = OptDiag->getDebugLoc();
|
||||
|
@ -319,6 +319,13 @@ void llvm::emitOptimizationRemarkAnalysisAliasing(LLVMContext &Ctx,
|
||||
Ctx.diagnose(OptimizationRemarkAnalysisAliasing(PassName, Fn, DLoc, Msg));
|
||||
}
|
||||
|
||||
DiagnosticInfoOptimizationFailure::DiagnosticInfoOptimizationFailure(
|
||||
const char *PassName, StringRef RemarkName, const DebugLoc &DLoc,
|
||||
Value *CodeRegion)
|
||||
: DiagnosticInfoIROptimization(
|
||||
DK_OptimizationFailure, DS_Warning, PassName, RemarkName,
|
||||
*cast<BasicBlock>(CodeRegion)->getParent(), DLoc, CodeRegion) {}
|
||||
|
||||
bool DiagnosticInfoOptimizationFailure::isEnabled() const {
|
||||
// Only print warnings.
|
||||
return getSeverity() == DS_Warning;
|
||||
@ -334,18 +341,6 @@ void DiagnosticInfoUnsupported::print(DiagnosticPrinter &DP) const {
|
||||
DP << Str;
|
||||
}
|
||||
|
||||
void llvm::emitLoopVectorizeWarning(LLVMContext &Ctx, const Function &Fn,
|
||||
const DebugLoc &DLoc, const Twine &Msg) {
|
||||
Ctx.diagnose(DiagnosticInfoOptimizationFailure(
|
||||
Fn, DLoc, Twine("loop not vectorized: " + Msg)));
|
||||
}
|
||||
|
||||
void llvm::emitLoopInterleaveWarning(LLVMContext &Ctx, const Function &Fn,
|
||||
const DebugLoc &DLoc, const Twine &Msg) {
|
||||
Ctx.diagnose(DiagnosticInfoOptimizationFailure(
|
||||
Fn, DLoc, Twine("loop not interleaved: " + Msg)));
|
||||
}
|
||||
|
||||
void DiagnosticInfoISelFallback::print(DiagnosticPrinter &DP) const {
|
||||
DP << "Instruction selection used fallback path for " << getFunction();
|
||||
}
|
||||
|
@ -1513,13 +1513,17 @@ static void emitMissedWarning(Function *F, Loop *L,
|
||||
|
||||
if (LH.getForce() == LoopVectorizeHints::FK_Enabled) {
|
||||
if (LH.getWidth() != 1)
|
||||
emitLoopVectorizeWarning(
|
||||
F->getContext(), *F, L->getStartLoc(),
|
||||
"failed explicitly specified loop vectorization");
|
||||
ORE->emit(DiagnosticInfoOptimizationFailure(
|
||||
DEBUG_TYPE, "FailedRequestedVectorization",
|
||||
L->getStartLoc(), L->getHeader())
|
||||
<< "loop not vectorized: "
|
||||
<< "failed explicitly specified loop vectorization");
|
||||
else if (LH.getInterleave() != 1)
|
||||
emitLoopInterleaveWarning(
|
||||
F->getContext(), *F, L->getStartLoc(),
|
||||
"failed explicitly specified loop interleaving");
|
||||
ORE->emit(DiagnosticInfoOptimizationFailure(
|
||||
DEBUG_TYPE, "FailedRequestedInterleaving", L->getStartLoc(),
|
||||
L->getHeader())
|
||||
<< "loop not interleaved: "
|
||||
<< "failed explicitly specified loop interleaving");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
; RUN: opt < %s -loop-vectorize -S -pass-remarks-missed='loop-vectorize' -pass-remarks-analysis='loop-vectorize' 2>&1 | FileCheck %s
|
||||
; RUN: opt < %s -loop-vectorize -o /dev/null -pass-remarks-output=%t.yaml
|
||||
; RUN: cat %t.yaml | FileCheck -check-prefix=YAML %s
|
||||
|
||||
; C/C++ code for tests
|
||||
; void test(int *A, int Length) {
|
||||
@ -42,6 +44,61 @@
|
||||
; CHECK-NOT: x i32>
|
||||
; CHECK: ret
|
||||
|
||||
; YAML: --- !Analysis
|
||||
; YAML-NEXT: Pass: loop-vectorize
|
||||
; YAML-NEXT: Name: CantComputeNumberOfIterations
|
||||
; YAML-NEXT: DebugLoc: { File: source.cpp, Line: 4, Column: 5 }
|
||||
; YAML-NEXT: Function: _Z4testPii
|
||||
; YAML-NEXT: Args:
|
||||
; YAML-NEXT: - String: 'loop not vectorized: '
|
||||
; YAML-NEXT: - String: could not determine number of loop iterations
|
||||
; YAML-NEXT: ...
|
||||
; YAML-NEXT: --- !Missed
|
||||
; YAML-NEXT: Pass: loop-vectorize
|
||||
; YAML-NEXT: Name: MissedDetails
|
||||
; YAML-NEXT: DebugLoc: { File: source.cpp, Line: 4, Column: 5 }
|
||||
; YAML-NEXT: Function: _Z4testPii
|
||||
; YAML-NEXT: Args:
|
||||
; YAML-NEXT: - String: loop not vectorized
|
||||
; YAML-NEXT: ...
|
||||
; YAML-NEXT: --- !Analysis
|
||||
; YAML-NEXT: Pass: loop-vectorize
|
||||
; YAML-NEXT: Name: AllDisabled
|
||||
; YAML-NEXT: DebugLoc: { File: source.cpp, Line: 13, Column: 5 }
|
||||
; YAML-NEXT: Function: _Z13test_disabledPii
|
||||
; YAML-NEXT: Args:
|
||||
; YAML-NEXT: - String: 'loop not vectorized: vectorization and interleaving are explicitly disabled, or vectorize width and interleave count are both set to 1'
|
||||
; YAML-NEXT: ...
|
||||
; YAML-NEXT: --- !Analysis
|
||||
; YAML-NEXT: Pass: ''
|
||||
; YAML-NEXT: Name: CantIdentifyArrayBounds
|
||||
; YAML-NEXT: DebugLoc: { File: source.cpp, Line: 19, Column: 5 }
|
||||
; YAML-NEXT: Function: _Z17test_array_boundsPiS_i
|
||||
; YAML-NEXT: Args:
|
||||
; YAML-NEXT: - String: 'loop not vectorized: '
|
||||
; YAML-NEXT: - String: cannot identify array bounds
|
||||
; YAML-NEXT: ...
|
||||
; YAML-NEXT: --- !Missed
|
||||
; YAML-NEXT: Pass: loop-vectorize
|
||||
; YAML-NEXT: Name: MissedDetails
|
||||
; YAML-NEXT: DebugLoc: { File: source.cpp, Line: 19, Column: 5 }
|
||||
; YAML-NEXT: Function: _Z17test_array_boundsPiS_i
|
||||
; YAML-NEXT: Args:
|
||||
; YAML-NEXT: - String: loop not vectorized
|
||||
; YAML-NEXT: - String: ' (Force='
|
||||
; YAML-NEXT: - Force: 'true'
|
||||
; YAML-NEXT: - String: ')'
|
||||
; YAML-NEXT: ...
|
||||
; YAML-NEXT: --- !Failure
|
||||
; YAML-NEXT: Pass: loop-vectorize
|
||||
; YAML-NEXT: Name: FailedRequestedVectorization
|
||||
; YAML-NEXT: DebugLoc: { File: source.cpp, Line: 19, Column: 5 }
|
||||
; YAML-NEXT: Function: _Z17test_array_boundsPiS_i
|
||||
; YAML-NEXT: Args:
|
||||
; YAML-NEXT: - String: 'loop not vectorized: '
|
||||
; YAML-NEXT: - String: failed explicitly specified loop vectorization
|
||||
; YAML-NEXT: ...
|
||||
|
||||
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
|
||||
|
||||
; Function Attrs: nounwind optsize ssp uwtable
|
||||
|
Loading…
x
Reference in New Issue
Block a user