[InstCombine] Remove some pointer element type accesses
One of these is guarded against opaque pointers, and the others were accessing the call function type in a rather convoluted way.
This commit is contained in:
parent
84e85e025e
commit
8d992862a0
|
@ -2783,9 +2783,9 @@ Instruction *InstCombinerImpl::visitCallBase(CallBase &Call) {
|
|||
PointerType *NewTy = cast<PointerType>(CI->getOperand(0)->getType());
|
||||
if (!NewTy->isOpaque() && Call.isByValArgument(ix)) {
|
||||
Call.removeParamAttr(ix, Attribute::ByVal);
|
||||
Call.addParamAttr(
|
||||
ix, Attribute::getWithByValType(
|
||||
Call.getContext(), NewTy->getPointerElementType()));
|
||||
Call.addParamAttr(ix, Attribute::getWithByValType(
|
||||
Call.getContext(),
|
||||
NewTy->getNonOpaquePointerElementType()));
|
||||
}
|
||||
Changed = true;
|
||||
}
|
||||
|
@ -3052,17 +3052,14 @@ bool InstCombinerImpl::transformConstExprCastCall(CallBase &Call) {
|
|||
// If the callee is just a declaration, don't change the varargsness of the
|
||||
// call. We don't want to introduce a varargs call where one doesn't
|
||||
// already exist.
|
||||
PointerType *APTy = cast<PointerType>(Call.getCalledOperand()->getType());
|
||||
if (FT->isVarArg()!=cast<FunctionType>(APTy->getPointerElementType())->isVarArg())
|
||||
if (FT->isVarArg() != Call.getFunctionType()->isVarArg())
|
||||
return false;
|
||||
|
||||
// If both the callee and the cast type are varargs, we still have to make
|
||||
// sure the number of fixed parameters are the same or we have the same
|
||||
// ABI issues as if we introduce a varargs call.
|
||||
if (FT->isVarArg() &&
|
||||
cast<FunctionType>(APTy->getPointerElementType())->isVarArg() &&
|
||||
FT->getNumParams() !=
|
||||
cast<FunctionType>(APTy->getPointerElementType())->getNumParams())
|
||||
if (FT->isVarArg() && Call.getFunctionType()->isVarArg() &&
|
||||
FT->getNumParams() != Call.getFunctionType()->getNumParams())
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue