[llvm] 950c95c - [coroutines] Get an IntegerType from the value instead of defaulting to 64 bit
Nathan Lanza via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 25 11:11:02 PDT 2022
Author: Nathan Lanza
Date: 2022-04-25T11:10:46-07:00
New Revision: 950c95cfdd75a4a150148c9e0bc53f49b44e48bc
URL: https://github.com/llvm/llvm-project/commit/950c95cfdd75a4a150148c9e0bc53f49b44e48bc
DIFF: https://github.com/llvm/llvm-project/commit/950c95cfdd75a4a150148c9e0bc53f49b44e48bc.diff
LOG: [coroutines] Get an IntegerType from the value instead of defaulting to 64 bit
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
Added:
Modified:
llvm/lib/Transforms/Coroutines/CoroFrame.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
index c2f4fe071dd6a..9bfcfd9a7011b 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(
More information about the llvm-commits
mailing list