aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
authorMark Seaborn <mseaborn@chromium.org>2013-06-12 13:24:22 -0700
committerMark Seaborn <mseaborn@chromium.org>2013-06-12 13:24:22 -0700
commit2117e90c707473abc7f2d76e5625e566c79de204 (patch)
tree9bee9c908c4d57b1dde4ed4668841fe4d40a54a0 /lib/Transforms
parent062f575e014d80540f28fa7f25eab152a8ac383a (diff)
PNaCl ABI: Strip out arithmetic attributes "nsw", "nuw" and "exact"
"nsw" and "nuw" -- "no signed wrap" and "no unsigned wrap" -- are not used by the backend, which is not surprising because it makes no difference to the hardware if arithmetic overflows. Although "exact" is used by the backend to convert "sdiv exact" to an "ashr" shift, it appears that "sdiv exact" does not get used in practice, and arguably such a transformation belongs in the user toolchain, not the PNaCl translator. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3483 TEST=*.ll tests + PNaCl toolchain trybots Review URL: https://codereview.chromium.org/16746005
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/NaCl/StripAttributes.cpp8
1 files changed, 8 insertions, 0 deletions
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);
}
}
}