Print an error message in Formula::print if the HasBaseReg flag
authorDan Gohman <gohman@apple.com>
Tue, 18 May 2010 22:35:55 +0000 (22:35 +0000)
committerDan Gohman <gohman@apple.com>
Tue, 18 May 2010 22:35:55 +0000 (22:35 +0000)
is inconsistent with the BaseRegs field. It's not print's job to
assert on an invalid condition, but it can make one more obvious.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104077 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/LoopStrengthReduce.cpp

index cec397c739c0f14d7d2e890e2a385ca5a50b2d3a..e2a3c46767c06061e7d2b189b36e0f43ebf6d214 100644 (file)
@@ -326,6 +326,13 @@ void Formula::print(raw_ostream &OS) const {
     if (!First) OS << " + "; else First = false;
     OS << "reg(" << **I << ')';
   }
+  if (AM.HasBaseReg && BaseRegs.empty()) {
+    if (!First) OS << " + "; else First = false;
+    OS << "**error: HasBaseReg**";
+  } else if (!AM.HasBaseReg && !BaseRegs.empty()) {
+    if (!First) OS << " + "; else First = false;
+    OS << "**error: !HasBaseReg**";
+  }
   if (AM.Scale != 0) {
     if (!First) OS << " + "; else First = false;
     OS << AM.Scale << "*reg(";