diff --git a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp --- a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp +++ b/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(