diff options
author | Mark Seaborn <mseaborn@chromium.org> | 2013-06-24 18:41:45 -0700 |
---|---|---|
committer | Mark Seaborn <mseaborn@chromium.org> | 2013-06-24 18:41:45 -0700 |
commit | 26c1bae3de5daa2ea28d7ee7584b98723f38c3fa (patch) | |
tree | f14d2f14ce033175a22eb0bd4bdcb93b0c52bce1 /lib/Analysis | |
parent | 9a2a4d5471baa159bfd4ed793962ec5d0841631b (diff) |
PNaCl ABI: Strip alignment info from memcpy/memmove/memset intrinsic calls
Do the same for memcpy/memmove/memset intrinsic calls that we have
already done for integer loads and stores: Remove assumptions about
pointer alignment by setting the alignment argument to 1. Make the
ABI checker require this.
BUG=https://code.google.com/p/nativeclient/issues/detail?id=3445
TEST=*.ll tests + PNaCl toolchain trybots
Review URL: https://codereview.chromium.org/17563008
Diffstat (limited to 'lib/Analysis')
-rw-r--r-- | lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp b/lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp index 1fe79757a0..9a96d19ed4 100644 --- a/lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp +++ b/lib/Analysis/NaCl/PNaClABIVerifyFunctions.cpp @@ -315,6 +315,18 @@ const char *PNaClABIVerifyFunctions::checkInstruction(const Instruction *Inst) { isa<MDNode>(Arg))) return "bad intrinsic operand"; } + // Disallow alignments other than 1 on memcpy() etc., for the + // same reason that we disallow them on integer loads and + // stores. + if (const MemIntrinsic *MemOp = dyn_cast<MemIntrinsic>(Call)) { + // Avoid the getAlignment() method here because it aborts if + // the alignment argument is not a Constant. + Value *AlignArg = MemOp->getArgOperand(3); + if (!isa<ConstantInt>(AlignArg) || + cast<ConstantInt>(AlignArg)->getZExtValue() != 1) { + return "bad alignment"; + } + } // Allow the instruction and skip the later checks. return NULL; } |