forked from OSchip/llvm-project
[InlineCost] Remove visitUnaryInstruction()
The simplifyInstruction() in visitUnaryInstruction() does not trigger for all of check-llvm. Looking at all delegates to UnaryInstruction in InstVisitor, the only instructions that either don't have a visitor in CallAnalyzer, or redirect to UnaryInstruction, are VAArgInst and Alloca. VAArgInst will never get simplified, and visitUnaryInstruction(Alloca) would always return false anyway. Reviewed By: mtrofin, lebedev.ri Differential Revision: https://reviews.llvm.org/D101577
This commit is contained in:
parent
544be70864
commit
a3a798d49d
|
@ -390,7 +390,6 @@ protected:
|
||||||
bool visitPtrToInt(PtrToIntInst &I);
|
bool visitPtrToInt(PtrToIntInst &I);
|
||||||
bool visitIntToPtr(IntToPtrInst &I);
|
bool visitIntToPtr(IntToPtrInst &I);
|
||||||
bool visitCastInst(CastInst &I);
|
bool visitCastInst(CastInst &I);
|
||||||
bool visitUnaryInstruction(UnaryInstruction &I);
|
|
||||||
bool visitCmpInst(CmpInst &I);
|
bool visitCmpInst(CmpInst &I);
|
||||||
bool visitSub(BinaryOperator &I);
|
bool visitSub(BinaryOperator &I);
|
||||||
bool visitBinaryOperator(BinaryOperator &I);
|
bool visitBinaryOperator(BinaryOperator &I);
|
||||||
|
@ -1040,6 +1039,8 @@ bool CallAnalyzer::isGEPFree(GetElementPtrInst &GEP) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CallAnalyzer::visitAlloca(AllocaInst &I) {
|
bool CallAnalyzer::visitAlloca(AllocaInst &I) {
|
||||||
|
disableSROA(I.getOperand(0));
|
||||||
|
|
||||||
// Check whether inlining will turn a dynamic alloca into a static
|
// Check whether inlining will turn a dynamic alloca into a static
|
||||||
// alloca and handle that case.
|
// alloca and handle that case.
|
||||||
if (I.isArrayAllocation()) {
|
if (I.isArrayAllocation()) {
|
||||||
|
@ -1057,12 +1058,10 @@ bool CallAnalyzer::visitAlloca(AllocaInst &I) {
|
||||||
AllocatedSize = SaturatingMultiplyAdd(
|
AllocatedSize = SaturatingMultiplyAdd(
|
||||||
AllocSize->getLimitedValue(), DL.getTypeAllocSize(Ty).getKnownMinSize(),
|
AllocSize->getLimitedValue(), DL.getTypeAllocSize(Ty).getKnownMinSize(),
|
||||||
AllocatedSize);
|
AllocatedSize);
|
||||||
if (AllocatedSize > InlineConstants::MaxSimplifiedDynamicAllocaToInline) {
|
if (AllocatedSize > InlineConstants::MaxSimplifiedDynamicAllocaToInline)
|
||||||
HasDynamicAlloca = true;
|
HasDynamicAlloca = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return Base::visitAlloca(I);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Accumulate the allocated size.
|
// Accumulate the allocated size.
|
||||||
|
@ -1072,15 +1071,13 @@ bool CallAnalyzer::visitAlloca(AllocaInst &I) {
|
||||||
SaturatingAdd(DL.getTypeAllocSize(Ty).getKnownMinSize(), AllocatedSize);
|
SaturatingAdd(DL.getTypeAllocSize(Ty).getKnownMinSize(), AllocatedSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We will happily inline static alloca instructions.
|
|
||||||
if (I.isStaticAlloca())
|
|
||||||
return Base::visitAlloca(I);
|
|
||||||
|
|
||||||
// FIXME: This is overly conservative. Dynamic allocas are inefficient for
|
// FIXME: This is overly conservative. Dynamic allocas are inefficient for
|
||||||
// a variety of reasons, and so we would like to not inline them into
|
// a variety of reasons, and so we would like to not inline them into
|
||||||
// functions which don't currently have a dynamic alloca. This simply
|
// functions which don't currently have a dynamic alloca. This simply
|
||||||
// disables inlining altogether in the presence of a dynamic alloca.
|
// disables inlining altogether in the presence of a dynamic alloca.
|
||||||
|
if (!I.isStaticAlloca())
|
||||||
HasDynamicAlloca = true;
|
HasDynamicAlloca = true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1367,19 +1364,6 @@ bool CallAnalyzer::visitCastInst(CastInst &I) {
|
||||||
TargetTransformInfo::TCC_Free;
|
TargetTransformInfo::TCC_Free;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CallAnalyzer::visitUnaryInstruction(UnaryInstruction &I) {
|
|
||||||
Value *Operand = I.getOperand(0);
|
|
||||||
if (simplifyInstruction(I, [&](SmallVectorImpl<Constant *> &COps) {
|
|
||||||
return ConstantFoldInstOperands(&I, COps[0], DL);
|
|
||||||
}))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// Disable any SROA on the argument to arbitrary unary instructions.
|
|
||||||
disableSROA(Operand);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CallAnalyzer::paramHasAttr(Argument *A, Attribute::AttrKind Attr) {
|
bool CallAnalyzer::paramHasAttr(Argument *A, Attribute::AttrKind Attr) {
|
||||||
return CandidateCall.paramHasAttr(A->getArgNo(), Attr);
|
return CandidateCall.paramHasAttr(A->getArgNo(), Attr);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue