r235680 - Cleanup some MS-ABI specific code
David Majnemer
david.majnemer at gmail.com
Thu Apr 23 18:25:00 PDT 2015
Author: majnemer
Date: Thu Apr 23 20:24:59 2015
New Revision: 235680
URL: http://llvm.org/viewvc/llvm-project?rev=235680&view=rev
Log:
Cleanup some MS-ABI specific code
No functional change intended.
Modified:
cfe/trunk/lib/AST/MicrosoftCXXABI.cpp
cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
Modified: cfe/trunk/lib/AST/MicrosoftCXXABI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/MicrosoftCXXABI.cpp?rev=235680&r1=235679&r2=235680&view=diff
==============================================================================
--- cfe/trunk/lib/AST/MicrosoftCXXABI.cpp (original)
+++ cfe/trunk/lib/AST/MicrosoftCXXABI.cpp Thu Apr 23 20:24:59 2015
@@ -213,29 +213,28 @@ getMSMemberPointerSlots(const MemberPoin
std::pair<uint64_t, unsigned> MicrosoftCXXABI::getMemberPointerWidthAndAlign(
const MemberPointerType *MPT) const {
- const TargetInfo &Target = Context.getTargetInfo();
- assert(Target.getTriple().getArch() == llvm::Triple::x86 ||
- Target.getTriple().getArch() == llvm::Triple::x86_64);
- unsigned Ptrs, Ints;
- std::tie(Ptrs, Ints) = getMSMemberPointerSlots(MPT);
// The nominal struct is laid out with pointers followed by ints and aligned
// to a pointer width if any are present and an int width otherwise.
+ const TargetInfo &Target = Context.getTargetInfo();
unsigned PtrSize = Target.getPointerWidth(0);
unsigned IntSize = Target.getIntWidth();
+
+ unsigned Ptrs, Ints;
+ std::tie(Ptrs, Ints) = getMSMemberPointerSlots(MPT);
uint64_t Width = Ptrs * PtrSize + Ints * IntSize;
unsigned Align;
// When MSVC does x86_32 record layout, it aligns aggregate member pointers to
// 8 bytes. However, __alignof usually returns 4 for data memptrs and 8 for
// function memptrs.
- if (Ptrs + Ints > 1 && Target.getTriple().getArch() == llvm::Triple::x86)
- Align = 8 * 8;
+ if (Ptrs + Ints > 1 && Target.getTriple().isArch32Bit())
+ Align = 64;
else if (Ptrs)
Align = Target.getPointerAlign(0);
else
Align = Target.getIntAlign();
- if (Target.getTriple().getArch() == llvm::Triple::x86_64)
+ if (Target.getTriple().isArch64Bit())
Width = llvm::RoundUpToAlignment(Width, Align);
return std::make_pair(Width, Align);
}
Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=235680&r1=235679&r2=235680&view=diff
==============================================================================
--- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
+++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Thu Apr 23 20:24:59 2015
@@ -2379,8 +2379,9 @@ void MicrosoftRecordLayoutBuilder::initi
// In 64-bit mode we always perform an alignment step after laying out vbases.
// In 32-bit mode we do not. The check to see if we need to perform alignment
// checks the RequiredAlignment field and performs alignment if it isn't 0.
- RequiredAlignment = Context.getTargetInfo().getPointerWidth(0) == 64 ?
- CharUnits::One() : CharUnits::Zero();
+ RequiredAlignment = Context.getTargetInfo().getTriple().isArch64Bit()
+ ? CharUnits::One()
+ : CharUnits::Zero();
// Compute the maximum field alignment.
MaxFieldAlignment = CharUnits::Zero();
// Honor the default struct packing maximum alignment flag.
@@ -2417,7 +2418,8 @@ MicrosoftRecordLayoutBuilder::initialize
// injection.
PointerInfo.Size =
Context.toCharUnitsFromBits(Context.getTargetInfo().getPointerWidth(0));
- PointerInfo.Alignment = PointerInfo.Size;
+ PointerInfo.Alignment =
+ Context.toCharUnitsFromBits(Context.getTargetInfo().getPointerAlign(0));
// Respect pragma pack.
if (!MaxFieldAlignment.isZero())
PointerInfo.Alignment = std::min(PointerInfo.Alignment, MaxFieldAlignment);
More information about the cfe-commits
mailing list