Make getByValTypeAlignment() taking DataLayout as an argument

Summary:
This change is part of a series of commits dedicated to have a single
DataLayout during compilation by using always the one owned by the
module.

Reviewers: echristo

Subscribers: yaron.keren, rafael, llvm-commits, jholewinski

Differential Revision: http://reviews.llvm.org/D11038

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 241777
This commit is contained in:
Mehdi Amini 2015-07-09 02:09:28 +00:00
parent 9639d650bb
commit 5c183d5239
8 changed files with 16 additions and 11 deletions

View File

@ -744,7 +744,7 @@ public:
/// Return the desired alignment for ByVal or InAlloca aggregate function /// Return the desired alignment for ByVal or InAlloca aggregate function
/// arguments in the caller parameter area. This is the actual alignment, not /// arguments in the caller parameter area. This is the actual alignment, not
/// its logarithm. /// its logarithm.
virtual unsigned getByValTypeAlignment(Type *Ty) const; virtual unsigned getByValTypeAlignment(Type *Ty, const DataLayout &DL) const;
/// Return the type of registers that this ValueType will eventually require. /// Return the type of registers that this ValueType will eventually require.
MVT getRegisterType(MVT VT) const { MVT getRegisterType(MVT VT) const {

View File

@ -976,7 +976,7 @@ bool FastISel::lowerCallTo(CallLoweringInfo &CLI) {
// not there, but there are cases it cannot get right. // not there, but there are cases it cannot get right.
unsigned FrameAlign = Arg.Alignment; unsigned FrameAlign = Arg.Alignment;
if (!FrameAlign) if (!FrameAlign)
FrameAlign = TLI.getByValTypeAlignment(ElementTy); FrameAlign = TLI.getByValTypeAlignment(ElementTy, DL);
Flags.setByValSize(FrameSize); Flags.setByValSize(FrameSize);
Flags.setByValAlign(FrameAlign); Flags.setByValAlign(FrameAlign);
} }

View File

@ -6878,7 +6878,7 @@ TargetLowering::LowerCallTo(TargetLowering::CallLoweringInfo &CLI) const {
if (Args[i].Alignment) if (Args[i].Alignment)
FrameAlign = Args[i].Alignment; FrameAlign = Args[i].Alignment;
else else
FrameAlign = getByValTypeAlignment(ElementTy); FrameAlign = getByValTypeAlignment(ElementTy, DL);
Flags.setByValAlign(FrameAlign); Flags.setByValAlign(FrameAlign);
} }
if (Args[i].isNest) if (Args[i].isNest)
@ -7149,7 +7149,7 @@ void SelectionDAGISel::LowerArguments(const Function &F) {
if (F.getParamAlignment(Idx)) if (F.getParamAlignment(Idx))
FrameAlign = F.getParamAlignment(Idx); FrameAlign = F.getParamAlignment(Idx);
else else
FrameAlign = TLI->getByValTypeAlignment(ElementTy); FrameAlign = TLI->getByValTypeAlignment(ElementTy, DL);
Flags.setByValAlign(FrameAlign); Flags.setByValAlign(FrameAlign);
} }
if (F.getAttributes().hasAttribute(Idx, Attribute::Nest)) if (F.getAttributes().hasAttribute(Idx, Attribute::Nest))

View File

@ -1522,8 +1522,9 @@ void llvm::GetReturnInfo(Type *ReturnType, AttributeSet attr,
/// getByValTypeAlignment - Return the desired alignment for ByVal aggregate /// getByValTypeAlignment - Return the desired alignment for ByVal aggregate
/// function arguments in the caller parameter area. This is the actual /// function arguments in the caller parameter area. This is the actual
/// alignment, not its logarithm. /// alignment, not its logarithm.
unsigned TargetLoweringBase::getByValTypeAlignment(Type *Ty) const { unsigned TargetLoweringBase::getByValTypeAlignment(Type *Ty,
return getDataLayout()->getABITypeAlignment(Ty); const DataLayout &DL) const {
return DL.getABITypeAlignment(Ty);
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//

View File

@ -952,7 +952,8 @@ static void getMaxByValAlign(Type *Ty, unsigned &MaxAlign,
/// getByValTypeAlignment - Return the desired alignment for ByVal aggregate /// getByValTypeAlignment - Return the desired alignment for ByVal aggregate
/// function arguments in the caller parameter area. /// function arguments in the caller parameter area.
unsigned PPCTargetLowering::getByValTypeAlignment(Type *Ty) const { unsigned PPCTargetLowering::getByValTypeAlignment(Type *Ty,
const DataLayout &DL) const {
// Darwin passes everything on 4 byte boundary. // Darwin passes everything on 4 byte boundary.
if (Subtarget.isDarwin()) if (Subtarget.isDarwin())
return 4; return 4;

View File

@ -536,7 +536,8 @@ namespace llvm {
/// getByValTypeAlignment - Return the desired alignment for ByVal aggregate /// getByValTypeAlignment - Return the desired alignment for ByVal aggregate
/// function arguments in the caller parameter area. This is the actual /// function arguments in the caller parameter area. This is the actual
/// alignment, not its logarithm. /// alignment, not its logarithm.
unsigned getByValTypeAlignment(Type *Ty) const override; unsigned getByValTypeAlignment(Type *Ty,
const DataLayout &DL) const override;
/// LowerAsmOperandForConstraint - Lower the specified operand into the Ops /// LowerAsmOperandForConstraint - Lower the specified operand into the Ops
/// vector. If it is invalid, don't add anything to Ops. /// vector. If it is invalid, don't add anything to Ops.

View File

@ -1784,10 +1784,11 @@ static void getMaxByValAlign(Type *Ty, unsigned &MaxAlign) {
/// function arguments in the caller parameter area. For X86, aggregates /// function arguments in the caller parameter area. For X86, aggregates
/// that contain SSE vectors are placed at 16-byte boundaries while the rest /// that contain SSE vectors are placed at 16-byte boundaries while the rest
/// are at 4-byte boundaries. /// are at 4-byte boundaries.
unsigned X86TargetLowering::getByValTypeAlignment(Type *Ty) const { unsigned X86TargetLowering::getByValTypeAlignment(Type *Ty,
const DataLayout &DL) const {
if (Subtarget->is64Bit()) { if (Subtarget->is64Bit()) {
// Max of 8 and alignment of type. // Max of 8 and alignment of type.
unsigned TyAlign = TD->getABITypeAlignment(Ty); unsigned TyAlign = DL.getABITypeAlignment(Ty);
if (TyAlign > 8) if (TyAlign > 8)
return TyAlign; return TyAlign;
return 8; return 8;

View File

@ -618,7 +618,8 @@ namespace llvm {
/// function arguments in the caller parameter area. For X86, aggregates /// function arguments in the caller parameter area. For X86, aggregates
/// that contains are placed at 16-byte boundaries while the rest are at /// that contains are placed at 16-byte boundaries while the rest are at
/// 4-byte boundaries. /// 4-byte boundaries.
unsigned getByValTypeAlignment(Type *Ty) const override; unsigned getByValTypeAlignment(Type *Ty,
const DataLayout &DL) const override;
/// Returns the target specific optimal type for load /// Returns the target specific optimal type for load
/// and store operations as a result of memset, memcpy, and memmove /// and store operations as a result of memset, memcpy, and memmove