[PATCH] D123272: [coroutines] Get an IntegerType from the value instead of defaulting to 64 bit
Nathan Lanza via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 6 18:28:34 PDT 2022
lanza created this revision.
lanza added a reviewer: lxfind.
Herald added subscribers: ChuanqiXu, hiraditya.
Herald added a project: All.
lanza requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
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.
https://reviews.llvm.org/D123272
Files:
llvm/lib/Transforms/Coroutines/CoroFrame.cpp
Index: llvm/lib/Transforms/Coroutines/CoroFrame.cpp
===================================================================
--- llvm/lib/Transforms/Coroutines/CoroFrame.cpp
+++ llvm/lib/Transforms/Coroutines/CoroFrame.cpp
@@ -1760,9 +1760,10 @@
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(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123272.421062.patch
Type: text/x-patch
Size: 937 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220407/6caa696b/attachment.bin>
More information about the llvm-commits
mailing list