[llvm] r318087 - Fix -Werror when compiling rL318083

Serge Guelton via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 13 13:25:35 PST 2017


Author: serge_sans_paille
Date: Mon Nov 13 13:25:35 2017
New Revision: 318087

URL: http://llvm.org/viewvc/llvm-project?rev=318087&view=rev
Log:
Fix -Werror when compiling rL318083

Statically assert the result and remove a runtime comparison, a direct consequence of the optimization introduced in rL318083.

Modified:
    llvm/trunk/include/llvm/IR/Constant.h

Modified: llvm/trunk/include/llvm/IR/Constant.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Constant.h?rev=318087&r1=318086&r2=318087&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Constant.h (original)
+++ llvm/trunk/include/llvm/IR/Constant.h Mon Nov 13 13:25:35 2017
@@ -117,8 +117,8 @@ public:
 
   //// Methods for support type inquiry through isa, cast, and dyn_cast:
   static bool classof(const Value *V) {
-    return V->getValueID() >= ConstantFirstVal &&
-           V->getValueID() <= ConstantLastVal;
+    static_assert(ConstantFirstVal == 0, "V->getValueID() >= ConstantFirstVal always succeeds");
+    return V->getValueID() <= ConstantLastVal;
   }
 
   /// This method is a special form of User::replaceUsesOfWith




More information about the llvm-commits mailing list