diff options
Diffstat (limited to 'willow/lib/IR/Verifier.cpp')
| -rw-r--r-- | willow/lib/IR/Verifier.cpp | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/willow/lib/IR/Verifier.cpp b/willow/lib/IR/Verifier.cpp index d19bc83..b622f10 100644 --- a/willow/lib/IR/Verifier.cpp +++ b/willow/lib/IR/Verifier.cpp @@ -1,3 +1,4 @@ +#include <iostream> #include <willow/IR/BasicBlock.h> #include <willow/IR/Diagnostic.h> #include <willow/IR/DiagnosticEngine.h> @@ -75,20 +76,19 @@ LogicalResult verifyBasicBlock(WillowContext &ctx, const BasicBlock &BB, DiagnosticEngine &diags) { if (BB.empty()) return emit(diags, Severity::Error, BB.getLoc()) - << "Basic block '" << BB.getName() << "' has an empty body"; + << "Basic block has empty body"; - if (!BB.trailer()->isTerminator()) + if (!BB.trailer().isTerminator()) return emit(diags, Severity::Error, BB.getLoc()) - << "Basic block '" << BB.getName() - << "' does not end with a terminator"; + << "Basic block does not end with a terminator"; bool has_failed = false; - for (auto &inst : BB.getBody()) { + for (auto& inst : BB) { // verify inst if (failed(verifyInst(ctx, inst, diags))) has_failed = true; - if (&inst != BB.trailer() && inst.isTerminator()) + if (&inst != &BB.trailer() && inst.isTerminator()) return emit(diags, Severity::Error, BB.getLoc()) << "Illegal terminator in the middle of a block"; } @@ -219,11 +219,9 @@ LogicalResult verifyInst(WillowContext &ctx, const Instruction &inst, if (aty == pty) continue; - DiagnosticBuilder d(diags, Severity::Error, inst.getLoc()); - d << "invalid argument: expected '" << pty << "', got '" << aty << "'"; - if (param.hasName()) - d.note(Diagnostic{Severity::Remark, - std::format("param name: {}", param.getName())}); + return emit(diags, Severity::Error, inst.getLoc()) + << "invalid argument: expected '" << pty << "', got '" << aty + << "'"; return failure(); } @@ -266,8 +264,7 @@ LogicalResult verifyInst(WillowContext &ctx, const Instruction &inst, if (BB && fn && (pred->getParent() != fn)) return emit(diags, Severity::Error, inst.getLoc()) - << "basic block: '" << pred->getName() - << "' is not a child of function '" << fn->getName() << "'"; + << "invalid predecessor"; } return success(); @@ -344,14 +341,14 @@ LogicalResult verifyBinaryIntegerCmp(WillowContext &ctx, } LogicalResult verifyResult(const Instruction &inst, DiagnosticEngine &diags) { - if (inst.hasName()) - return success(); + if (!inst.getType().isVoid()) + return success(); return emit(diags, Severity::Error, inst.getLoc()) << "expected ssa result"; } LogicalResult verifyNoResult(const Instruction &inst, DiagnosticEngine &diags) { - if (!inst.hasName()) + if (inst.getType().isVoid()) return success(); return emit(diags, Severity::Error, inst.getLoc()) << "unexpected ssa result"; |