Skip to content

Commit e55c167

Browse files
authored
[TargetLowering] Return Align from getByValTypeAlignment (NFC) (#119233)
1 parent a4e2927 commit e55c167

File tree

9 files changed

+21
-33
lines changed

9 files changed

+21
-33
lines changed

llvm/include/llvm/CodeGen/TargetLowering.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,10 +1720,9 @@ class TargetLoweringBase {
17201720
return getValueType(DL, Ty, AllowUnknown).getSimpleVT();
17211721
}
17221722

1723-
/// Return the desired alignment for ByVal or InAlloca aggregate function
1724-
/// arguments in the caller parameter area. This is the actual alignment, not
1725-
/// its logarithm.
1726-
virtual uint64_t getByValTypeAlignment(Type *Ty, const DataLayout &DL) const;
1723+
/// Returns the desired alignment for ByVal or InAlloca aggregate function
1724+
/// arguments in the caller parameter area.
1725+
virtual Align getByValTypeAlignment(Type *Ty, const DataLayout &DL) const;
17271726

17281727
/// Return the type of registers that this ValueType will eventually require.
17291728
MVT getRegisterType(MVT VT) const {

llvm/lib/CodeGen/GlobalISel/CallLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ void CallLowering::setArgFlags(CallLowering::ArgInfo &Arg, unsigned OpIdx,
258258
else if ((ParamAlign = FuncInfo.getParamAlign(ParamIdx)))
259259
MemAlign = *ParamAlign;
260260
else
261-
MemAlign = Align(getTLI()->getByValTypeAlignment(ElementTy, DL));
261+
MemAlign = getTLI()->getByValTypeAlignment(ElementTy, DL);
262262
} else if (OpIdx >= AttributeList::FirstArgIndex) {
263263
if (auto ParamAlign =
264264
FuncInfo.getParamStackAlign(OpIdx - AttributeList::FirstArgIndex))

llvm/lib/CodeGen/SelectionDAG/FastISel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,7 @@ bool FastISel::lowerCallTo(CallLoweringInfo &CLI) {
10781078
// For ByVal, alignment should come from FE. BE will guess if this info
10791079
// is not there, but there are cases it cannot get right.
10801080
if (!MemAlign)
1081-
MemAlign = Align(TLI.getByValTypeAlignment(Arg.IndirectType, DL));
1081+
MemAlign = TLI.getByValTypeAlignment(Arg.IndirectType, DL);
10821082
Flags.setByValSize(FrameSize);
10831083
} else if (!MemAlign) {
10841084
MemAlign = DL.getABITypeAlign(Arg.Ty);

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11197,7 +11197,7 @@ TargetLowering::LowerCallTo(TargetLowering::CallLoweringInfo &CLI) const {
1119711197
if (auto MA = Args[i].Alignment)
1119811198
MemAlign = *MA;
1119911199
else
11200-
MemAlign = Align(getByValTypeAlignment(Args[i].IndirectType, DL));
11200+
MemAlign = getByValTypeAlignment(Args[i].IndirectType, DL);
1120111201
} else if (auto MA = Args[i].Alignment) {
1120211202
MemAlign = *MA;
1120311203
} else {
@@ -11754,7 +11754,7 @@ void SelectionDAGISel::LowerArguments(const Function &F) {
1175411754
else if ((ParamAlign = Arg.getParamAlign()))
1175511755
MemAlign = *ParamAlign;
1175611756
else
11757-
MemAlign = Align(TLI->getByValTypeAlignment(ArgMemTy, DL));
11757+
MemAlign = TLI->getByValTypeAlignment(ArgMemTy, DL);
1175811758
if (Flags.isByRef())
1175911759
Flags.setByRefSize(MemSize);
1176011760
else

llvm/lib/CodeGen/TargetLoweringBase.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1697,12 +1697,9 @@ void llvm::GetReturnInfo(CallingConv::ID CC, Type *ReturnType,
16971697
}
16981698
}
16991699

1700-
/// getByValTypeAlignment - Return the desired alignment for ByVal aggregate
1701-
/// function arguments in the caller parameter area. This is the actual
1702-
/// alignment, not its logarithm.
1703-
uint64_t TargetLoweringBase::getByValTypeAlignment(Type *Ty,
1704-
const DataLayout &DL) const {
1705-
return DL.getABITypeAlign(Ty).value();
1700+
Align TargetLoweringBase::getByValTypeAlignment(Type *Ty,
1701+
const DataLayout &DL) const {
1702+
return DL.getABITypeAlign(Ty);
17061703
}
17071704

17081705
bool TargetLoweringBase::allowsMemoryAccessForAlignment(

llvm/lib/Target/PowerPC/PPCISelLowering.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,14 +1638,14 @@ static void getMaxByValAlign(Type *Ty, Align &MaxAlign, Align MaxMaxAlign) {
16381638

16391639
/// getByValTypeAlignment - Return the desired alignment for ByVal aggregate
16401640
/// function arguments in the caller parameter area.
1641-
uint64_t PPCTargetLowering::getByValTypeAlignment(Type *Ty,
1642-
const DataLayout &DL) const {
1641+
Align PPCTargetLowering::getByValTypeAlignment(Type *Ty,
1642+
const DataLayout &DL) const {
16431643
// 16byte and wider vectors are passed on 16byte boundary.
16441644
// The rest is 8 on PPC64 and 4 on PPC32 boundary.
16451645
Align Alignment = Subtarget.isPPC64() ? Align(8) : Align(4);
16461646
if (Subtarget.hasAltivec())
16471647
getMaxByValAlign(Ty, Alignment, Align(16));
1648-
return Alignment.value();
1648+
return Alignment;
16491649
}
16501650

16511651
bool PPCTargetLowering::useSoftFloat() const {

llvm/lib/Target/PowerPC/PPCISelLowering.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -985,10 +985,8 @@ namespace llvm {
985985
StringRef Constraint, MVT VT) const override;
986986

987987
/// getByValTypeAlignment - Return the desired alignment for ByVal aggregate
988-
/// function arguments in the caller parameter area. This is the actual
989-
/// alignment, not its logarithm.
990-
uint64_t getByValTypeAlignment(Type *Ty,
991-
const DataLayout &DL) const override;
988+
/// function arguments in the caller parameter area.
989+
Align getByValTypeAlignment(Type *Ty, const DataLayout &DL) const override;
992990

993991
/// LowerAsmOperandForConstraint - Lower the specified operand into the Ops
994992
/// vector. If it is invalid, don't add anything to Ops.

llvm/lib/Target/X86/X86ISelLowering.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,8 +1079,7 @@ namespace llvm {
10791079
/// function arguments in the caller parameter area. For X86, aggregates
10801080
/// that contains are placed at 16-byte boundaries while the rest are at
10811081
/// 4-byte boundaries.
1082-
uint64_t getByValTypeAlignment(Type *Ty,
1083-
const DataLayout &DL) const override;
1082+
Align getByValTypeAlignment(Type *Ty, const DataLayout &DL) const override;
10841083

10851084
EVT getOptimalMemOpType(const MemOp &Op,
10861085
const AttributeList &FuncAttributes) const override;

llvm/lib/Target/X86/X86ISelLoweringCall.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -262,20 +262,15 @@ static void getMaxByValAlign(Type *Ty, Align &MaxAlign) {
262262
/// function arguments in the caller parameter area. For X86, aggregates
263263
/// that contain SSE vectors are placed at 16-byte boundaries while the rest
264264
/// are at 4-byte boundaries.
265-
uint64_t X86TargetLowering::getByValTypeAlignment(Type *Ty,
266-
const DataLayout &DL) const {
267-
if (Subtarget.is64Bit()) {
268-
// Max of 8 and alignment of type.
269-
Align TyAlign = DL.getABITypeAlign(Ty);
270-
if (TyAlign > 8)
271-
return TyAlign.value();
272-
return 8;
273-
}
265+
Align X86TargetLowering::getByValTypeAlignment(Type *Ty,
266+
const DataLayout &DL) const {
267+
if (Subtarget.is64Bit())
268+
return std::max(DL.getABITypeAlign(Ty), Align::Constant<8>());
274269

275270
Align Alignment(4);
276271
if (Subtarget.hasSSE1())
277272
getMaxByValAlign(Ty, Alignment);
278-
return Alignment.value();
273+
return Alignment;
279274
}
280275

281276
/// It returns EVT::Other if the type should be determined using generic

0 commit comments

Comments
 (0)