[PATCH] D19334: [MC] EmitNop: Make an assertion more useful

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 20 10:47:27 PDT 2016


davide created this revision.
davide added a reviewer: sanjoy.
davide added a subscriber: llvm-commits.

NumBytes is an unsigned so this will never fire. I assume this might be what you wanted to do originally. 

http://reviews.llvm.org/D19334

Files:
  lib/Target/X86/X86MCInstLower.cpp

Index: lib/Target/X86/X86MCInstLower.cpp
===================================================================
--- lib/Target/X86/X86MCInstLower.cpp
+++ lib/Target/X86/X86MCInstLower.cpp
@@ -837,9 +837,10 @@
 /// \brief Emit the optimal amount of multi-byte nops on X86.
 static void EmitNops(MCStreamer &OS, unsigned NumBytes, bool Is64Bit,
                      const MCSubtargetInfo &STI) {
+  unsigned NopsToEmit = NumBytes;
   while (NumBytes) {
     NumBytes -= EmitNop(OS, NumBytes, Is64Bit, STI);
-    assert(NumBytes >= 0 && "Emitted more than I asked for!");
+    assert(NopsToEmit >= NumBytes && "Emitted more than I asked for!");
   }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19334.54391.patch
Type: text/x-patch
Size: 650 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160420/5850dc00/attachment.bin>


More information about the llvm-commits mailing list