[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());
|
PointerType *NewTy = cast<PointerType>(CI->getOperand(0)->getType());
|
||||||
if (!NewTy->isOpaque() && Call.isByValArgument(ix)) {
|
if (!NewTy->isOpaque() && Call.isByValArgument(ix)) {
|
||||||
Call.removeParamAttr(ix, Attribute::ByVal);
|
Call.removeParamAttr(ix, Attribute::ByVal);
|
||||||
Call.addParamAttr(
|
Call.addParamAttr(ix, Attribute::getWithByValType(
|
||||||
ix, Attribute::getWithByValType(
|
Call.getContext(),
|
||||||
Call.getContext(), NewTy->getPointerElementType()));
|
NewTy->getNonOpaquePointerElementType()));
|
||||||
}
|
}
|
||||||
Changed = true;
|
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
|
// 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
|
// call. We don't want to introduce a varargs call where one doesn't
|
||||||
// already exist.
|
// already exist.
|
||||||
PointerType *APTy = cast<PointerType>(Call.getCalledOperand()->getType());
|
if (FT->isVarArg() != Call.getFunctionType()->isVarArg())
|
||||||
if (FT->isVarArg()!=cast<FunctionType>(APTy->getPointerElementType())->isVarArg())
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// If both the callee and the cast type are varargs, we still have to make
|
// 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
|
// sure the number of fixed parameters are the same or we have the same
|
||||||
// ABI issues as if we introduce a varargs call.
|
// ABI issues as if we introduce a varargs call.
|
||||||
if (FT->isVarArg() &&
|
if (FT->isVarArg() && Call.getFunctionType()->isVarArg() &&
|
||||||
cast<FunctionType>(APTy->getPointerElementType())->isVarArg() &&
|
FT->getNumParams() != Call.getFunctionType()->getNumParams())
|
||||||
FT->getNumParams() !=
|
|
||||||
cast<FunctionType>(APTy->getPointerElementType())->getNumParams())
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue