aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore
diff options
context:
space:
mode:
authorAnton Korobeynikov <asl@math.spbu.ru>2007-10-28 22:50:32 +0000
committerAnton Korobeynikov <asl@math.spbu.ru>2007-10-28 22:50:32 +0000
commit536c64b4d6e67477fafadb830b6a5bf81cf5652d (patch)
tree62bdb65ae1470563a0bee1e268928606502794e6 /lib/VMCore
parent5973ef40ca290903e0b3a4952162c14b55af5d72 (diff)
downloadexternal_llvm-536c64b4d6e67477fafadb830b6a5bf81cf5652d.zip
external_llvm-536c64b4d6e67477fafadb830b6a5bf81cf5652d.tar.gz
external_llvm-536c64b4d6e67477fafadb830b6a5bf81cf5652d.tar.bz2
Add 'pedantic' mode to verifier rejecting syntactically valid, but 'bad' due to other reasons code
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43424 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/Verifier.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp
index 000fa6b..1d35d65 100644
--- a/lib/VMCore/Verifier.cpp
+++ b/lib/VMCore/Verifier.cpp
@@ -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 @@ void Verifier::visitCallInst(CallInst &CI) {
"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);
}