aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2022-01-27 10:14:44 +0100
committerNikita Popov <npopov@redhat.com>2022-01-27 10:15:35 +0100
commit8d992862a0281d595d08d172ab6fb48f8cd7395c (patch)
tree1b3faad7b8506e1bcab7a1debb2c4646cd9a751b /llvm/lib/Transforms
parent84e85e025e02211d1f24ea423cd1be8945e70009 (diff)
downloadllvm-8d992862a0281d595d08d172ab6fb48f8cd7395c.zip
llvm-8d992862a0281d595d08d172ab6fb48f8cd7395c.tar.gz
llvm-8d992862a0281d595d08d172ab6fb48f8cd7395c.tar.bz2
[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.
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index bfe09da..1fb46af 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -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;
}