diff options
author | Mark Seaborn <mseaborn@chromium.org> | 2013-06-12 13:24:22 -0700 |
---|---|---|
committer | Mark Seaborn <mseaborn@chromium.org> | 2013-06-12 13:24:22 -0700 |
commit | 2117e90c707473abc7f2d76e5625e566c79de204 (patch) | |
tree | 9bee9c908c4d57b1dde4ed4668841fe4d40a54a0 /lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp | |
parent | 062f575e014d80540f28fa7f25eab152a8ac383a (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/Analysis/NaCl/PNaClABIVerifyFunctions.cpp')
-rw-r--r-- | lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp | 16 |
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; } |