[PATCH] D158638: [CoroSplit][DebugInfo] Don't use entry_value for async args in 32-bit targets

Felipe de Azevedo Piovezan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 24 05:50:34 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rGaefa9ff3ec45: [CoroSplit][DebugInfo] Don't use entry_value for async args in 32-bit targets (authored by fdeazeve).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158638/new/

https://reviews.llvm.org/D158638

Files:
  llvm/lib/Transforms/Coroutines/CoroFrame.cpp
  llvm/lib/Transforms/Coroutines/CoroSplit.cpp
  llvm/test/Transforms/Coroutines/swift-async-dbg.ll


Index: llvm/test/Transforms/Coroutines/swift-async-dbg.ll
===================================================================
--- llvm/test/Transforms/Coroutines/swift-async-dbg.ll
+++ llvm/test/Transforms/Coroutines/swift-async-dbg.ll
@@ -1,6 +1,10 @@
-; RUN: opt %s -S -passes='module(coro-early),cgscc(coro-split,simplifycfg)' -o - | FileCheck %s
+; RUN: opt -mtriple='arm64-' %s -S -passes='module(coro-early),cgscc(coro-split,simplifycfg)' -o - | FileCheck %s
+; RUN: opt -mtriple='x86_64' %s -S -passes='module(coro-early),cgscc(coro-split,simplifycfg)' -o - | FileCheck %s
+; RUN: opt -mtriple='i386-' %s -S -passes='module(coro-early),cgscc(coro-split,simplifycfg)' -o - | FileCheck %s --check-prefix=NOENTRY
+; RUN: opt -mtriple='armv7-' %s -S -passes='module(coro-early),cgscc(coro-split,simplifycfg)' -o - | FileCheck %s --check-prefix=NOENTRY
+; NOENTRY-NOT: OP_llvm_entry_value
+
 target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
-target triple = "arm64-apple-macosx13.0.0"
 
 ; This coroutine has one split point and two variables defined by:
 ;   %var_with_dbg_value,   which has multiple dbg.value intrinsics associated with
Index: llvm/lib/Transforms/Coroutines/CoroSplit.cpp
===================================================================
--- llvm/lib/Transforms/Coroutines/CoroSplit.cpp
+++ llvm/lib/Transforms/Coroutines/CoroSplit.cpp
@@ -701,9 +701,13 @@
   SmallVector<DbgVariableIntrinsic *, 8> Worklist =
       collectDbgVariableIntrinsics(*NewF);
   SmallDenseMap<Argument *, AllocaInst *, 4> ArgToAllocaMap;
+
+  // Only 64-bit ABIs have a register we can refer to with the entry value.
+  bool UseEntryValue =
+      llvm::Triple(OrigF.getParent()->getTargetTriple()).isArch64Bit();
   for (DbgVariableIntrinsic *DVI : Worklist)
     coro::salvageDebugInfo(ArgToAllocaMap, DVI, Shape.OptimizeFrame,
-                           false /*IsEntryPoint*/);
+                           UseEntryValue);
 
   // Remove all salvaged dbg.declare intrinsics that became
   // either unreachable or stale due to the CoroSplit transformation.
@@ -1997,7 +2001,7 @@
   SmallDenseMap<Argument *, AllocaInst *, 4> ArgToAllocaMap;
   for (auto *DDI : collectDbgVariableIntrinsics(F))
     coro::salvageDebugInfo(ArgToAllocaMap, DDI, Shape.OptimizeFrame,
-                           true /*IsEntryPoint*/);
+                           false /*UseEntryValue*/);
 
   return Shape;
 }
Index: llvm/lib/Transforms/Coroutines/CoroFrame.cpp
===================================================================
--- llvm/lib/Transforms/Coroutines/CoroFrame.cpp
+++ llvm/lib/Transforms/Coroutines/CoroFrame.cpp
@@ -1883,7 +1883,7 @@
           // This dbg.declare is for the main function entry point.  It
           // will be deleted in all coro-split functions.
           coro::salvageDebugInfo(ArgToAllocaMap, DDI, Shape.OptimizeFrame,
-                                 true /*IsEntryPoint*/);
+                                 false /*UseEntryValue*/);
         }
       }
 
@@ -2819,7 +2819,7 @@
 
 void coro::salvageDebugInfo(
     SmallDenseMap<Argument *, AllocaInst *, 4> &ArgToAllocaMap,
-    DbgVariableIntrinsic *DVI, bool OptimizeFrame, bool IsEntryPoint) {
+    DbgVariableIntrinsic *DVI, bool OptimizeFrame, bool UseEntryValue) {
   Function *F = DVI->getFunction();
   IRBuilder<> Builder(F->getContext());
   auto InsertPt = F->getEntryBlock().getFirstInsertionPt();
@@ -2874,7 +2874,7 @@
   // For the EntryPoint funclet, don't use EntryValues. This funclet can be
   // inlined, which would remove the guarantee that this intrinsic targets an
   // Argument.
-  if (IsSwiftAsyncArg && !IsEntryPoint && !Expr->isEntryValue())
+  if (IsSwiftAsyncArg && UseEntryValue && !Expr->isEntryValue())
     Expr = DIExpression::prepend(Expr, DIExpression::EntryValue);
 
   // If the coroutine frame is an Argument, store it in an alloca to improve


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158638.553087.patch
Type: text/x-patch
Size: 3870 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230824/54ffb790/attachment.bin>


More information about the llvm-commits mailing list