diff options
author | Pete Cooper <peter_cooper@apple.com> | 2015-11-19 05:56:52 +0000 |
---|---|---|
committer | Pete Cooper <peter_cooper@apple.com> | 2015-11-19 05:56:52 +0000 |
commit | 67cf9a723ba5cf0a711efcb317b241104b558779 (patch) | |
tree | e362be29f8f95e45470715ea59a93f2b8ad86de9 /llvm/lib/IR | |
parent | 3b39e88ae0e1f260ebb89f874d8006cb0b87fd2f (diff) | |
download | bcm5719-llvm-67cf9a723ba5cf0a711efcb317b241104b558779.tar.gz bcm5719-llvm-67cf9a723ba5cf0a711efcb317b241104b558779.zip |
Revert "Change memcpy/memset/memmove to have dest and source alignments."
This reverts commit r253511.
This likely broke the bots in
http://lab.llvm.org:8011/builders/clang-ppc64-elf-linux2/builds/20202
http://bb.pgr.jp/builders/clang-3stage-i686-linux/builds/3787
llvm-svn: 253543
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r-- | llvm/lib/IR/Attributes.cpp | 5 | ||||
-rw-r--r-- | llvm/lib/IR/AutoUpgrade.cpp | 55 | ||||
-rw-r--r-- | llvm/lib/IR/IRBuilder.cpp | 25 | ||||
-rw-r--r-- | llvm/lib/IR/Verifier.cpp | 2 |
4 files changed, 12 insertions, 75 deletions
diff --git a/llvm/lib/IR/Attributes.cpp b/llvm/lib/IR/Attributes.cpp index fe09c47fb48..bdefe5917fe 100644 --- a/llvm/lib/IR/Attributes.cpp +++ b/llvm/lib/IR/Attributes.cpp @@ -830,6 +830,11 @@ AttributeSet AttributeSet::removeAttributes(LLVMContext &C, unsigned Index, if (!pImpl) return AttributeSet(); if (!Attrs.pImpl) return *this; + // FIXME it is not obvious how this should work for alignment. + // For now, say we can't pass in alignment, which no current use does. + assert(!Attrs.hasAttribute(Index, Attribute::Alignment) && + "Attempt to change alignment!"); + // Add the attribute slots before the one we're trying to add. SmallVector<AttributeSet, 4> AttrSet; uint64_t NumAttrs = pImpl->getNumAttributes(); diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp index c83313fa654..12c354c89b2 100644 --- a/llvm/lib/IR/AutoUpgrade.cpp +++ b/llvm/lib/IR/AutoUpgrade.cpp @@ -144,36 +144,6 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) { } break; } - case 'm': { - if (Name.startswith("memcpy.") && F->arg_size() == 5) { - F->setName(Name + ".old"); - // Get the types of dest, src, and len. - ArrayRef<Type *> ParamTypes = F->getFunctionType()->params().slice(0, 3); - NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::memcpy, - ParamTypes); - return true; - } - if (Name.startswith("memmove.") && F->arg_size() == 5) { - F->setName(Name + ".old"); - // Get the types of dest, src, and len. - ArrayRef<Type *> ParamTypes = F->getFunctionType()->params().slice(0, 3); - NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::memmove, - ParamTypes); - return true; - } - if (Name.startswith("memset.") && F->arg_size() == 5) { - F->setName(Name + ".old"); - // Get the types of dest and len. - Type *ParamTypes[2] = { - F->getFunctionType()->getParamType(0), - F->getFunctionType()->getParamType(2) - }; - NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::memset, - ParamTypes); - return true; - } - break; - } case 'o': // We only need to change the name to match the mangling including the @@ -757,31 +727,6 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { CI->eraseFromParent(); return; - case Intrinsic::memcpy: - case Intrinsic::memmove: - case Intrinsic::memset: { - // Remove alignment argument (3), and add alignment attributes to the - // dest/src pointers. - Value *Args[4] = { - CI->getArgOperand(0), - CI->getArgOperand(1), - CI->getArgOperand(2), - CI->getArgOperand(4) - }; - auto *MemCI = cast<MemIntrinsic>(Builder.CreateCall(NewFn, Args, Name)); - - // All mem intrinsics support dest alignment. - const ConstantInt *Align = cast<ConstantInt>(CI->getArgOperand(3)); - MemCI->setDestAlignment(Align->getZExtValue()); - - // Memcpy/Memmove also support source alignment. - if (auto *MemTransferI = dyn_cast<MemTransferInst>(MemCI)) - MemTransferI->setSrcAlignment(Align->getZExtValue()); - CI->replaceAllUsesWith(MemCI); - CI->eraseFromParent(); - return; - } - case Intrinsic::objectsize: CI->replaceAllUsesWith(Builder.CreateCall( NewFn, {CI->getArgOperand(0), CI->getArgOperand(1)}, Name)); diff --git a/llvm/lib/IR/IRBuilder.cpp b/llvm/lib/IR/IRBuilder.cpp index b07f15515ad..44741293633 100644 --- a/llvm/lib/IR/IRBuilder.cpp +++ b/llvm/lib/IR/IRBuilder.cpp @@ -15,7 +15,6 @@ #include "llvm/IR/Function.h" #include "llvm/IR/GlobalVariable.h" #include "llvm/IR/IRBuilder.h" -#include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/Intrinsics.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Statepoint.h" @@ -80,11 +79,11 @@ static InvokeInst *createInvokeHelper(Value *Invokee, BasicBlock *NormalDest, } CallInst *IRBuilderBase:: -CreateMemSet(Value *Ptr, Value *Val, Value *Size, unsigned DstAlign, +CreateMemSet(Value *Ptr, Value *Val, Value *Size, unsigned Align, bool isVolatile, MDNode *TBAATag, MDNode *ScopeTag, MDNode *NoAliasTag) { Ptr = getCastedInt8PtrValue(Ptr); - Value *Ops[] = { Ptr, Val, Size, getInt1(isVolatile) }; + Value *Ops[] = { Ptr, Val, Size, getInt32(Align), getInt1(isVolatile) }; Type *Tys[] = { Ptr->getType(), Size->getType() }; Module *M = BB->getParent()->getParent(); Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys); @@ -100,21 +99,18 @@ CreateMemSet(Value *Ptr, Value *Val, Value *Size, unsigned DstAlign, if (NoAliasTag) CI->setMetadata(LLVMContext::MD_noalias, NoAliasTag); - - cast<MemSetInst>(CI)->setDestAlignment(DstAlign); return CI; } CallInst *IRBuilderBase:: -CreateMemCpy(Value *Dst, Value *Src, Value *Size, unsigned DstAlign, - IntegerAlignment SrcAlign, +CreateMemCpy(Value *Dst, Value *Src, Value *Size, unsigned Align, bool isVolatile, MDNode *TBAATag, MDNode *TBAAStructTag, MDNode *ScopeTag, MDNode *NoAliasTag) { Dst = getCastedInt8PtrValue(Dst); Src = getCastedInt8PtrValue(Src); - Value *Ops[] = { Dst, Src, Size, getInt1(isVolatile) }; + Value *Ops[] = { Dst, Src, Size, getInt32(Align), getInt1(isVolatile) }; Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() }; Module *M = BB->getParent()->getParent(); Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memcpy, Tys); @@ -134,23 +130,18 @@ CreateMemCpy(Value *Dst, Value *Src, Value *Size, unsigned DstAlign, if (NoAliasTag) CI->setMetadata(LLVMContext::MD_noalias, NoAliasTag); - - auto *MCI = cast<MemCpyInst>(CI); - MCI->setDestAlignment(DstAlign); - MCI->setSrcAlignment(SrcAlign); return CI; } CallInst *IRBuilderBase:: -CreateMemMove(Value *Dst, Value *Src, Value *Size, unsigned DstAlign, - IntegerAlignment SrcAlign, +CreateMemMove(Value *Dst, Value *Src, Value *Size, unsigned Align, bool isVolatile, MDNode *TBAATag, MDNode *ScopeTag, MDNode *NoAliasTag) { Dst = getCastedInt8PtrValue(Dst); Src = getCastedInt8PtrValue(Src); - Value *Ops[] = { Dst, Src, Size, getInt1(isVolatile) }; + Value *Ops[] = { Dst, Src, Size, getInt32(Align), getInt1(isVolatile) }; Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() }; Module *M = BB->getParent()->getParent(); Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memmove, Tys); @@ -166,10 +157,6 @@ CreateMemMove(Value *Dst, Value *Src, Value *Size, unsigned DstAlign, if (NoAliasTag) CI->setMetadata(LLVMContext::MD_noalias, NoAliasTag); - - auto *MMI = cast<MemMoveInst>(CI); - MMI->setDestAlignment(DstAlign); - MMI->setSrcAlignment(SrcAlign); return CI; } diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 86e30620dec..cf7b4cac342 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -3511,7 +3511,7 @@ void Verifier::visitIntrinsicCallSite(Intrinsic::ID ID, CallSite CS) { const APInt &AlignVal = AlignCI->getValue(); Assert(AlignCI->isZero() || AlignVal.isPowerOf2(), "alignment argument of memory intrinsics must be a power of 2", CS); - Assert(isa<ConstantInt>(CS.getArgOperand(3)), + Assert(isa<ConstantInt>(CS.getArgOperand(4)), "isvolatile argument of memory intrinsics must be a constant int", CS); break; |