mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-23 14:25:07 +00:00
IR: Replace DataLayout::RoundUpAlignment with RoundUpToAlignment
No functional change intended, just cleaning up some code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220187 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -369,7 +369,7 @@ public:
|
|||||||
/// x86_fp80, depending on alignment.
|
/// x86_fp80, depending on alignment.
|
||||||
uint64_t getTypeAllocSize(Type *Ty) const {
|
uint64_t getTypeAllocSize(Type *Ty) const {
|
||||||
// Round up to the next alignment boundary.
|
// Round up to the next alignment boundary.
|
||||||
return RoundUpAlignment(getTypeStoreSize(Ty), getABITypeAlignment(Ty));
|
return RoundUpToAlignment(getTypeStoreSize(Ty), getABITypeAlignment(Ty));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getTypeAllocSizeInBits - Return the offset in bits between successive
|
/// getTypeAllocSizeInBits - Return the offset in bits between successive
|
||||||
@@ -438,16 +438,6 @@ public:
|
|||||||
/// specified global, returned in log form. This includes an explicitly
|
/// specified global, returned in log form. This includes an explicitly
|
||||||
/// requested alignment (if the global has one).
|
/// requested alignment (if the global has one).
|
||||||
unsigned getPreferredAlignmentLog(const GlobalVariable *GV) const;
|
unsigned getPreferredAlignmentLog(const GlobalVariable *GV) const;
|
||||||
|
|
||||||
/// RoundUpAlignment - Round the specified value up to the next alignment
|
|
||||||
/// boundary specified by Alignment. For example, 7 rounded up to an
|
|
||||||
/// alignment boundary of 4 is 8. 8 rounded up to the alignment boundary of 4
|
|
||||||
/// is 8 because it is already aligned.
|
|
||||||
template <typename UIntTy>
|
|
||||||
static UIntTy RoundUpAlignment(UIntTy Val, unsigned Alignment) {
|
|
||||||
assert((Alignment & (Alignment-1)) == 0 && "Alignment must be power of 2!");
|
|
||||||
return (Val + (Alignment-1)) & ~UIntTy(Alignment-1);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline DataLayout *unwrap(LLVMTargetDataRef P) {
|
inline DataLayout *unwrap(LLVMTargetDataRef P) {
|
||||||
|
@@ -597,7 +597,8 @@ inline uint64_t PowerOf2Floor(uint64_t A) {
|
|||||||
/// RoundUpToAlignment(~0LL, 8) = 0
|
/// RoundUpToAlignment(~0LL, 8) = 0
|
||||||
/// \endcode
|
/// \endcode
|
||||||
inline uint64_t RoundUpToAlignment(uint64_t Value, uint64_t Align) {
|
inline uint64_t RoundUpToAlignment(uint64_t Value, uint64_t Align) {
|
||||||
return ((Value + Align - 1) / Align) * Align;
|
assert(isPowerOf2_64(Align) && "Alignment must be power of 2!");
|
||||||
|
return (Value + Align - 1) & ~uint64_t(Align - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the offset to the next integer (mod 2**64) that is greater than
|
/// Returns the offset to the next integer (mod 2**64) that is greater than
|
||||||
|
@@ -91,8 +91,8 @@ public:
|
|||||||
Type *ElTy = GV->getType()->getElementType();
|
Type *ElTy = GV->getType()->getElementType();
|
||||||
size_t GVSize = (size_t)TD.getTypeAllocSize(ElTy);
|
size_t GVSize = (size_t)TD.getTypeAllocSize(ElTy);
|
||||||
void *RawMemory = ::operator new(
|
void *RawMemory = ::operator new(
|
||||||
DataLayout::RoundUpAlignment(sizeof(GVMemoryBlock),
|
RoundUpToAlignment(sizeof(GVMemoryBlock),
|
||||||
TD.getPreferredAlignment(GV))
|
TD.getPreferredAlignment(GV))
|
||||||
+ GVSize);
|
+ GVSize);
|
||||||
new(RawMemory) GVMemoryBlock(GV);
|
new(RawMemory) GVMemoryBlock(GV);
|
||||||
return static_cast<char*>(RawMemory) + sizeof(GVMemoryBlock);
|
return static_cast<char*>(RawMemory) + sizeof(GVMemoryBlock);
|
||||||
|
@@ -55,7 +55,7 @@ StructLayout::StructLayout(StructType *ST, const DataLayout &DL) {
|
|||||||
|
|
||||||
// Add padding if necessary to align the data element properly.
|
// Add padding if necessary to align the data element properly.
|
||||||
if ((StructSize & (TyAlign-1)) != 0)
|
if ((StructSize & (TyAlign-1)) != 0)
|
||||||
StructSize = DataLayout::RoundUpAlignment(StructSize, TyAlign);
|
StructSize = RoundUpToAlignment(StructSize, TyAlign);
|
||||||
|
|
||||||
// Keep track of maximum alignment constraint.
|
// Keep track of maximum alignment constraint.
|
||||||
StructAlignment = std::max(TyAlign, StructAlignment);
|
StructAlignment = std::max(TyAlign, StructAlignment);
|
||||||
@@ -70,7 +70,7 @@ StructLayout::StructLayout(StructType *ST, const DataLayout &DL) {
|
|||||||
// Add padding to the end of the struct so that it could be put in an array
|
// Add padding to the end of the struct so that it could be put in an array
|
||||||
// and all array elements would be aligned correctly.
|
// and all array elements would be aligned correctly.
|
||||||
if ((StructSize & (StructAlignment-1)) != 0)
|
if ((StructSize & (StructAlignment-1)) != 0)
|
||||||
StructSize = DataLayout::RoundUpAlignment(StructSize, StructAlignment);
|
StructSize = RoundUpToAlignment(StructSize, StructAlignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -980,7 +980,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
|
|||||||
setOrigin(A, EntryIRB.CreateLoad(OriginPtr));
|
setOrigin(A, EntryIRB.CreateLoad(OriginPtr));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ArgOffset += DataLayout::RoundUpAlignment(Size, kShadowTLSAlignment);
|
ArgOffset += RoundUpToAlignment(Size, kShadowTLSAlignment);
|
||||||
}
|
}
|
||||||
assert(*ShadowPtr && "Could not find shadow for an argument");
|
assert(*ShadowPtr && "Could not find shadow for an argument");
|
||||||
return *ShadowPtr;
|
return *ShadowPtr;
|
||||||
@@ -2347,7 +2347,7 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
|
|||||||
(void)Store;
|
(void)Store;
|
||||||
assert(Size != 0 && Store != nullptr);
|
assert(Size != 0 && Store != nullptr);
|
||||||
DEBUG(dbgs() << " Param:" << *Store << "\n");
|
DEBUG(dbgs() << " Param:" << *Store << "\n");
|
||||||
ArgOffset += DataLayout::RoundUpAlignment(Size, 8);
|
ArgOffset += RoundUpToAlignment(Size, 8);
|
||||||
}
|
}
|
||||||
DEBUG(dbgs() << " done with call args\n");
|
DEBUG(dbgs() << " done with call args\n");
|
||||||
|
|
||||||
@@ -2628,7 +2628,7 @@ struct VarArgAMD64Helper : public VarArgHelper {
|
|||||||
Type *RealTy = A->getType()->getPointerElementType();
|
Type *RealTy = A->getType()->getPointerElementType();
|
||||||
uint64_t ArgSize = MS.DL->getTypeAllocSize(RealTy);
|
uint64_t ArgSize = MS.DL->getTypeAllocSize(RealTy);
|
||||||
Value *Base = getShadowPtrForVAArgument(RealTy, IRB, OverflowOffset);
|
Value *Base = getShadowPtrForVAArgument(RealTy, IRB, OverflowOffset);
|
||||||
OverflowOffset += DataLayout::RoundUpAlignment(ArgSize, 8);
|
OverflowOffset += RoundUpToAlignment(ArgSize, 8);
|
||||||
IRB.CreateMemCpy(Base, MSV.getShadowPtr(A, IRB.getInt8Ty(), IRB),
|
IRB.CreateMemCpy(Base, MSV.getShadowPtr(A, IRB.getInt8Ty(), IRB),
|
||||||
ArgSize, kShadowTLSAlignment);
|
ArgSize, kShadowTLSAlignment);
|
||||||
} else {
|
} else {
|
||||||
@@ -2650,7 +2650,7 @@ struct VarArgAMD64Helper : public VarArgHelper {
|
|||||||
case AK_Memory:
|
case AK_Memory:
|
||||||
uint64_t ArgSize = MS.DL->getTypeAllocSize(A->getType());
|
uint64_t ArgSize = MS.DL->getTypeAllocSize(A->getType());
|
||||||
Base = getShadowPtrForVAArgument(A->getType(), IRB, OverflowOffset);
|
Base = getShadowPtrForVAArgument(A->getType(), IRB, OverflowOffset);
|
||||||
OverflowOffset += DataLayout::RoundUpAlignment(ArgSize, 8);
|
OverflowOffset += RoundUpToAlignment(ArgSize, 8);
|
||||||
}
|
}
|
||||||
IRB.CreateAlignedStore(MSV.getShadow(A), Base, kShadowTLSAlignment);
|
IRB.CreateAlignedStore(MSV.getShadow(A), Base, kShadowTLSAlignment);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user