Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions llvm/include/llvm/Transforms/Coroutines/CoroInstr.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ class CoroIdInst : public AnyCoroIdInst {
void setInfo(Constant *C) { setArgOperand(InfoArg, C); }

Function *getCoroutine() const {
return cast<Function>(getArgOperand(CoroutineArg)->stripPointerCasts());
return cast<Function>(
getArgOperand(CoroutineArg)->stripPointerCastsAndAliases());
}
void setCoroutineSelf() {
if (!isa<ConstantPointerNull>(getArgOperand(CoroutineArg)))
Expand Down Expand Up @@ -254,17 +255,20 @@ class AnyCoroIdRetconInst : public AnyCoroIdInst {
/// attributes, and calling convention of the continuation function(s)
/// are taken from this declaration.
Function *getPrototype() const {
return cast<Function>(getArgOperand(PrototypeArg)->stripPointerCasts());
return cast<Function>(
getArgOperand(PrototypeArg)->stripPointerCastsAndAliases());
}

/// Return the function to use for allocating memory.
Function *getAllocFunction() const {
return cast<Function>(getArgOperand(AllocArg)->stripPointerCasts());
return cast<Function>(
getArgOperand(AllocArg)->stripPointerCastsAndAliases());
}

/// Return the function to use for deallocating memory.
Function *getDeallocFunction() const {
return cast<Function>(getArgOperand(DeallocArg)->stripPointerCasts());
return cast<Function>(
getArgOperand(DeallocArg)->stripPointerCastsAndAliases());
}

// Methods to support type inquiry through isa, cast, and dyn_cast:
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/IR/Verifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6276,7 +6276,7 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
Check(isa<ConstantPointerNull>(Promise) || isa<AllocaInst>(Promise),
"promise argument must refer to an alloca");

auto *CoroAddr = Call.getArgOperand(2)->stripPointerCasts();
auto *CoroAddr = Call.getArgOperand(2)->stripPointerCastsAndAliases();
bool BeforeCoroEarly = isa<ConstantPointerNull>(CoroAddr);
Check(BeforeCoroEarly || isa<Function>(CoroAddr),
"coro argument must refer to a function");
Expand Down
6 changes: 4 additions & 2 deletions llvm/lib/Transforms/Coroutines/CoroCleanup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,12 @@ bool Lowerer::lower(Function &F) {
break;
case Intrinsic::coro_async_size_replace:
auto *Target = cast<ConstantStruct>(
cast<GlobalVariable>(II->getArgOperand(0)->stripPointerCasts())
cast<GlobalVariable>(
II->getArgOperand(0)->stripPointerCastsAndAliases())
->getInitializer());
auto *Source = cast<ConstantStruct>(
cast<GlobalVariable>(II->getArgOperand(1)->stripPointerCasts())
cast<GlobalVariable>(
II->getArgOperand(1)->stripPointerCastsAndAliases())
->getInitializer());
auto *TargetSize = Target->getOperand(1);
auto *SourceSize = Source->getOperand(1);
Expand Down
9 changes: 5 additions & 4 deletions llvm/lib/Transforms/Coroutines/Coroutines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ void coro::Shape::emitDealloc(IRBuilder<> &Builder, Value *Ptr,
/// Check that the given value is a well-formed prototype for the
/// llvm.coro.id.retcon.* intrinsics.
static void checkWFRetconPrototype(const AnyCoroIdRetconInst *I, Value *V) {
auto F = dyn_cast<Function>(V->stripPointerCasts());
auto F = dyn_cast<Function>(V->stripPointerCastsAndAliases());
if (!F)
fail(I, "llvm.coro.id.retcon.* prototype not a Function", V);

Expand Down Expand Up @@ -591,7 +591,7 @@ static void checkWFRetconPrototype(const AnyCoroIdRetconInst *I, Value *V) {

/// Check that the given value is a well-formed allocator.
static void checkWFAlloc(const Instruction *I, Value *V) {
auto F = dyn_cast<Function>(V->stripPointerCasts());
auto F = dyn_cast<Function>(V->stripPointerCastsAndAliases());
if (!F)
fail(I, "llvm.coro.* allocator not a Function", V);

Expand All @@ -606,7 +606,7 @@ static void checkWFAlloc(const Instruction *I, Value *V) {

/// Check that the given value is a well-formed deallocator.
static void checkWFDealloc(const Instruction *I, Value *V) {
auto F = dyn_cast<Function>(V->stripPointerCasts());
auto F = dyn_cast<Function>(V->stripPointerCastsAndAliases());
if (!F)
fail(I, "llvm.coro.* deallocator not a Function", V);

Expand Down Expand Up @@ -637,7 +637,8 @@ void AnyCoroIdRetconInst::checkWellFormed() const {
}

static void checkAsyncFuncPointer(const Instruction *I, Value *V) {
auto *AsyncFuncPtrAddr = dyn_cast<GlobalVariable>(V->stripPointerCasts());
auto *AsyncFuncPtrAddr =
dyn_cast<GlobalVariable>(V->stripPointerCastsAndAliases());
if (!AsyncFuncPtrAddr)
fail(I, "llvm.coro.id.async async function pointer not a global", V);
}
Expand Down
13 changes: 13 additions & 0 deletions llvm/test/Transforms/Coroutines/coro-id-alias.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
; RUN: opt < %s -passes=coro-early -S | FileCheck %s

declare token @llvm.coro.id(i32, ptr, ptr, ptr)

@foo_alias = alias void (), ptr @foo

define void @foo() presplitcoroutine {
entry:
%id = call token @llvm.coro.id(i32 0, ptr null, ptr @foo_alias, ptr null)
ret void
}
; CHECK-LABEL: define void @foo()
; CHECK: call token @llvm.coro.id(i32 0, ptr null, ptr @foo, ptr null)