Skip to content

Commit

Permalink
[NFC] Rename *ByValOrInalloca* to *PassPointeeByValue*
Browse files Browse the repository at this point in the history
Summary: In preparation for preallocated.

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D79152
  • Loading branch information
aeubanks committed Apr 30, 2020
1 parent 4eabd00 commit a90948f
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 19 deletions.
4 changes: 1 addition & 3 deletions llvm/include/llvm/Analysis/ObjCARCAnalysisUtils.h
Expand Up @@ -151,9 +151,7 @@ inline bool IsPotentialRetainableObjPtr(const Value *Op) {
return false;
// Special arguments can not be a valid retainable object pointer.
if (const Argument *Arg = dyn_cast<Argument>(Op))
if (Arg->hasByValAttr() ||
Arg->hasInAllocaAttr() ||
Arg->hasNestAttr() ||
if (Arg->hasPassPointeeByValueAttr() || Arg->hasNestAttr() ||
Arg->hasStructRetAttr())
return false;
// Only consider values with pointer types.
Expand Down
4 changes: 2 additions & 2 deletions llvm/include/llvm/IR/Argument.h
Expand Up @@ -71,9 +71,9 @@ class Argument final : public Value {
/// Return true if this argument has the swifterror attribute.
bool hasSwiftErrorAttr() const;

/// Return true if this argument has the byval attribute or inalloca
/// Return true if this argument has the byval, inalloca, or preallocated
/// attribute. These attributes represent arguments being passed by value.
bool hasByValOrInAllocaAttr() const;
bool hasPassPointeeByValueAttr() const;

/// If this is a byval or inalloca argument, return its alignment.
/// FIXME: Remove this function once transition to Align is over.
Expand Down
8 changes: 5 additions & 3 deletions llvm/include/llvm/IR/InstrTypes.h
Expand Up @@ -1541,10 +1541,12 @@ class CallBase : public Instruction {
return paramHasAttr(ArgNo, Attribute::InAlloca);
}

/// Determine whether this argument is passed by value or in an alloca.
bool isByValOrInAllocaArgument(unsigned ArgNo) const {
/// Determine whether this argument is passed by value, in an alloca, or is
/// preallocated.
bool isPassPointeeByValueArgument(unsigned ArgNo) const {
return paramHasAttr(ArgNo, Attribute::ByVal) ||
paramHasAttr(ArgNo, Attribute::InAlloca);
paramHasAttr(ArgNo, Attribute::InAlloca) ||
paramHasAttr(ArgNo, Attribute::Preallocated);
}

/// Determine if there are is an inalloca argument. Only the last argument can
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Analysis/MemoryBuiltins.cpp
Expand Up @@ -673,7 +673,7 @@ SizeOffsetType ObjectSizeOffsetVisitor::visitAllocaInst(AllocaInst &I) {

SizeOffsetType ObjectSizeOffsetVisitor::visitArgument(Argument &A) {
// No interprocedural analysis is done at the moment.
if (!A.hasByValOrInAllocaAttr()) {
if (!A.hasPassPointeeByValueAttr()) {
++ObjectVisitorArgument;
return unknown();
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Analysis/ValueTracking.cpp
Expand Up @@ -2339,7 +2339,7 @@ bool isKnownNonZero(const Value *V, const APInt &DemandedElts, unsigned Depth,

// A byval, inalloca, or nonnull argument is never null.
if (const Argument *A = dyn_cast<Argument>(V))
if (A->hasByValOrInAllocaAttr() || A->hasNonNullAttr())
if (A->hasPassPointeeByValueAttr() || A->hasNonNullAttr())
return true;

// A Load tagged with nonnull metadata is never null.
Expand Down
5 changes: 3 additions & 2 deletions llvm/lib/IR/Function.cpp
Expand Up @@ -114,11 +114,12 @@ bool Argument::hasInAllocaAttr() const {
return hasAttribute(Attribute::InAlloca);
}

bool Argument::hasByValOrInAllocaAttr() const {
bool Argument::hasPassPointeeByValueAttr() const {
if (!getType()->isPointerTy()) return false;
AttributeList Attrs = getParent()->getAttributes();
return Attrs.hasParamAttribute(getArgNo(), Attribute::ByVal) ||
Attrs.hasParamAttribute(getArgNo(), Attribute::InAlloca);
Attrs.hasParamAttribute(getArgNo(), Attribute::InAlloca) ||
Attrs.hasParamAttribute(getArgNo(), Attribute::Preallocated);
}

unsigned Argument::getParamAlignment() const {
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/IR/Mangler.cpp
Expand Up @@ -98,7 +98,7 @@ static void addByteCountSuffix(raw_ostream &OS, const Function *F,
AI != AE; ++AI) {
Type *Ty = AI->getType();
// 'Dereference' type in case of byval or inalloca parameter attribute.
if (AI->hasByValOrInAllocaAttr())
if (AI->hasPassPointeeByValueAttr())
Ty = cast<PointerType>(Ty)->getElementType();
// Size should be aligned to pointer size.
unsigned PtrSize = DL.getPointerSize();
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/ARM/ARMCallLowering.cpp
Expand Up @@ -429,7 +429,7 @@ bool ARMCallLowering::lowerFormalArguments(
for (auto &Arg : F.args()) {
if (!isSupportedType(DL, TLI, Arg.getType()))
return false;
if (Arg.hasByValOrInAllocaAttr())
if (Arg.hasPassPointeeByValueAttr())
return false;
}

Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
Expand Up @@ -289,7 +289,8 @@ bool DeadArgumentEliminationPass::RemoveDeadArgumentsFromCallers(Function &Fn) {
bool Changed = false;

for (Argument &Arg : Fn.args()) {
if (!Arg.hasSwiftErrorAttr() && Arg.use_empty() && !Arg.hasByValOrInAllocaAttr()) {
if (!Arg.hasSwiftErrorAttr() && Arg.use_empty() &&
!Arg.hasPassPointeeByValueAttr()) {
if (Arg.isUsedByMetadata()) {
Arg.replaceAllUsesWith(UndefValue::get(Arg.getType()));
Changed = true;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
Expand Up @@ -4336,7 +4336,7 @@ static bool isSafeToEliminateVarargsCast(const CallBase &Call,
// The size of ByVal or InAlloca arguments is derived from the type, so we
// can't change to a type with a different size. If the size were
// passed explicitly we could avoid this check.
if (!Call.isByValOrInAllocaArgument(ix))
if (!Call.isPassPointeeByValueArgument(ix))
return true;

Type* SrcTy =
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
Expand Up @@ -839,7 +839,7 @@ static bool handleEndBlock(BasicBlock &BB, AliasAnalysis *AA,
// Treat byval or inalloca arguments the same, stores to them are dead at the
// end of the function.
for (Argument &AI : BB.getParent()->args())
if (AI.hasByValOrInAllocaAttr())
if (AI.hasPassPointeeByValueAttr())
DeadStackObjects.insert(&AI);

const DataLayout &DL = BB.getModule()->getDataLayout();
Expand Down Expand Up @@ -1549,7 +1549,7 @@ struct DSEState {
// Treat byval or inalloca arguments the same as Allocas, stores to them are
// dead at the end of the function.
for (Argument &AI : F.args())
if (AI.hasByValOrInAllocaAttr())
if (AI.hasPassPointeeByValueAttr())
State.InvisibleToCallerBeforeRet.insert(&AI);
return State;
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Utils/InlineFunction.cpp
Expand Up @@ -1242,7 +1242,7 @@ 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.hasByValOrInAllocaAttr() && !Arg.hasNUses(0)) {
if (Align && !Arg.hasPassPointeeByValueAttr() && !Arg.hasNUses(0)) {
if (!DTCalculated) {
DT.recalculate(*CB.getCaller());
DTCalculated = true;
Expand Down

0 comments on commit a90948f

Please sign in to comment.