Skip to content

[coroutine] Fix type of an ImplicitParamDecl used in generateAwaitSuspendWrapper #87134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ahatanak
Copy link
Collaborator

Use the correct type for AwaiterDecl instead of using void *.

See the discussion here:
#79712 (comment)

…pendWrapper

Use the correct type for AwaiterDecl instead of using `void *`.

See the discussion here:
llvm#79712 (comment)
@ahatanak ahatanak requested a review from ChuanqiXu9 March 30, 2024 01:39
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:codegen IR generation bugs: mangling, exceptions, etc. coroutines C++20 coroutines labels Mar 30, 2024
@llvmbot
Copy link
Member

llvmbot commented Mar 30, 2024

@llvm/pr-subscribers-coroutines
@llvm/pr-subscribers-clang-codegen

@llvm/pr-subscribers-clang

Author: Akira Hatanaka (ahatanak)

Changes

Use the correct type for AwaiterDecl instead of using void *.

See the discussion here:
#79712 (comment)


Full diff: https://github.com/llvm/llvm-project/pull/87134.diff

1 Files Affected:

  • (modified) clang/lib/CodeGen/CGCoroutine.cpp (+4-3)
diff --git a/clang/lib/CodeGen/CGCoroutine.cpp b/clang/lib/CodeGen/CGCoroutine.cpp
index 93ca711f716fce..dd005fdaa8f745 100644
--- a/clang/lib/CodeGen/CGCoroutine.cpp
+++ b/clang/lib/CodeGen/CGCoroutine.cpp
@@ -422,7 +422,9 @@ CodeGenFunction::generateAwaitSuspendWrapper(Twine const &CoroName,
 
   FunctionArgList args;
 
-  ImplicitParamDecl AwaiterDecl(C, C.VoidPtrTy, ImplicitParamKind::Other);
+  QualType AwaiterType = S.getOpaqueValue()->getType();
+  ImplicitParamDecl AwaiterDecl(C, C.getPointerType(AwaiterType),
+                                ImplicitParamKind::Other);
   ImplicitParamDecl FrameDecl(C, C.VoidPtrTy, ImplicitParamKind::Other);
   QualType ReturnTy = S.getSuspendExpr()->getType();
 
@@ -449,8 +451,7 @@ CodeGenFunction::generateAwaitSuspendWrapper(Twine const &CoroName,
 
   // FIXME: add TBAA metadata to the loads
   llvm::Value *AwaiterPtr = Builder.CreateLoad(GetAddrOfLocalVar(&AwaiterDecl));
-  auto AwaiterLValue =
-      MakeNaturalAlignAddrLValue(AwaiterPtr, AwaiterDecl.getType());
+  auto AwaiterLValue = MakeNaturalAlignAddrLValue(AwaiterPtr, AwaiterType);
 
   CurAwaitSuspendWrapper.FramePtr =
       Builder.CreateLoad(GetAddrOfLocalVar(&FrameDecl));

@ahatanak
Copy link
Collaborator Author

I don't have a test case yet. I'll see if I can come up with one.

Copy link
Member

@ChuanqiXu9 ChuanqiXu9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change itself looks good to me. It will be better if we can have a reduced test case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:codegen IR generation bugs: mangling, exceptions, etc. clang Clang issues not falling into any other category coroutines C++20 coroutines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants