aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/InlineFunction.cpp
diff options
context:
space:
mode:
authorGuillaume Chatelet <gchatelet@google.com>2023-01-13 15:50:38 +0000
committerGuillaume Chatelet <gchatelet@google.com>2023-01-13 16:20:58 +0000
commitb55f83d013eff244f7cf6bfcd06f06f7c894ff28 (patch)
tree75edc213874b916d9f4873345e9c7e115923c4d0 /llvm/lib/Transforms/Utils/InlineFunction.cpp
parentc9ab87df9dce9aa5da1daf4a3d1f43076733e5f2 (diff)
downloadllvm-b55f83d013eff244f7cf6bfcd06f06f7c894ff28.zip
llvm-b55f83d013eff244f7cf6bfcd06f06f7c894ff28.tar.gz
llvm-b55f83d013eff244f7cf6bfcd06f06f7c894ff28.tar.bz2
[NFC] Remove Function::getParamAlignment
Differential Revision: https://reviews.llvm.org/D141696
Diffstat (limited to 'llvm/lib/Transforms/Utils/InlineFunction.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/InlineFunction.cpp47
1 files changed, 25 insertions, 22 deletions
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp
index ceb2f52..9370c73 100644
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp
@@ -1437,23 +1437,26 @@ static void AddAlignmentAssumptions(CallBase &CB, InlineFunctionInfo &IFI) {
Function *CalledFunc = CB.getCalledFunction();
for (Argument &Arg : CalledFunc->args()) {
- unsigned Align = Arg.getType()->isPointerTy() ? Arg.getParamAlignment() : 0;
- if (Align && !Arg.hasPassPointeeByValueCopyAttr() && !Arg.hasNUses(0)) {
- if (!DTCalculated) {
- DT.recalculate(*CB.getCaller());
- DTCalculated = true;
- }
-
- // If we can already prove the asserted alignment in the context of the
- // caller, then don't bother inserting the assumption.
- Value *ArgVal = CB.getArgOperand(Arg.getArgNo());
- if (getKnownAlignment(ArgVal, DL, &CB, AC, &DT) >= Align)
- continue;
+ if (!Arg.getType()->isPointerTy() || Arg.hasPassPointeeByValueCopyAttr() ||
+ Arg.hasNUses(0))
+ continue;
+ MaybeAlign Alignment = Arg.getParamAlign();
+ if (!Alignment)
+ continue;
- CallInst *NewAsmp =
- IRBuilder<>(&CB).CreateAlignmentAssumption(DL, ArgVal, Align);
- AC->registerAssumption(cast<AssumeInst>(NewAsmp));
+ if (!DTCalculated) {
+ DT.recalculate(*CB.getCaller());
+ DTCalculated = true;
}
+ // If we can already prove the asserted alignment in the context of the
+ // caller, then don't bother inserting the assumption.
+ Value *ArgVal = CB.getArgOperand(Arg.getArgNo());
+ if (getKnownAlignment(ArgVal, DL, &CB, AC, &DT) >= *Alignment)
+ continue;
+
+ CallInst *NewAsmp = IRBuilder<>(&CB).CreateAlignmentAssumption(
+ DL, ArgVal, Alignment->value());
+ AC->registerAssumption(cast<AssumeInst>(NewAsmp));
}
}
@@ -1553,7 +1556,7 @@ static Value *HandleByValArgument(Type *ByValType, Value *Arg,
Instruction *TheCall,
const Function *CalledFunc,
InlineFunctionInfo &IFI,
- unsigned ByValAlignment) {
+ MaybeAlign ByValAlignment) {
assert(cast<PointerType>(Arg->getType())
->isOpaqueOrPointeeTypeMatches(ByValType));
Function *Caller = TheCall->getFunction();
@@ -1566,7 +1569,7 @@ static Value *HandleByValArgument(Type *ByValType, Value *Arg,
// If the byval argument has a specified alignment that is greater than the
// passed in pointer, then we either have to round up the input pointer or
// give up on this transformation.
- if (ByValAlignment <= 1) // 0 = unspecified, 1 = no particular alignment.
+ if (ByValAlignment.valueOrOne() == 1)
return Arg;
AssumptionCache *AC =
@@ -1574,8 +1577,8 @@ static Value *HandleByValArgument(Type *ByValType, Value *Arg,
// If the pointer is already known to be sufficiently aligned, or if we can
// round it up to a larger alignment, then we don't need a temporary.
- if (getOrEnforceKnownAlignment(Arg, Align(ByValAlignment), DL, TheCall,
- AC) >= ByValAlignment)
+ if (getOrEnforceKnownAlignment(Arg, *ByValAlignment, DL, TheCall, AC) >=
+ *ByValAlignment)
return Arg;
// Otherwise, we have to make a memcpy to get a safe alignment. This is bad
@@ -1588,8 +1591,8 @@ static Value *HandleByValArgument(Type *ByValType, Value *Arg,
// If the byval had an alignment specified, we *must* use at least that
// alignment, as it is required by the byval argument (and uses of the
// pointer inside the callee).
- if (ByValAlignment > 0)
- Alignment = std::max(Alignment, Align(ByValAlignment));
+ if (ByValAlignment)
+ Alignment = std::max(Alignment, *ByValAlignment);
Value *NewAlloca =
new AllocaInst(ByValType, DL.getAllocaAddrSpace(), nullptr, Alignment,
@@ -2185,7 +2188,7 @@ llvm::InlineResult llvm::InlineFunction(CallBase &CB, InlineFunctionInfo &IFI,
if (CB.isByValArgument(ArgNo)) {
ActualArg = HandleByValArgument(CB.getParamByValType(ArgNo), ActualArg,
&CB, CalledFunc, IFI,
- CalledFunc->getParamAlignment(ArgNo));
+ CalledFunc->getParamAlign(ArgNo));
if (ActualArg != *AI)
ByValInits.push_back(
{ActualArg, (Value *)*AI, CB.getParamByValType(ArgNo)});