[llvm-commits] [llvm] r43424 - /llvm/trunk/lib/VMCore/Verifier.cpp

Anton Korobeynikov asl at math.spbu.ru
Sun Oct 28 15:50:32 PDT 2007


Author: asl
Date: Sun Oct 28 17:50:32 2007
New Revision: 43424

URL: http://llvm.org/viewvc/llvm-project?rev=43424&view=rev
Log:
Add 'pedantic' mode to verifier rejecting syntactically valid, but 'bad' due to other reasons code

Modified:
    llvm/trunk/lib/VMCore/Verifier.cpp

Modified: llvm/trunk/lib/VMCore/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=43424&r1=43423&r2=43424&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Verifier.cpp (original)
+++ llvm/trunk/lib/VMCore/Verifier.cpp Sun Oct 28 17:50:32 2007
@@ -60,6 +60,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Compiler.h"
 #include <algorithm>
 #include <sstream>
@@ -67,7 +68,10 @@
 using namespace llvm;
 
 namespace {  // Anonymous namespace for class
-
+  cl::opt<bool>
+  Pedantic("pedantic",
+           cl::desc("Reject code with undefined behaviour"));
+    
   struct VISIBILITY_HIDDEN
      Verifier : public FunctionPass, InstVisitor<Verifier> {
     static char ID; // Pass ID, replacement for typeid
@@ -806,10 +810,17 @@
             "Call parameter type does not match function signature!",
             CI.getOperand(i+1), FTy->getParamType(i), &CI);
 
-  if (Function *F = CI.getCalledFunction())
+  if (Function *F = CI.getCalledFunction()) {
+    if (Pedantic) {
+      // Verify that calling convention of Function and CallInst match
+      Assert1(F->getCallingConv() == CI.getCallingConv(),
+              "Call uses different calling convention than function", &CI);
+    }
+    
     if (Intrinsic::ID ID = (Intrinsic::ID)F->getIntrinsicID())
       visitIntrinsicFunctionCall(ID, CI);
-
+  }
+  
   visitInstruction(CI);
 }
 





More information about the llvm-commits mailing list