[llvm] bfbdb5e - [Coroutines] Avoid some pointer element type accesses
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 21 03:36:28 PST 2022
Author: Nikita Popov
Date: 2022-01-21T12:36:19+01:00
New Revision: bfbdb5e43e50484e179122bfb66cff8165e4b084
URL: https://github.com/llvm/llvm-project/commit/bfbdb5e43e50484e179122bfb66cff8165e4b084
DIFF: https://github.com/llvm/llvm-project/commit/bfbdb5e43e50484e179122bfb66cff8165e4b084.diff
LOG: [Coroutines] Avoid some pointer element type accesses
These are just verifying that pointer types are correct, which is
no longer relevant under opaque pointers.
Added:
Modified:
llvm/lib/Transforms/Coroutines/Coroutines.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Coroutines/Coroutines.cpp b/llvm/lib/Transforms/Coroutines/Coroutines.cpp
index 1078aac257d7..a8123aee319e 100644
--- a/llvm/lib/Transforms/Coroutines/Coroutines.cpp
+++ b/llvm/lib/Transforms/Coroutines/Coroutines.cpp
@@ -676,6 +676,9 @@ static void checkAsyncFuncPointer(const Instruction *I, Value *V) {
if (!AsyncFuncPtrAddr)
fail(I, "llvm.coro.id.async async function pointer not a global", V);
+ if (AsyncFuncPtrAddr->getType()->isOpaquePointerTy())
+ return;
+
auto *StructTy =
cast<StructType>(AsyncFuncPtrAddr->getType()->getPointerElementType());
if (StructTy->isOpaque() || !StructTy->isPacked() ||
@@ -701,14 +704,16 @@ void CoroIdAsyncInst::checkWellFormed() const {
static void checkAsyncContextProjectFunction(const Instruction *I,
Function *F) {
auto *FunTy = cast<FunctionType>(F->getValueType());
- if (!FunTy->getReturnType()->isPointerTy() ||
- !FunTy->getReturnType()->getPointerElementType()->isIntegerTy(8))
+ Type *Int8Ty = Type::getInt8Ty(F->getContext());
+ auto *RetPtrTy = dyn_cast<PointerType>(FunTy->getReturnType());
+ if (!RetPtrTy || !RetPtrTy->isOpaqueOrPointeeTypeMatches(Int8Ty))
fail(I,
"llvm.coro.suspend.async resume function projection function must "
"return an i8* type",
F);
if (FunTy->getNumParams() != 1 || !FunTy->getParamType(0)->isPointerTy() ||
- !FunTy->getParamType(0)->getPointerElementType()->isIntegerTy(8))
+ !cast<PointerType>(FunTy->getParamType(0))
+ ->isOpaqueOrPointeeTypeMatches(Int8Ty))
fail(I,
"llvm.coro.suspend.async resume function projection function must "
"take one i8* type as parameter",
@@ -723,8 +728,7 @@ void CoroAsyncEndInst::checkWellFormed() const {
auto *MustTailCallFunc = getMustTailCallFunction();
if (!MustTailCallFunc)
return;
- auto *FnTy =
- cast<FunctionType>(MustTailCallFunc->getType()->getPointerElementType());
+ auto *FnTy = MustTailCallFunc->getFunctionType();
if (FnTy->getNumParams() != (arg_size() - 3))
fail(this,
"llvm.coro.end.async must tail call function argument type must "
More information about the llvm-commits
mailing list