aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp16
-rw-r--r--lib/Transforms/NaCl/StripAttributes.cpp8
2 files changed, 24 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;
}
diff --git a/lib/Transforms/NaCl/StripAttributes.cpp b/lib/Transforms/NaCl/StripAttributes.cpp
index 476c500756..8074353472 100644
--- a/lib/Transforms/NaCl/StripAttributes.cpp
+++ b/lib/Transforms/NaCl/StripAttributes.cpp
@@ -22,6 +22,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/IR/Function.h"
+#include "llvm/IR/Operator.h"
#include "llvm/Pass.h"
#include "llvm/Support/CallSite.h"
#include "llvm/Transforms/NaCl.h"
@@ -144,6 +145,13 @@ bool StripAttributes::runOnFunction(Function &Func) {
CheckAttributes(Call.getAttributes());
Call.setAttributes(AttributeSet());
Call.setCallingConv(CallingConv::C);
+ } else if (OverflowingBinaryOperator *Op =
+ dyn_cast<OverflowingBinaryOperator>(Inst)) {
+ cast<BinaryOperator>(Op)->setHasNoUnsignedWrap(false);
+ cast<BinaryOperator>(Op)->setHasNoSignedWrap(false);
+ } else if (PossiblyExactOperator *Op =
+ dyn_cast<PossiblyExactOperator>(Inst)) {
+ cast<BinaryOperator>(Op)->setIsExact(false);
}
}
}