Skip to content

Commit ef5149f

Browse files
committed
Clarify comments
1 parent 7f321c3 commit ef5149f

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

clang/lib/CodeGen/CGCoroutine.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,16 +452,14 @@ CodeGenFunction::generateAwaitSuspendWrapper(Twine const &CoroName,
452452

453453
StartFunction(GlobalDecl(), ReturnTy, Fn, FI, args);
454454

455+
// FIXME: add TBAA metadata to the loads
455456
llvm::Value *AwaiterPtr = Builder.CreateLoad(GetAddrOfLocalVar(&AwaiterDecl));
456457
auto AwaiterLValue =
457458
MakeNaturalAlignAddrLValue(AwaiterPtr, AwaiterDecl.getType());
458459

459460
CurAwaitSuspendWrapper.FramePtr =
460461
Builder.CreateLoad(GetAddrOfLocalVar(&FrameDecl));
461462

462-
// FIXME: mark as aliasing with frame?
463-
// FIXME: TBAA?
464-
// FIXME: emit in a better way (maybe egenerate AST in SemaCoroutine)?
465463
auto AwaiterBinder = CodeGenFunction::OpaqueValueMappingData::bind(
466464
*this, S.getOpaqueValue(), AwaiterLValue);
467465

llvm/lib/Transforms/Coroutines/CoroInstr.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ class LLVM_LIBRARY_VISIBILITY CoroAllocInst : public IntrinsicInst {
7979
};
8080

8181
/// This represents the llvm.coro.await.suspend instruction.
82+
// FIXME: add callback metadata
83+
// FIXME: make a proper IntrinisicInst. Currently this is not possible,
84+
// because llvm.coro.await.suspend can be invoked.
8285
class LLVM_LIBRARY_VISIBILITY CoroAwaitSuspendInst : public CallBase {
8386
enum { AwaiterArg, FrameArg, WrapperArg };
8487

llvm/lib/Transforms/Coroutines/CoroSplit.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,12 @@ static void lowerAwaitSuspend(IRBuilder<> &Builder, CoroAwaitSuspendInst *CB) {
179179
Builder.SetInsertPoint(CB);
180180

181181
CallBase *NewCall = nullptr;
182+
// await_suspend has only 2 parameters, awaiter and handle.
183+
// Copy parameter attributes from the intrinsic call, but remove the last,
184+
// because the last parameter now becomes the function that is being called.
185+
AttributeList NewAttributes =
186+
CB->getAttributes().removeParamAttributes(CB->getContext(), 2);
187+
182188
if (auto Invoke = dyn_cast<InvokeInst>(CB)) {
183189
auto WrapperInvoke =
184190
Builder.CreateInvoke(Wrapper, Invoke->getNormalDest(),
@@ -187,16 +193,12 @@ static void lowerAwaitSuspend(IRBuilder<> &Builder, CoroAwaitSuspendInst *CB) {
187193
WrapperInvoke->setCallingConv(Invoke->getCallingConv());
188194
std::copy(Invoke->bundle_op_info_begin(), Invoke->bundle_op_info_end(),
189195
WrapperInvoke->bundle_op_info_begin());
190-
AttributeList NewAttributes =
191-
Invoke->getAttributes().removeParamAttributes(Invoke->getContext(), 2);
192196
WrapperInvoke->setAttributes(NewAttributes);
193197
WrapperInvoke->setDebugLoc(Invoke->getDebugLoc());
194198
NewCall = WrapperInvoke;
195199
} else if (auto Call = dyn_cast<CallInst>(CB)) {
196200
auto WrapperCall = Builder.CreateCall(Wrapper, {Awaiter, FramePtr});
197201

198-
AttributeList NewAttributes =
199-
Call->getAttributes().removeParamAttributes(Call->getContext(), 2);
200202
WrapperCall->setAttributes(NewAttributes);
201203
WrapperCall->setDebugLoc(Call->getDebugLoc());
202204
NewCall = WrapperCall;

0 commit comments

Comments
 (0)