diff options
author | Igor Laevsky <igmyrj@gmail.com> | 2016-12-29 14:31:07 +0000 |
---|---|---|
committer | Igor Laevsky <igmyrj@gmail.com> | 2016-12-29 14:31:07 +0000 |
commit | 4f31e52f9456a78d579506736cd6620d3370fcd8 (patch) | |
tree | 7ff965b4319d7d2322df6adfd72fbc7777930eb1 /llvm/lib/IR/Verifier.cpp | |
parent | 17b5568bc7b7cd79dc80a8e359cf39e3a8e5a31a (diff) | |
download | bcm5719-llvm-4f31e52f9456a78d579506736cd6620d3370fcd8.tar.gz bcm5719-llvm-4f31e52f9456a78d579506736cd6620d3370fcd8.zip |
Introduce element-wise atomic memcpy intrinsic
This change adds a new intrinsic which is intended to provide memcpy functionality
with additional atomicity guarantees. Please refer to the review thread
or language reference for further details.
Differential Revision: https://reviews.llvm.org/D27133
llvm-svn: 290708
Diffstat (limited to 'llvm/lib/IR/Verifier.cpp')
-rw-r--r-- | llvm/lib/IR/Verifier.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index dc7f7bf9080..8c91f1ee9e1 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -3952,6 +3952,32 @@ void Verifier::visitIntrinsicCallSite(Intrinsic::ID ID, CallSite CS) { CS); break; } + case Intrinsic::memcpy_element_atomic: { + ConstantInt *ElementSizeCI = dyn_cast<ConstantInt>(CS.getArgOperand(3)); + Assert(ElementSizeCI, "element size of the element-wise atomic memory " + "intrinsic must be a constant int", + CS); + const APInt &ElementSizeVal = ElementSizeCI->getValue(); + Assert(ElementSizeVal.isPowerOf2(), + "element size of the element-wise atomic memory intrinsic " + "must be a power of 2", + CS); + + auto IsValidAlignment = [&](uint64_t Alignment) { + return isPowerOf2_64(Alignment) && ElementSizeVal.ule(Alignment); + }; + + uint64_t DstAlignment = CS.getParamAlignment(1), + SrcAlignment = CS.getParamAlignment(2); + + Assert(IsValidAlignment(DstAlignment), + "incorrect alignment of the destination argument", + CS); + Assert(IsValidAlignment(SrcAlignment), + "incorrect alignment of the source argument", + CS); + break; + } case Intrinsic::gcroot: case Intrinsic::gcwrite: case Intrinsic::gcread: |