[llvm] [llvm][Coroutines] Avoid Type::getPointerTo() (NFC) (PR #110520)
Youngsuk Kim via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 30 08:12:30 PDT 2024
https://github.com/JOE1994 created https://github.com/llvm/llvm-project/pull/110520
`llvm::Type::getPointerTo()` is to be deprecated & removed soon.
In `Lowerer::lowerCoroDone`, also remove the no-op bitcast (1st parameter of `llvm::coro::done` intrinsic is `ptr`).
>From 2ab764e2e96f25882335ed35be0b8224bfb7ecfe Mon Sep 17 00:00:00 2001
From: Youngsuk Kim <youngsuk.kim at hpe.com>
Date: Mon, 30 Sep 2024 09:38:31 -0500
Subject: [PATCH] [llvm][Coroutines] Avoid Type::getPointerTo() (NFC)
`llvm::Type::getPointerTo()` is to be deprecated & removed soon.
In `Lowerer::lowerCoroDone`, also remove the no-op bitcast
(1st parameter of `llvm::coro::done` intrinsic is `ptr`).
---
llvm/lib/Transforms/Coroutines/CoroEarly.cpp | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/llvm/lib/Transforms/Coroutines/CoroEarly.cpp b/llvm/lib/Transforms/Coroutines/CoroEarly.cpp
index 5f8efd1a8f32ea..093a81648c92e1 100644
--- a/llvm/lib/Transforms/Coroutines/CoroEarly.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroEarly.cpp
@@ -34,9 +34,7 @@ class Lowerer : public coro::LowererBase {
public:
Lowerer(Module &M)
: LowererBase(M), Builder(Context),
- AnyResumeFnPtrTy(FunctionType::get(Type::getVoidTy(Context), Int8Ptr,
- /*isVarArg=*/false)
- ->getPointerTo()) {}
+ AnyResumeFnPtrTy(PointerType::getUnqual(Context)) {}
void lowerEarlyIntrinsics(Function &F);
};
}
@@ -91,11 +89,9 @@ void Lowerer::lowerCoroDone(IntrinsicInst *II) {
static_assert(coro::Shape::SwitchFieldIndex::Resume == 0,
"resume function not at offset zero");
auto *FrameTy = Int8Ptr;
- PointerType *FramePtrTy = FrameTy->getPointerTo();
Builder.SetInsertPoint(II);
- auto *BCI = Builder.CreateBitCast(Operand, FramePtrTy);
- auto *Load = Builder.CreateLoad(FrameTy, BCI);
+ auto *Load = Builder.CreateLoad(FrameTy, Operand);
auto *Cond = Builder.CreateICmpEQ(Load, NullPtr);
II->replaceAllUsesWith(Cond);
@@ -128,10 +124,9 @@ void Lowerer::lowerCoroNoop(IntrinsicInst *II) {
// Create a noop.frame struct type.
StructType *FrameTy = StructType::create(C, "NoopCoro.Frame");
- auto *FramePtrTy = FrameTy->getPointerTo();
- auto *FnTy = FunctionType::get(Type::getVoidTy(C), FramePtrTy,
+ auto *FnTy = FunctionType::get(Type::getVoidTy(C), Builder.getPtrTy(0),
/*isVarArg=*/false);
- auto *FnPtrTy = FnTy->getPointerTo();
+ auto *FnPtrTy = Builder.getPtrTy(0);
FrameTy->setBody({FnPtrTy, FnPtrTy});
// Create a Noop function that does nothing.
More information about the llvm-commits
mailing list