From 77bba68de6d394f6b8b98529721ba7d0178b20e8 Mon Sep 17 00:00:00 2001 From: Guillaume Chatelet Date: Tue, 14 Jun 2022 09:52:45 +0000 Subject: [PATCH] [NFC][Alignment] Use Align in CoroFrame --- llvm/lib/Transforms/Coroutines/CoroFrame.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp index dea190901aa97..e28e567cfd645 100644 --- a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp +++ b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp @@ -340,15 +340,15 @@ struct FrameDataInfo { FieldIndexMap[V] = Index; } - uint64_t getAlign(Value *V) const { + Align getAlign(Value *V) const { auto Iter = FieldAlignMap.find(V); assert(Iter != FieldAlignMap.end()); return Iter->second; } - void setAlign(Value *V, uint64_t Align) { + void setAlign(Value *V, Align AL) { assert(FieldAlignMap.count(V) == 0); - FieldAlignMap.insert({V, Align}); + FieldAlignMap.insert({V, AL}); } uint64_t getDynamicAlign(Value *V) const { @@ -386,7 +386,7 @@ struct FrameDataInfo { DenseMap FieldIndexMap; // Map from values to their alignment on the frame. They would be set after // the frame is built. - DenseMap FieldAlignMap; + DenseMap FieldAlignMap; DenseMap FieldDynamicAlignMap; // Map from values to their offset on the frame. They would be set after // the frame is built. @@ -580,7 +580,7 @@ void FrameDataInfo::updateLayoutIndex(FrameTypeBuilder &B) { auto Updater = [&](Value *I) { auto Field = B.getLayoutField(getFieldIndex(I)); setFieldIndex(I, Field.LayoutFieldIndex); - setAlign(I, Field.Alignment.value()); + setAlign(I, Field.Alignment); uint64_t dynamicAlign = Field.DynamicAlignBuffer ? Field.DynamicAlignBuffer + Field.Alignment.value() @@ -1040,7 +1040,7 @@ static void buildFrameDebugInfo(Function &F, coro::Shape &Shape, auto Index = FrameData.getFieldIndex(V); OffsetCache.insert( - {Index, {FrameData.getAlign(V), FrameData.getOffset(V)}}); + {Index, {FrameData.getAlign(V).value(), FrameData.getOffset(V)}}); } DenseMap DITypeCache; @@ -1579,11 +1579,12 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) { Builder.CreateInBoundsGEP(FrameTy, FramePtr, Indices)); if (auto *AI = dyn_cast(Orig)) { if (FrameData.getDynamicAlign(Orig) != 0) { - assert(FrameData.getDynamicAlign(Orig) == AI->getAlignment()); + assert(FrameData.getDynamicAlign(Orig) == AI->getAlign().value()); auto *M = AI->getModule(); auto *IntPtrTy = M->getDataLayout().getIntPtrType(AI->getType()); auto *PtrValue = Builder.CreatePtrToInt(GEP, IntPtrTy); - auto *AlignMask = ConstantInt::get(IntPtrTy, AI->getAlignment() - 1); + auto *AlignMask = + ConstantInt::get(IntPtrTy, AI->getAlign().value() - 1); PtrValue = Builder.CreateAdd(PtrValue, AlignMask); PtrValue = Builder.CreateAnd(PtrValue, Builder.CreateNot(AlignMask)); return Builder.CreateIntToPtr(PtrValue, AI->getType()); @@ -2171,7 +2172,7 @@ static void lowerLocalAllocas(ArrayRef LocalAllocas, // Allocate memory. auto Alloca = Builder.CreateAlloca(Builder.getInt8Ty(), AI->getSize()); - Alloca->setAlignment(Align(AI->getAlignment())); + Alloca->setAlignment(AI->getAlignment()); for (auto U : AI->users()) { // Replace gets with the allocation.