[PATCH] D28358: [globalisel] Stop requiring -debug/-debug-only=registerbankinfo for assertions.

Daniel Sanders via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 5 08:39:06 PST 2017


dsanders created this revision.
dsanders added reviewers: qcolombet, t.p.northover, ab, rovka.
dsanders added a subscriber: llvm-commits.
Herald added subscribers: kristof.beyls, dberris.

I've noticed that these assertions don't trigger when the condition is false.
The problem is that the DEBUG(x) macro only executes x when the pass is
emitting debug output via the -debug and -debug-only=registerbankinfo command
line arguments.

Debug builds should always execute the assertions so use '#ifdef NDEBUG' instead.


https://reviews.llvm.org/D28358

Files:
  lib/CodeGen/GlobalISel/RegisterBankInfo.cpp


Index: lib/CodeGen/GlobalISel/RegisterBankInfo.cpp
===================================================================
--- lib/CodeGen/GlobalISel/RegisterBankInfo.cpp
+++ lib/CodeGen/GlobalISel/RegisterBankInfo.cpp
@@ -55,11 +55,13 @@
 RegisterBankInfo::RegisterBankInfo(RegisterBank **RegBanks,
                                    unsigned NumRegBanks)
     : RegBanks(RegBanks), NumRegBanks(NumRegBanks) {
-  DEBUG(for (unsigned Idx = 0, End = getNumRegBanks(); Idx != End; ++Idx) {
+#ifdef NDEBUG
+  for (unsigned Idx = 0, End = getNumRegBanks(); Idx != End; ++Idx) {
     assert(RegBanks[Idx] != nullptr && "Invalid RegisterBank");
     assert(!RegBanks[Idx]->isValid() &&
            "RegisterBank should be invalid before initialization");
-  });
+  }
+#endif // NDEBUG
 }
 
 RegisterBankInfo::~RegisterBankInfo() {
@@ -70,13 +72,15 @@
 }
 
 bool RegisterBankInfo::verify(const TargetRegisterInfo &TRI) const {
-  DEBUG(for (unsigned Idx = 0, End = getNumRegBanks(); Idx != End; ++Idx) {
+#ifdef NDEBUG
+  for (unsigned Idx = 0, End = getNumRegBanks(); Idx != End; ++Idx) {
     const RegisterBank &RegBank = getRegBank(Idx);
     assert(Idx == RegBank.getID() &&
            "ID does not match the index in the array");
     dbgs() << "Verify " << RegBank << '\n';
     assert(RegBank.verify(TRI) && "RegBank is invalid");
-  });
+  }
+#endif // NDEBUG
   return true;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28358.83250.patch
Type: text/x-patch
Size: 1381 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170105/ef086cc9/attachment.bin>


More information about the llvm-commits mailing list