Skip to content

[Coroutines] Improved formatting of the SpillUtils comment on ptr tracking #112376

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

Merged

Conversation

TylerNowicki
Copy link
Collaborator

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Oct 15, 2024

@llvm/pr-subscribers-coroutines

@llvm/pr-subscribers-llvm-transforms

Author: Tyler Nowicki (TylerNowicki)

Changes

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

1 Files Affected:

  • (modified) llvm/lib/Transforms/Coroutines/SpillUtils.cpp (+22-16)
diff --git a/llvm/lib/Transforms/Coroutines/SpillUtils.cpp b/llvm/lib/Transforms/Coroutines/SpillUtils.cpp
index e8609af992122c..58e83ea83d5211 100644
--- a/llvm/lib/Transforms/Coroutines/SpillUtils.cpp
+++ b/llvm/lib/Transforms/Coroutines/SpillUtils.cpp
@@ -118,29 +118,35 @@ static Instruction *splitBeforeCatchSwitch(CatchSwitchInst *CatchSwitch) {
 
 // We use a pointer use visitor to track how an alloca is being used.
 // The goal is to be able to answer the following three questions:
-// 1. Should this alloca be allocated on the frame instead.
-// 2. Could the content of the alloca be modified prior to CoroBegn, which would
-// require copying the data from alloca to the frame after CoroBegin.
-// 3. Is there any alias created for this alloca prior to CoroBegin, but used
-// after CoroBegin. In that case, we will need to recreate the alias after
-// CoroBegin based off the frame. To answer question 1, we track two things:
-//   a. List of all BasicBlocks that use this alloca or any of the aliases of
+//   1. Should this alloca be allocated on the frame instead.
+//   2. Could the content of the alloca be modified prior to CoroBegin, which
+//      would require copying the data from the alloca to the frame after
+//      CoroBegin.
+//   3. Are there any aliases created for this alloca prior to CoroBegin, but
+//      used after CoroBegin. In that case, we will need to recreate the alias
+//      after CoroBegin based off the frame.
+//
+// To answer question 1, we track two things:
+//   A. List of all BasicBlocks that use this alloca or any of the aliases of
 //   the alloca. In the end, we check if there exists any two basic blocks that
-//   cross suspension points. If so, this alloca must be put on the frame. b.
-//   Whether the alloca or any alias of the alloca is escaped at some point,
+//   cross suspension points. If so, this alloca must be put on the frame.
+//   B. Whether the alloca or any alias of the alloca is escaped at some point,
 //   either by storing the address somewhere, or the address is used in a
 //   function call that might capture. If it's ever escaped, this alloca must be
 //   put on the frame conservatively.
+//
 // To answer quetion 2, we track through the variable MayWriteBeforeCoroBegin.
 // Whenever a potential write happens, either through a store instruction, a
 // function call or any of the memory intrinsics, we check whether this
-// instruction is prior to CoroBegin. To answer question 3, we track the offsets
-// of all aliases created for the alloca prior to CoroBegin but used after
-// CoroBegin. std::optional is used to be able to represent the case when the
-// offset is unknown (e.g. when you have a PHINode that takes in different
-// offset values). We cannot handle unknown offsets and will assert. This is the
-// potential issue left out. An ideal solution would likely require a
-// significant redesign.
+// instruction is prior to CoroBegin.
+//
+// To answer question 3, we track the offsets of all aliases created for the
+// alloca prior to CoroBegin but used after CoroBegin. std::optional is used to
+// be able to represent the case when the offset is unknown (e.g. when you have
+// a PHINode that takes in different offset values). We cannot handle unknown
+// offsets and will assert. This is the potential issue left out. An ideal
+// solution would likely require a significant redesign.
+
 namespace {
 struct AllocaUseVisitor : PtrUseVisitor<AllocaUseVisitor> {
   using Base = PtrUseVisitor<AllocaUseVisitor>;

@TylerNowicki TylerNowicki merged commit 867e042 into llvm:main Oct 15, 2024
11 checks passed
@TylerNowicki TylerNowicki deleted the users/tylernowicki/coro-comment-fixup branch October 15, 2024 17:20
@ChuanqiXu9
Copy link
Member

Some nits comment: generally we like to see [NFC] in the title of such comments and a label like skip-precommit-approval

DanielCChen pushed a commit to DanielCChen/llvm-project that referenced this pull request Oct 16, 2024
@TylerNowicki TylerNowicki added the skip-precommit-approval PR for CI feedback, not intended for review label Oct 16, 2024
@TylerNowicki
Copy link
Collaborator Author

Some nits comment: generally we like to see [NFC] in the title of such comments and a label like skip-precommit-approval

Sorry, I didn't realize. I will do that in the future. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
coroutines C++20 coroutines llvm:transforms skip-precommit-approval PR for CI feedback, not intended for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants