forked from OSchip/llvm-project
change the MemIntrinsic get/setAlignment method to take an unsigned
instead of a Constant*, which is what the clients of it really want. llvm-svn: 66364
This commit is contained in:
parent
de22116f39
commit
dc35e5b43a
|
@ -176,9 +176,13 @@ namespace llvm {
|
||||||
Value *getRawDest() const { return const_cast<Value*>(getOperand(1)); }
|
Value *getRawDest() const { return const_cast<Value*>(getOperand(1)); }
|
||||||
|
|
||||||
Value *getLength() const { return const_cast<Value*>(getOperand(3)); }
|
Value *getLength() const { return const_cast<Value*>(getOperand(3)); }
|
||||||
ConstantInt *getAlignment() const {
|
ConstantInt *getAlignmentCst() const {
|
||||||
return cast<ConstantInt>(const_cast<Value*>(getOperand(4)));
|
return cast<ConstantInt>(const_cast<Value*>(getOperand(4)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned getAlignment() const {
|
||||||
|
return getAlignmentCst()->getZExtValue();
|
||||||
|
}
|
||||||
|
|
||||||
/// getDest - This is just like getRawDest, but it strips off any cast
|
/// getDest - This is just like getRawDest, but it strips off any cast
|
||||||
/// instructions that feed it, giving the original input. The returned
|
/// instructions that feed it, giving the original input. The returned
|
||||||
|
@ -198,12 +202,11 @@ namespace llvm {
|
||||||
"setLength called with value of wrong type!");
|
"setLength called with value of wrong type!");
|
||||||
setOperand(3, L);
|
setOperand(3, L);
|
||||||
}
|
}
|
||||||
void setAlignment(ConstantInt *A) {
|
void setAlignment(unsigned A) {
|
||||||
assert(getAlignment()->getType() == A->getType() &&
|
const Type *Int32Ty = getOperand(4)->getType();
|
||||||
"setAlignment called with value of wrong type!");
|
setOperand(4, ConstantInt::get(Int32Ty, A));
|
||||||
setOperand(4, A);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||||
static inline bool classof(const MemIntrinsic *) { return true; }
|
static inline bool classof(const MemIntrinsic *) { return true; }
|
||||||
static inline bool classof(const IntrinsicInst *I) {
|
static inline bool classof(const IntrinsicInst *I) {
|
||||||
|
|
|
@ -9302,10 +9302,10 @@ Instruction *InstCombiner::SimplifyMemTransfer(MemIntrinsic *MI) {
|
||||||
unsigned DstAlign = GetOrEnforceKnownAlignment(MI->getOperand(1));
|
unsigned DstAlign = GetOrEnforceKnownAlignment(MI->getOperand(1));
|
||||||
unsigned SrcAlign = GetOrEnforceKnownAlignment(MI->getOperand(2));
|
unsigned SrcAlign = GetOrEnforceKnownAlignment(MI->getOperand(2));
|
||||||
unsigned MinAlign = std::min(DstAlign, SrcAlign);
|
unsigned MinAlign = std::min(DstAlign, SrcAlign);
|
||||||
unsigned CopyAlign = MI->getAlignment()->getZExtValue();
|
unsigned CopyAlign = MI->getAlignment();
|
||||||
|
|
||||||
if (CopyAlign < MinAlign) {
|
if (CopyAlign < MinAlign) {
|
||||||
MI->setAlignment(ConstantInt::get(Type::Int32Ty, MinAlign));
|
MI->setAlignment(MinAlign);
|
||||||
return MI;
|
return MI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9377,8 +9377,8 @@ Instruction *InstCombiner::SimplifyMemTransfer(MemIntrinsic *MI) {
|
||||||
|
|
||||||
Instruction *InstCombiner::SimplifyMemSet(MemSetInst *MI) {
|
Instruction *InstCombiner::SimplifyMemSet(MemSetInst *MI) {
|
||||||
unsigned Alignment = GetOrEnforceKnownAlignment(MI->getDest());
|
unsigned Alignment = GetOrEnforceKnownAlignment(MI->getDest());
|
||||||
if (MI->getAlignment()->getZExtValue() < Alignment) {
|
if (MI->getAlignment() < Alignment) {
|
||||||
MI->setAlignment(ConstantInt::get(Type::Int32Ty, Alignment));
|
MI->setAlignment(Alignment);
|
||||||
return MI;
|
return MI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9388,7 +9388,7 @@ Instruction *InstCombiner::SimplifyMemSet(MemSetInst *MI) {
|
||||||
if (!LenC || !FillC || FillC->getType() != Type::Int8Ty)
|
if (!LenC || !FillC || FillC->getType() != Type::Int8Ty)
|
||||||
return 0;
|
return 0;
|
||||||
uint64_t Len = LenC->getZExtValue();
|
uint64_t Len = LenC->getZExtValue();
|
||||||
Alignment = MI->getAlignment()->getZExtValue();
|
Alignment = MI->getAlignment();
|
||||||
|
|
||||||
// If the length is zero, this is a no-op
|
// If the length is zero, this is a no-op
|
||||||
if (Len == 0) return MI; // memset(d,c,0,a) -> noop
|
if (Len == 0) return MI; // memset(d,c,0,a) -> noop
|
||||||
|
|
|
@ -678,13 +678,11 @@ bool MemCpyOpt::processMemCpy(MemCpyInst* M) {
|
||||||
M->getParent()->getParent()->getParent(),
|
M->getParent()->getParent()->getParent(),
|
||||||
M->getIntrinsicID(), Tys, 1);
|
M->getIntrinsicID(), Tys, 1);
|
||||||
|
|
||||||
std::vector<Value*> args;
|
Value *Args[4] = {
|
||||||
args.push_back(M->getRawDest());
|
M->getRawDest(), MDep->getRawSource(), M->getLength(), M->getAlignmentCst()
|
||||||
args.push_back(MDep->getRawSource());
|
};
|
||||||
args.push_back(M->getLength());
|
|
||||||
args.push_back(M->getAlignment());
|
|
||||||
|
|
||||||
CallInst* C = CallInst::Create(MemCpyFun, args.begin(), args.end(), "", M);
|
CallInst* C = CallInst::Create(MemCpyFun, Args, Args+4, "", M);
|
||||||
|
|
||||||
|
|
||||||
// If C and M don't interfere, then this is a valid transformation. If they
|
// If C and M don't interfere, then this is a valid transformation. If they
|
||||||
|
|
|
@ -725,7 +725,7 @@ void SROA::RewriteMemIntrinUserOfAlloca(MemIntrinsic *MI, Instruction *BCInst,
|
||||||
// that doesn't have anything to do with the alloca that we are promoting. For
|
// that doesn't have anything to do with the alloca that we are promoting. For
|
||||||
// memset, this Value* stays null.
|
// memset, this Value* stays null.
|
||||||
Value *OtherPtr = 0;
|
Value *OtherPtr = 0;
|
||||||
unsigned MemAlignment = MI->getAlignment()->getZExtValue();
|
unsigned MemAlignment = MI->getAlignment();
|
||||||
if (MemTransferInst *MTI = dyn_cast<MemTransferInst>(MI)) { // memmove/memcopy
|
if (MemTransferInst *MTI = dyn_cast<MemTransferInst>(MI)) { // memmove/memcopy
|
||||||
if (BCInst == MTI->getRawDest())
|
if (BCInst == MTI->getRawDest())
|
||||||
OtherPtr = MTI->getRawSource();
|
OtherPtr = MTI->getRawSource();
|
||||||
|
@ -1356,7 +1356,7 @@ bool SROA::CanConvertToScalar(Value *V, bool &IsNotTrivial, const Type *&VecTy,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ignore dbg intrinsic.
|
// Ignore dbg intrinsic.
|
||||||
if (isa<DbgInfoIntrinsic>(User))
|
if (isa<DbgInfoIntrinsic>(User))
|
||||||
continue;
|
continue;
|
||||||
|
@ -1440,7 +1440,7 @@ void SROA::ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, uint64_t Offset) {
|
||||||
MSI->eraseFromParent();
|
MSI->eraseFromParent();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If user is a dbg info intrinsic then it is safe to remove it.
|
// If user is a dbg info intrinsic then it is safe to remove it.
|
||||||
if (isa<DbgInfoIntrinsic>(User)) {
|
if (isa<DbgInfoIntrinsic>(User)) {
|
||||||
User->eraseFromParent();
|
User->eraseFromParent();
|
||||||
|
|
Loading…
Reference in New Issue