From 950c95cfdd75a4a150148c9e0bc53f49b44e48bc Mon Sep 17 00:00:00 2001 From: Nathan Lanza Date: Mon, 25 Apr 2022 10:48:55 -0700 Subject: [PATCH] [coroutines] Get an IntegerType from the value instead of defaulting to 64 bit MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This AliasPtr is being created always from an Int64 even for targets where 32 bit is the proper type. e.g. “thumbv7-none-linux-android16”. This causes the assert in the `get` func to fail as we're getting a 32 bit from the APInt. Fix this by simply always just getting the type from the value instead. Reviewed By: ChuanqiXu Differential Revision: https://reviews.llvm.org/D123272 --- llvm/lib/Transforms/Coroutines/CoroFrame.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp index c2f4fe0..9bfcfd9 100644 --- a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp +++ b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp @@ -1760,9 +1760,10 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) { auto *FramePtr = GetFramePointer(Alloca); auto *FramePtrRaw = Builder.CreateBitCast(FramePtr, Type::getInt8PtrTy(C)); - auto *AliasPtr = Builder.CreateGEP( - Type::getInt8Ty(C), FramePtrRaw, - ConstantInt::get(Type::getInt64Ty(C), Alias.second.getValue())); + auto &Value = Alias.second.getValue(); + auto ITy = IntegerType::get(C, Value.getBitWidth()); + auto *AliasPtr = Builder.CreateGEP(Type::getInt8Ty(C), FramePtrRaw, + ConstantInt::get(ITy, Value)); auto *AliasPtrTyped = Builder.CreateBitCast(AliasPtr, Alias.first->getType()); Alias.first->replaceUsesWithIf( -- 2.7.4