llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: Weibo He (NewSigma)

<details>
<summary>Changes</summary>

#<!-- -->192351 demonstrated that certain passes can sink memory-none 
instructions after the coroutine frame has been freed.

Reloading from the frame is unnecessary when the original SSA value is still 
available. This patch proposes that instructions in the ramp function directly 
reference the original SSA values rather than reloading them from the coroutine 
frame, thereby preventing loads from a potentially dead frame. This change also 
eliminates several redundant load instructions in my benchmarks.

---

Patch is 26.48 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/218309.diff


12 Files Affected:

- (modified) clang/test/CodeGenCoroutines/coro-suspend-cleanups.cpp (+3-2) 
- (modified) llvm/lib/Transforms/Coroutines/CoroFrame.cpp (+50-15) 
- (modified) llvm/test/Transforms/Coroutines/coro-async.ll (+4-4) 
- (modified) llvm/test/Transforms/Coroutines/coro-catchswitch-cleanuppad.ll 
(+6-6) 
- (modified) llvm/test/Transforms/Coroutines/coro-catchswitch.ll (+1-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-frame.ll (+2-2) 
- (modified) llvm/test/Transforms/Coroutines/coro-retcon-once-value.ll (+4-4) 
- (modified) llvm/test/Transforms/Coroutines/coro-retcon-once-value2.ll (+4-4) 
- (modified) llvm/test/Transforms/Coroutines/coro-retcon-resume-values.ll 
(+5-5) 
- (modified) llvm/test/Transforms/Coroutines/coro-retcon-resume-values2.ll 
(+5-5) 
- (modified) llvm/test/Transforms/Coroutines/coro-retcon.ll (+4-6) 
- (added) llvm/test/Transforms/Coroutines/coro-spill-ramp.ll (+84) 


``````````diff
diff --git a/clang/test/CodeGenCoroutines/coro-suspend-cleanups.cpp 
b/clang/test/CodeGenCoroutines/coro-suspend-cleanups.cpp
index 6c05d02d0642f..fa5d74e743b3f 100644
--- a/clang/test/CodeGenCoroutines/coro-suspend-cleanups.cpp
+++ b/clang/test/CodeGenCoroutines/coro-suspend-cleanups.cpp
@@ -59,8 +59,9 @@ coroutine ArrayInitCoro() {
   // CHECK:         br label %cleanup{{.*}}
 
   // CHECK:       await.ready:
-  // CHECK-NEXT:    %arrayinit.element.reload.addr = getelementptr inbounds 
i8, ptr %0, i64 48
-  // CHECK-NEXT:    %arrayinit.element.reload = load ptr, ptr 
%arrayinit.element.reload.addr, align 8
+  // CHECK-NEXT:    br label %await.ready.after.spill
+
+  // CHECK:       await.ready.after.spill:
   // CHECK-NEXT:    call void @_ZN7Awaiter12await_resumeEv
   // CHECK-NEXT:    store i1 false, ptr %cleanup.isactive.reload.addr, align 1
   // CHECK-NEXT:    br label %cleanup{{.*}}.from.await.ready
diff --git a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp 
b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
index c59e65f270a23..2b5fec3ffaad3 100644
--- a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp
@@ -1086,20 +1086,48 @@ static void insertSpills(const FrameDataInfo 
&FrameData, coro::Shape &Shape) {
 
     Builder.SetInsertPoint(coro::getSpillInsertionPt(Shape, Def, DT));
     createStoreIntoFrame(Builder, Def, ByValTy, Shape, FrameData);
-
-    BasicBlock *CurrentBlock = nullptr;
+    // Before insertSpills():
+    //   before.spill:
+    //     ; use %def
+    //
+    // After insertSpills():
+    //   before.spill:
+    //     (phis)
+    //     %InRamp = call i1 @llvm.coro.is_in_ramp()
+    //     br i1 %InRamp, label %after.spill, label %ssa.spill
+    //
+    //   ssa.spill:
+    //     ; gep and load from frame
+    //     br label %after.spill
+    //
+    //   after.spill:
+    //     %MaybeReload = phi ptr [%def, %before.spill], [%reload, %ssa.spill]
+    //     ; use %MaybeReload
+    BasicBlock *BeforeSpillBB = nullptr;
+    BasicBlock *SpillBB = nullptr;
+    BasicBlock *AfterSpillBB = nullptr;
     Value *CurrentReload = nullptr;
     for (auto *U : E.second) {
       // If we have not seen the use block, create a load instruction to reload
       // the spilled value from the coroutine frame. Populates the Value 
pointer
       // reference provided with the frame GEP.
-      if (CurrentBlock != U->getParent()) {
-        CurrentBlock = U->getParent();
-        Builder.SetInsertPoint(CurrentBlock,
-                               CurrentBlock->getFirstInsertionPt());
-
-        auto *GEP = createGEPToFramePointer(FrameData, Builder, Shape, 
E.first);
-        GEP->setName(E.first->getName() + Twine(".reload.addr"));
+      if (BeforeSpillBB != U->getParent()) {
+        BeforeSpillBB = U->getParent();
+        AfterSpillBB = BeforeSpillBB->splitBasicBlock(
+            BeforeSpillBB->getFirstInsertionPt(),
+            BeforeSpillBB->getName() + Twine(".after.spill"));
+        SpillBB = BasicBlock::Create(
+            C, BeforeSpillBB->getName() + Twine(".spill"), F, AfterSpillBB);
+
+        BeforeSpillBB->getTerminator()->eraseFromParent();
+        Builder.SetInsertPoint(BeforeSpillBB);
+        auto *InRamp = Builder.CreateIntrinsic(Intrinsic::coro_is_in_ramp, {});
+        Builder.CreateCondBr(InRamp, AfterSpillBB, SpillBB);
+        Shape.CoroIsInRampInsts.push_back(cast<CoroIsInRampInst>(InRamp));
+
+        Builder.SetInsertPoint(SpillBB);
+        auto *GEP = createGEPToFramePointer(FrameData, Builder, Shape, Def);
+        GEP->setName(Def->getName() + Twine(".reload.addr"));
         if (ByValTy) {
           CurrentReload = GEP;
         } else {
@@ -1111,6 +1139,7 @@ static void insertSpills(const FrameDataInfo &FrameData, 
coro::Shape &Shape) {
             LI->setMetadata(LLVMContext::MD_tbaa, TBAATag);
           CurrentReload = LI;
         }
+        Builder.CreateBr(AfterSpillBB);
 
         TinyPtrVector<DbgVariableRecord *> DVRs = findDbgRecordsThroughLoads<
             DbgVariableRecord::LocationType::Declare>(*F, Def);
@@ -1123,8 +1152,8 @@ static void insertSpills(const FrameDataInfo &FrameData, 
coro::Shape &Shape) {
               ValueAsMetadata::get(CurrentReload), DDI->getVariable(),
               DDI->getExpression(), DDI->getDebugLoc(),
               DbgVariableRecord::LocationType::Declare);
-          Builder.GetInsertPoint()->getParent()->insertDbgRecordBefore(
-              NewDVR, Builder.GetInsertPoint());
+          BeforeSpillBB->insertDbgRecordBefore(
+              NewDVR, BeforeSpillBB->getFirstInsertionPt());
           // This dbg.declare is for the main function entry point.  It
           // will be deleted in all coro-split functions.
           coro::salvageDebugInfo(ArgToAllocaMap, *DDI, false 
/*UseEntryValue*/);
@@ -1150,14 +1179,20 @@ static void insertSpills(const FrameDataInfo 
&FrameData, coro::Shape &Shape) {
             DDI->getExpression(), DDI->getDebugLoc(),
             Ty->isPointerTy() ? DbgVariableRecord::LocationType::Declare
                               : DbgVariableRecord::LocationType::Value);
-        Builder.GetInsertPoint()->getParent()->insertDbgRecordBefore(
-            NewDVR, Builder.GetInsertPoint());
+        BeforeSpillBB->insertDbgRecordBefore(
+            NewDVR, BeforeSpillBB->getFirstInsertionPt());
         // This dbg.declare_value is for the main function entry point.  It
         // will be deleted in all coro-split functions.
         coro::salvageDebugInfo(ArgToAllocaMap, *DDI, false /*UseEntryValue*/);
       };
       for_each(DVRDeclareValues, SalvageOneCoro);
 
+      Builder.SetInsertPoint(AfterSpillBB->getFirstInsertionPt());
+      // No need to reload if the original SSA value is available
+      auto *MaybeReload = Builder.CreatePHI(Def->getType(), 2);
+      MaybeReload->addIncoming(CurrentReload, SpillBB);
+      MaybeReload->addIncoming(Def, BeforeSpillBB);
+
       // If we have a single edge PHINode, remove it and replace it with a
       // reload from the coroutine frame. (We already took care of multi edge
       // PHINodes by normalizing them in the rewritePHIs function).
@@ -1165,14 +1200,14 @@ static void insertSpills(const FrameDataInfo 
&FrameData, coro::Shape &Shape) {
         assert(PN->getNumIncomingValues() == 1 &&
                "unexpected number of incoming "
                "values in the PHINode");
-        PN->replaceAllUsesWith(CurrentReload);
+        PN->replaceAllUsesWith(MaybeReload);
         PN->eraseFromParent();
         continue;
       }
 
       // Replace all uses of CurrentValue in the current instruction with
       // reload.
-      U->replaceUsesOfWith(Def, CurrentReload);
+      U->replaceUsesOfWith(Def, MaybeReload);
       // Instructions are added to Def's user list if the attached
       // debug records use Def. Update those now.
       for (DbgVariableRecord &DVR : filterDbgVars(U->getDbgRecordRange()))
diff --git a/llvm/test/Transforms/Coroutines/coro-async.ll 
b/llvm/test/Transforms/Coroutines/coro-async.ll
index 3454737820b7a..fd433a225143f 100644
--- a/llvm/test/Transforms/Coroutines/coro-async.ll
+++ b/llvm/test/Transforms/Coroutines/coro-async.ll
@@ -151,12 +151,12 @@ define void @my_async_function_pa(ptr %ctxt, ptr %task, 
ptr %actor) {
 ; CHECK:   [[FRAME_PTR:%.*]] = getelementptr inbounds nuw i8, ptr 
[[CALLER_CONTEXT]], i64 128
 ; CHECK-O0:   [[VECTOR_SPILL_ADDR:%.*]] = getelementptr inbounds i8, ptr 
{{.*}}, i64 32
 ; CHECK-O0:   load <4 x double>, ptr [[VECTOR_SPILL_ADDR]], align 16
-; CHECK:   [[CALLEE_CTXT_SPILL_ADDR:%.*]] = getelementptr inbounds nuw i8, ptr 
[[CALLER_CONTEXT]], i64 160
-; CHECK:   [[CALLEE_CTXT_RELOAD:%.*]] = load ptr, ptr 
[[CALLEE_CTXT_SPILL_ADDR]]
-; CHECK:   [[ACTOR_RELOAD_ADDR:%.*]] = getelementptr inbounds nuw i8, ptr 
[[CALLER_CONTEXT]], i64 152
-; CHECK:   [[ACTOR_RELOAD:%.*]] = load ptr, ptr [[ACTOR_RELOAD_ADDR]]
 ; CHECK:   [[ADDR1:%.*]] = getelementptr inbounds nuw i8, ptr 
[[CALLER_CONTEXT]], i64 144
 ; CHECK:   [[ASYNC_CTXT_RELOAD:%.*]] = load ptr, ptr [[ADDR1]]
+; CHECK:   [[ACTOR_RELOAD_ADDR:%.*]] = getelementptr inbounds nuw i8, ptr 
[[CALLER_CONTEXT]], i64 152
+; CHECK:   [[ACTOR_RELOAD:%.*]] = load ptr, ptr [[ACTOR_RELOAD_ADDR]]
+; CHECK:   [[CALLEE_CTXT_SPILL_ADDR:%.*]] = getelementptr inbounds nuw i8, ptr 
[[CALLER_CONTEXT]], i64 160
+; CHECK:   [[CALLEE_CTXT_RELOAD:%.*]] = load ptr, ptr 
[[CALLEE_CTXT_SPILL_ADDR]]
 ; CHECK:   [[ALLOCA_PRJ2:%.*]] = getelementptr inbounds nuw i8, ptr 
[[CALLER_CONTEXT]], i64 136
 ; CHECK:   tail call void @llvm.coro.async.context.dealloc(ptr nonnull 
[[CALLEE_CTXT_RELOAD]])
 ; CHECK:   [[VAL1:%.*]] = load i64, ptr [[FRAME_PTR]]
diff --git a/llvm/test/Transforms/Coroutines/coro-catchswitch-cleanuppad.ll 
b/llvm/test/Transforms/Coroutines/coro-catchswitch-cleanuppad.ll
index 945b364cbad70..c7890620fced7 100644
--- a/llvm/test/Transforms/Coroutines/coro-catchswitch-cleanuppad.ll
+++ b/llvm/test/Transforms/Coroutines/coro-catchswitch-cleanuppad.ll
@@ -81,18 +81,18 @@ cleanup2:
 ; CHECK:   %1 = phi i8 [ 0, %handler2 ], [ 1, %catch.dispatch.2 ]
 ; CHECK:   %2 = cleanuppad within %h1 []
 ; CHECK:   %3 = icmp eq i8 %1, 0
-; CHECK:   br i1 %3, label %cleanup2.from.handler2, label 
%cleanup2.from.catch.dispatch.2, !prof [[PROF1:![0-9]+]]
+; CHECK:   br i1 %3, label %[[FROM_HANDLER:.+]], label %[[FROM_DISPATCH:.+]], 
!prof [[PROF1:![0-9]+]]
 
-; CHECK: cleanup2.from.handler2:
-; CHECK:   %valueB.reload = load i32, ptr %valueB.spill.addr, align 4
+; CHECK: [[FROM_HANDLER]]:
+; CHECK:   %valueB.reload = load i32, ptr %valueB.reload.addr, align 4
 ; CHECK:   br label %cleanup2
 
-; CHECK: cleanup2.from.catch.dispatch.2:
-; CHECK:   %valueA.reload = load i32, ptr %valueA.spill.addr, align 4
+; CHECK: [[FROM_DISPATCH]]:
+; CHECK:   %valueA.reload = load i32, ptr %valueA.reload.addr, align 4
 ; CHECK:   br label %cleanup2
 
 ; CHECK: cleanup2:
-; CHECK:   %cleanupval2 = phi i32 [ %valueA.reload, 
%cleanup2.from.catch.dispatch.2 ], [ %valueB.reload, %cleanup2.from.handler2 ]
+; CHECK:   %cleanupval2 = phi i32 [ %valueA.reload, %[[FROM_DISPATCH]] ], [ 
%valueB.reload, %[[FROM_HANDLER]] ]
 ; CHECK:   call void @print(i32 %cleanupval2)
 ; CHECK:   br label %cleanup
 }
diff --git a/llvm/test/Transforms/Coroutines/coro-catchswitch.ll 
b/llvm/test/Transforms/Coroutines/coro-catchswitch.ll
index 776d2bfac2339..f09bb609e09da 100644
--- a/llvm/test/Transforms/Coroutines/coro-catchswitch.ll
+++ b/llvm/test/Transforms/Coroutines/coro-catchswitch.ll
@@ -38,8 +38,7 @@ define void @f(i1 %cond) presplitcoroutine personality i32 0 {
 ; CHECK-NEXT:    store i1 false, ptr [[INDEX_ADDR3]], align 1
 ; CHECK-NEXT:    br i1 false, label %[[RESUME:.*]], label %[[AFTERCOROEND]]
 ; CHECK:       [[RESUME]]:
-; CHECK-NEXT:    [[VAL_RELOAD:%.*]] = load i32, ptr [[VAL_SPILL_ADDR]], align 4
-; CHECK-NEXT:    call void @print(i32 [[VAL_RELOAD]])
+; CHECK-NEXT:    call void @print(i32 [[VAL]])
 ; CHECK-NEXT:    br label %[[AFTERCOROEND]]
 ; CHECK:       [[AFTERCOROEND]]:
 ; CHECK-NEXT:    ret void
diff --git a/llvm/test/Transforms/Coroutines/coro-frame.ll 
b/llvm/test/Transforms/Coroutines/coro-frame.ll
index 2af186e405d54..c7f6c4774de2e 100644
--- a/llvm/test/Transforms/Coroutines/coro-frame.ll
+++ b/llvm/test/Transforms/Coroutines/coro-frame.ll
@@ -75,10 +75,10 @@ declare void @free(ptr)
 ; CHECK-LABEL: define internal void @f.resume(
 ; CHECK-SAME: ptr noundef nonnull align 8 dereferenceable(40) [[HDL:%.*]]) 
personality i32 0 {
 ; CHECK-NEXT:  [[ENTRY_RESUME:.*:]]
-; CHECK-NEXT:    [[R_RELOAD_ADDR:%.*]] = getelementptr inbounds i8, ptr 
[[HDL]], i64 16
-; CHECK-NEXT:    [[R_RELOAD:%.*]] = load double, ptr [[R_RELOAD_ADDR]], align 8
 ; CHECK-NEXT:    [[THIS1_RELOAD_ADDR:%.*]] = getelementptr inbounds i8, ptr 
[[HDL]], i64 24
 ; CHECK-NEXT:    [[THIS1_RELOAD:%.*]] = load i64, ptr [[THIS1_RELOAD_ADDR]], 
align 4
+; CHECK-NEXT:    [[R_RELOAD_ADDR:%.*]] = getelementptr inbounds i8, ptr 
[[HDL]], i64 16
+; CHECK-NEXT:    [[R_RELOAD:%.*]] = load double, ptr [[R_RELOAD_ADDR]], align 8
 ; CHECK-NEXT:    [[TMP0:%.*]] = call double @print(double [[R_RELOAD]])
 ; CHECK-NEXT:    call void @print2(i64 [[THIS1_RELOAD]])
 ; CHECK-NEXT:    [[MEM:%.*]] = call ptr @llvm.coro.free(token poison, ptr 
[[HDL]])
diff --git a/llvm/test/Transforms/Coroutines/coro-retcon-once-value.ll 
b/llvm/test/Transforms/Coroutines/coro-retcon-once-value.ll
index 74a3f8d449d0c..e83d8f0e13690 100644
--- a/llvm/test/Transforms/Coroutines/coro-retcon-once-value.ll
+++ b/llvm/test/Transforms/Coroutines/coro-retcon-once-value.ll
@@ -123,7 +123,7 @@ declare void @print(i32)
 ; CHECK-LABEL: @f.resume.0(
 ; CHECK-NEXT:  entryresume.0:
 ; CHECK-NEXT:    br i1 [[TMP1:%.*]], label [[COROEND:%.*]], label 
[[CLEANUP_SINK_SPLIT:%.*]]
-; CHECK:       cleanup.sink.split:
+; CHECK:       cleanup.sink.split.after.spill:
 ; CHECK-NEXT:    [[ARRAY_RELOAD:%.*]] = load ptr, ptr [[TMP0:%.*]], align 8
 ; CHECK-NEXT:    store i32 0, ptr [[ARRAY_RELOAD]], align 4
 ; CHECK-NEXT:    br label [[COROEND]]
@@ -134,7 +134,7 @@ declare void @print(i32)
 ; CHECK-LABEL: @f.resume.1(
 ; CHECK-NEXT:  entryresume.1:
 ; CHECK-NEXT:    br i1 [[TMP1:%.*]], label [[COROEND:%.*]], label 
[[CLEANUP_SINK_SPLIT:%.*]]
-; CHECK:       cleanup.sink.split:
+; CHECK:       cleanup.sink.split.after.spill:
 ; CHECK-NEXT:    [[ARRAY_RELOAD:%.*]] = load ptr, ptr [[TMP0:%.*]], align 8
 ; CHECK-NEXT:    store i32 10, ptr [[ARRAY_RELOAD]], align 4
 ; CHECK-NEXT:    br label [[COROEND]]
@@ -175,7 +175,7 @@ declare void @print(i32)
 ; CHECK-NEXT:  entryresume.0:
 ; CHECK-NEXT:    [[TMP2:%.*]] = load ptr, ptr [[TMP0:%.*]], align 8
 ; CHECK-NEXT:    br i1 [[TMP1:%.*]], label [[COROEND:%.*]], label 
[[CLEANUP_SINK_SPLIT:%.*]]
-; CHECK:       cleanup.sink.split:
+; CHECK:       cleanup.sink.split.after.spill:
 ; CHECK-NEXT:    [[ARRAY_RELOAD:%.*]] = load ptr, ptr [[TMP2]], align 8
 ; CHECK-NEXT:    store i32 0, ptr [[ARRAY_RELOAD]], align 4
 ; CHECK-NEXT:    br label [[COROEND]]
@@ -193,7 +193,7 @@ declare void @print(i32)
 ; CHECK-NEXT:  entryresume.1:
 ; CHECK-NEXT:    [[TMP2:%.*]] = load ptr, ptr [[TMP0:%.*]], align 8
 ; CHECK-NEXT:    br i1 [[TMP1:%.*]], label [[COROEND:%.*]], label 
[[CLEANUP_SINK_SPLIT:%.*]]
-; CHECK:       cleanup.sink.split:
+; CHECK:       cleanup.sink.split.after.spill:
 ; CHECK-NEXT:    [[ARRAY_RELOAD:%.*]] = load ptr, ptr [[TMP2]], align 8
 ; CHECK-NEXT:    store i32 10, ptr [[ARRAY_RELOAD]], align 4
 ; CHECK-NEXT:    br label [[COROEND]]
diff --git a/llvm/test/Transforms/Coroutines/coro-retcon-once-value2.ll 
b/llvm/test/Transforms/Coroutines/coro-retcon-once-value2.ll
index bf95b2a74e6de..b9f271bbb5635 100644
--- a/llvm/test/Transforms/Coroutines/coro-retcon-once-value2.ll
+++ b/llvm/test/Transforms/Coroutines/coro-retcon-once-value2.ll
@@ -99,7 +99,7 @@ declare void @print(i32)
 ; CHECK-NEXT:    [[TMP2:%.*]] = load ptr, ptr [[TMP0:%.*]], align 8
 ; CHECK-NEXT:    [[TEMP:%.*]] = getelementptr inbounds i8, ptr [[TMP2]], i64 8
 ; CHECK-NEXT:    br i1 [[TMP1:%.*]], label [[COROEND:%.*]], label [[CONT:%.*]]
-; CHECK:       cont:
+; CHECK:       cont.spill:
 ; CHECK-NEXT:    [[PTR_RELOAD:%.*]] = load ptr, ptr [[TMP2]], align 8
 ; CHECK-NEXT:    [[NEWVALUE:%.*]] = load i32, ptr [[TEMP]], align 4
 ; CHECK-NEXT:    store i32 [[NEWVALUE]], ptr [[PTR_RELOAD]], align 4
@@ -128,12 +128,12 @@ declare void @print(i32)
 ; CHECK-NEXT:    [[TMP2:%.*]] = load ptr, ptr [[TMP0:%.*]], align 8
 ; CHECK-NEXT:    [[TEMP:%.*]] = getelementptr inbounds i8, ptr [[TMP2]], i64 8
 ; CHECK-NEXT:    br i1 [[TMP1:%.*]], label [[CLEANUP:%.*]], label [[CONT:%.*]]
-; CHECK:       cont:
+; CHECK:       cont.spill:
 ; CHECK-NEXT:    [[PTR_RELOAD:%.*]] = load ptr, ptr [[TMP2]], align 8
 ; CHECK-NEXT:    [[NEWVALUE:%.*]] = load i32, ptr [[TEMP]], align 4
 ; CHECK-NEXT:    store i32 [[NEWVALUE]], ptr [[PTR_RELOAD]], align 4
 ; CHECK-NEXT:    br label [[CLEANUP]]
-; CHECK:       cleanup:
+; CHECK:       cleanup.spill:
 ; CHECK-NEXT:    [[VAL_RELOAD_ADDR:%.*]] = getelementptr inbounds i8, ptr 
[[TMP2]], i64 12
 ; CHECK-NEXT:    [[VAL_RELOAD:%.*]] = load i8, ptr [[VAL_RELOAD_ADDR]], align 1
 ; CHECK-NEXT:    call fastcc void @deallocate(ptr [[TMP2]])
@@ -157,7 +157,7 @@ declare void @print(i32)
 ; CHECK-NEXT:    [[TMP2:%.*]] = load ptr, ptr [[TMP0:%.*]], align 8
 ; CHECK-NEXT:    [[TEMP:%.*]] = getelementptr inbounds i8, ptr [[TMP2]], i64 8
 ; CHECK-NEXT:    br i1 [[TMP1:%.*]], label [[COROEND:%.*]], label [[CONT:%.*]]
-; CHECK:       cont:
+; CHECK:       cont.spill:
 ; CHECK-NEXT:    [[PTR_RELOAD:%.*]] = load ptr, ptr [[TMP2]], align 8
 ; CHECK-NEXT:    [[NEWVALUE:%.*]] = load i32, ptr [[TEMP]], align 4
 ; CHECK-NEXT:    store i32 [[NEWVALUE]], ptr [[PTR_RELOAD]], align 4
diff --git a/llvm/test/Transforms/Coroutines/coro-retcon-resume-values.ll 
b/llvm/test/Transforms/Coroutines/coro-retcon-resume-values.ll
index 2f04453d69c4b..489e9799a119f 100644
--- a/llvm/test/Transforms/Coroutines/coro-retcon-resume-values.ll
+++ b/llvm/test/Transforms/Coroutines/coro-retcon-resume-values.ll
@@ -40,14 +40,14 @@ define i32 @main() {
 ; CHECK-NEXT:    store i32 1, ptr [[TMP0]], align 4
 ; CHECK-NEXT:    [[N_VAL3_SPILL_ADDR_I:%.*]] = getelementptr inbounds nuw i8, 
ptr [[TMP0]], i64 4
 ; CHECK-NEXT:    store i32 1, ptr [[N_VAL3_SPILL_ADDR_I]], align 4, !noalias 
[[META0:![0-9]+]]
-; CHECK-NEXT:    [[INPUT_SPILL_ADDR_I:%.*]] = getelementptr inbounds nuw i8, 
ptr [[TMP0]], i64 8
-; CHECK-NEXT:    store i32 2, ptr [[INPUT_SPILL_ADDR_I]], align 4, !noalias 
[[META0]]
 ; CHECK-NEXT:    [[INPUT_RELOAD_ADDR13_I:%.*]] = getelementptr inbounds nuw 
i8, ptr [[TMP0]], i64 8
+; CHECK-NEXT:    store i32 2, ptr [[INPUT_RELOAD_ADDR13_I]], align 4, !noalias 
[[META0]]
 ; CHECK-NEXT:    [[N_VAL3_RELOAD_ADDR11_I:%.*]] = getelementptr inbounds nuw 
i8, ptr [[TMP0]], i64 4
+; CHECK-NEXT:    [[INPUT_RELOAD_ADDR14_I:%.*]] = getelementptr inbounds nuw 
i8, ptr [[TMP0]], i64 8
 ; CHECK-NEXT:    store i32 3, ptr [[N_VAL3_RELOAD_ADDR11_I]], align 4, 
!noalias [[META3:![0-9]+]]
-; CHECK-NEXT:    store i32 4, ptr [[INPUT_RELOAD_ADDR13_I]], align 4, !noalias 
[[META3]]
-; CHECK-NEXT:    tail call void @print(i32 7), !noalias [[META6:![0-9]+]]
-; CHECK-NEXT:    tail call void @deallocate(ptr nonnull [[TMP0]]), !noalias 
[[META6]]
+; CHECK-NEXT:    store i32 4, ptr [[INPUT_RELOAD_ADDR14_I]], align 4, !noalias 
[[META3]]
+; CHECK-NEXT:    tail call void @print(i32 7), !noalias [[META6:![0-9]+]], 
!inline_history [[META9:![0-9]+]]
+; CHECK-NEXT:    tail call void @deallocate(ptr nonnull [[TMP0]]), !noalias 
[[META6]], !inline_history [[META9]]
 ; CHECK-NEXT:    ret i32 0
 ;
 entry:
diff --git a/llvm/test/Transforms/Coroutines/coro-retcon-resume-values2.ll 
b/llvm/test/Transforms/Coroutines/coro-retcon-resume-values2.ll
index b1dfbd1b6d4f6..6441456c5ac28 100644
--- a/llvm/test/Transforms/Coroutines/coro-retcon-resume-values2.ll
+++ b/llvm/test/Transforms/Coroutines/coro-retcon-resume-values2.ll
@@ -58,10 +58,10 @@ declare void @print(i32)
 ; CHECK-NEXT:    [[TMP2:%.*]] = load ptr, ptr [[TMP0:%.*]], align 8
 ; CHECK-NEXT:    [[VALUE1_SPILL_ADDR:%.*]] = getelementptr inbounds i8, ptr 
[[TMP2]], i64 12
 ; CHECK-NEXT:    store i32 [[TMP1:%.*]], ptr [[VALUE1_SPILL_ADDR]], align 4
-; CHECK-NEXT:    [[SUM0_RELOAD_ADDR:%.*]] = getelementptr inbounds i8, ptr 
[[TMP2]], i64 8
-; CHECK-NEXT:    [[SUM0_RELOAD:%.*]] = load i32, ptr [[SUM0_RELOAD_ADDR]], 
align 4
 ; CHECK-NEXT:    [[VALUE0_RELOAD_ADDR5:%.*]] = getelementptr inbounds i8, ptr 
[[TMP2]], i64 4
 ; CHECK-NEXT:    [[VALUE0_RELOAD6:%.*]] = load i32, ptr 
[[VALUE0_RELOAD_ADDR5]], align 4
+; CHECK-NEXT:    [[SUM0_RELOAD_ADDR:%.*]] = getelementptr inbounds i8, ptr 
[[TMP2]], i64 8
+; CHECK-NEXT:    [[SUM0_RELOAD:%.*]] = load i32, ptr [[SUM0_RELOAD_ADDR]], 
align 4
 ; CHECK-NEXT:    [[SUM1:%.*]] = call i32 @add(i32 [[SUM0_RELOAD]], i32 
[[VALUE0_RELOAD6]])
 ; CHECK-NEXT:    [[SUM2:%.*]] = call i32 @add(i32 [[SUM1]], i32 [[TMP1]])
 ; CHECK-NEXT:    [[SUM2_SPILL_ADDR:%.*]] = getelementptr inbounds i8, ptr 
[[TMP2]], i64 16
@@ -72,13 +72,13 @@ declare void @print(i32)
 ; CHECK-LABEL: @f.resume.2(
 ; CHECK-NEXT:  entryresume.2:
 ; CHECK-NEXT:    [[TMP2:%.*]] = load ptr, ptr [[TMP0:%.*]], align 8
-; CHECK-NEXT:    [[SUM2_RELOAD_ADDR:%.*]] = getelementptr inbounds i8, ptr 
[[TMP2]], i64 16
+; CHECK-NEXT:    [[SUM2_RELOAD_ADDR:%.*]] = getelementptr inbounds i8, ptr 
[[TMP2]], i64 4
 ; CHECK-NEXT:    [[SUM2_RELOAD:%.*]] = load i32, ptr [[SUM2_RELOAD_ADDR]], 
align 4
 ; CHECK-NEXT:    [[VALUE1_RELOAD_ADDR:%.*]] = geteleme...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/218309
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to