[PATCH] D125035: [riscv] Add strict asserts for VSETVLI insertion algorithm to help catch bugs
Philip Reames via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 6 08:51:23 PDT 2022
reames updated this revision to Diff 427653.
reames added a comment.
Address review comment.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D125035/new/
https://reviews.llvm.org/D125035
Files:
llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
Index: llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
+++ llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
@@ -37,6 +37,10 @@
"riscv-disable-insert-vsetvl-phi-opt", cl::init(false), cl::Hidden,
cl::desc("Disable looking through phis when inserting vsetvlis."));
+static cl::opt<bool> UseStrictAsserts(
+ "riscv-insert-vsetvl-strict-asserts", cl::init(false), cl::Hidden,
+ cl::desc("Enable strict assertion checking for the dataflow algorithm"));
+
namespace {
class VSETVLIInfo {
@@ -1168,7 +1172,7 @@
// If we reach the end of the block and our current info doesn't match the
// expected info, insert a vsetvli to correct.
- if (MI.isTerminator()) {
+ if (!UseStrictAsserts && MI.isTerminator()) {
const VSETVLIInfo &ExitInfo = BlockInfo[MBB.getNumber()].Exit;
if (CurInfo.isValid() && ExitInfo.isValid() && !ExitInfo.isUnknown() &&
CurInfo != ExitInfo) {
@@ -1177,6 +1181,17 @@
}
}
}
+
+ if (UseStrictAsserts && CurInfo.isValid()) {
+ const auto &Info = BlockInfo[MBB.getNumber()];
+ if (CurInfo != Info.Exit) {
+ LLVM_DEBUG(dbgs() << "in block " << printMBBReference(MBB) << "\n");
+ LLVM_DEBUG(dbgs() << " begin state: " << Info.Pred << "\n");
+ LLVM_DEBUG(dbgs() << " expected end state: " << Info.Exit << "\n");
+ LLVM_DEBUG(dbgs() << " actual end state: " << CurInfo << "\n");
+ }
+ assert(CurInfo == Info.Exit);
+ }
}
bool RISCVInsertVSETVLI::runOnMachineFunction(MachineFunction &MF) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125035.427653.patch
Type: text/x-patch
Size: 1637 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220506/786e3b84/attachment.bin>
More information about the llvm-commits
mailing list