[llvm] a162ddf - [InstCombine] Remove various checks for opaque pointers (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 6 00:45:59 PDT 2023
Author: Nikita Popov
Date: 2023-04-06T09:45:51+02:00
New Revision: a162ddf7f2f66af5a797d2bc0c78e628bb8c43fe
URL: https://github.com/llvm/llvm-project/commit/a162ddf7f2f66af5a797d2bc0c78e628bb8c43fe
DIFF: https://github.com/llvm/llvm-project/commit/a162ddf7f2f66af5a797d2bc0c78e628bb8c43fe.diff
LOG: [InstCombine] Remove various checks for opaque pointers (NFC)
All pointers are opaque now, so these are no longer necessary.
Added:
Modified:
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 71700506624c..fbbd6465f328 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -3642,24 +3642,6 @@ bool InstCombinerImpl::transformConstExprCastCall(CallBase &Call) {
if (CallerPAL.hasParamAttr(i, Attribute::ByVal) !=
Callee->getAttributes().hasParamAttr(i, Attribute::ByVal))
return false; // Cannot transform to or from byval.
-
- // If the parameter is passed as a byval argument, then we have to have a
- // sized type and the sized type has to have the same size as the old type.
- if (ParamTy != ActTy && CallerPAL.hasParamAttr(i, Attribute::ByVal)) {
- PointerType *ParamPTy = dyn_cast<PointerType>(ParamTy);
- if (!ParamPTy)
- return false;
-
- if (!ParamPTy->isOpaque()) {
- Type *ParamElTy = ParamPTy->getNonOpaquePointerElementType();
- if (!ParamElTy->isSized())
- return false;
-
- Type *CurElTy = Call.getParamByValType(i);
- if (DL.getTypeAllocSize(CurElTy) != DL.getTypeAllocSize(ParamElTy))
- return false;
- }
- }
}
if (Callee->isDeclaration()) {
@@ -3720,16 +3702,8 @@ bool InstCombinerImpl::transformConstExprCastCall(CallBase &Call) {
// type. Note that we made sure all incompatible ones are safe to drop.
AttributeMask IncompatibleAttrs = AttributeFuncs::typeIncompatible(
ParamTy, AttributeFuncs::ASK_SAFE_TO_DROP);
- if (CallerPAL.hasParamAttr(i, Attribute::ByVal) &&
- !ParamTy->isOpaquePointerTy()) {
- AttrBuilder AB(Ctx, CallerPAL.getParamAttrs(i).removeAttributes(
- Ctx, IncompatibleAttrs));
- AB.addByValAttr(ParamTy->getNonOpaquePointerElementType());
- ArgAttrs.push_back(AttributeSet::get(Ctx, AB));
- } else {
- ArgAttrs.push_back(
- CallerPAL.getParamAttrs(i).removeAttributes(Ctx, IncompatibleAttrs));
- }
+ ArgAttrs.push_back(
+ CallerPAL.getParamAttrs(i).removeAttributes(Ctx, IncompatibleAttrs));
}
// If the function takes more arguments than the call was taking, add them
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index 4177f64c6abe..236ebf4bebc8 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -1976,9 +1976,8 @@ Instruction *InstCombinerImpl::visitGEPOfGEP(GetElementPtrInst &GEP,
return nullptr; // Wait until our source is folded to completion.
// For constant GEPs, use a more general offset-based folding approach.
- // Only do this for opaque pointers, as the result element type may change.
Type *PtrTy = Src->getType()->getScalarType();
- if (PtrTy->isOpaquePointerTy() && GEP.hasAllConstantIndices() &&
+ if (GEP.hasAllConstantIndices() &&
(Src->hasOneUse() || Src->hasAllConstantIndices())) {
// Split Src into a variable part and a constant suffix.
gep_type_iterator GTI = gep_type_begin(*Src);
More information about the llvm-commits
mailing list