mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-08 13:36:26 +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,
|
: DiagnosticInfoIROptimization(DK_OptimizationFailure, DS_Warning,
|
||||||
nullptr, Fn, DLoc, Msg) {}
|
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) {
|
static bool classof(const DiagnosticInfo *DI) {
|
||||||
return DI->getKind() == DK_OptimizationFailure;
|
return DI->getKind() == DK_OptimizationFailure;
|
||||||
}
|
}
|
||||||
@ -926,19 +934,6 @@ public:
|
|||||||
|
|
||||||
void print(DiagnosticPrinter &DP) const override;
|
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
|
} // end namespace llvm
|
||||||
|
|
||||||
#endif // LLVM_IR_DIAGNOSTICINFO_H
|
#endif // LLVM_IR_DIAGNOSTICINFO_H
|
||||||
|
@ -93,8 +93,10 @@ void MappingTraits<DiagnosticInfoOptimizationBase *>::mapping(
|
|||||||
OptDiag->getKind() ==
|
OptDiag->getKind() ==
|
||||||
DK_OptimizationRemarkAnalysisAliasing))
|
DK_OptimizationRemarkAnalysisAliasing))
|
||||||
;
|
;
|
||||||
|
else if (io.mapTag("!Failure", OptDiag->getKind() == DK_OptimizationFailure))
|
||||||
|
;
|
||||||
else
|
else
|
||||||
llvm_unreachable("todo");
|
llvm_unreachable("Unknown remark type");
|
||||||
|
|
||||||
// These are read-only for now.
|
// These are read-only for now.
|
||||||
DebugLoc DL = OptDiag->getDebugLoc();
|
DebugLoc DL = OptDiag->getDebugLoc();
|
||||||
|
@ -319,6 +319,13 @@ void llvm::emitOptimizationRemarkAnalysisAliasing(LLVMContext &Ctx,
|
|||||||
Ctx.diagnose(OptimizationRemarkAnalysisAliasing(PassName, Fn, DLoc, Msg));
|
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 {
|
bool DiagnosticInfoOptimizationFailure::isEnabled() const {
|
||||||
// Only print warnings.
|
// Only print warnings.
|
||||||
return getSeverity() == DS_Warning;
|
return getSeverity() == DS_Warning;
|
||||||
@ -334,18 +341,6 @@ void DiagnosticInfoUnsupported::print(DiagnosticPrinter &DP) const {
|
|||||||
DP << Str;
|
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 {
|
void DiagnosticInfoISelFallback::print(DiagnosticPrinter &DP) const {
|
||||||
DP << "Instruction selection used fallback path for " << getFunction();
|
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.getForce() == LoopVectorizeHints::FK_Enabled) {
|
||||||
if (LH.getWidth() != 1)
|
if (LH.getWidth() != 1)
|
||||||
emitLoopVectorizeWarning(
|
ORE->emit(DiagnosticInfoOptimizationFailure(
|
||||||
F->getContext(), *F, L->getStartLoc(),
|
DEBUG_TYPE, "FailedRequestedVectorization",
|
||||||
"failed explicitly specified loop vectorization");
|
L->getStartLoc(), L->getHeader())
|
||||||
|
<< "loop not vectorized: "
|
||||||
|
<< "failed explicitly specified loop vectorization");
|
||||||
else if (LH.getInterleave() != 1)
|
else if (LH.getInterleave() != 1)
|
||||||
emitLoopInterleaveWarning(
|
ORE->emit(DiagnosticInfoOptimizationFailure(
|
||||||
F->getContext(), *F, L->getStartLoc(),
|
DEBUG_TYPE, "FailedRequestedInterleaving", L->getStartLoc(),
|
||||||
"failed explicitly specified loop interleaving");
|
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 -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
|
; C/C++ code for tests
|
||||||
; void test(int *A, int Length) {
|
; void test(int *A, int Length) {
|
||||||
@ -42,6 +44,61 @@
|
|||||||
; CHECK-NOT: x i32>
|
; CHECK-NOT: x i32>
|
||||||
; CHECK: ret
|
; 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"
|
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
|
||||||
|
|
||||||
; Function Attrs: nounwind optsize ssp uwtable
|
; Function Attrs: nounwind optsize ssp uwtable
|
||||||
|
Loading…
x
Reference in New Issue
Block a user