aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp')
-rw-r--r--lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp b/lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp
index a59f6f6682..b17fc1ab69 100644
--- a/lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp
+++ b/lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp
@@ -19,6 +19,7 @@
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Metadata.h"
+#include "llvm/IR/Operator.h"
#include "llvm/Pass.h"
#include "llvm/Support/raw_ostream.h"
@@ -322,6 +323,21 @@ const char *PNaClABIVerifyFunctions::checkInstruction(const Instruction *Inst) {
!isValidScalarOperand(Inst->getOperand(OpNum)))
return "bad operand";
}
+
+ // Check arithmetic attributes.
+ if (const OverflowingBinaryOperator *Op =
+ dyn_cast<OverflowingBinaryOperator>(Inst)) {
+ if (Op->hasNoUnsignedWrap())
+ return "has \"nuw\" attribute";
+ if (Op->hasNoSignedWrap())
+ return "has \"nsw\" attribute";
+ }
+ if (const PossiblyExactOperator *Op =
+ dyn_cast<PossiblyExactOperator>(Inst)) {
+ if (Op->isExact())
+ return "has \"exact\" attribute";
+ }
+
// Allow the instruction.
return NULL;
}