[llvm] [LLVM][Coroutines] Introduce TBAA metadata for coro frame object (PR #176543)

Chuanqi Xu via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 19 22:41:44 PST 2026


================
@@ -1009,6 +1010,20 @@ static void insertSpills(const FrameDataInfo &FrameData, coro::Shape &Shape) {
   DominatorTree DT(*F);
   SmallDenseMap<Argument *, AllocaInst *, 4> ArgToAllocaMap;
 
+  MDBuilder MDB(C);
+  // Create a TBAA tag for accesses to the coroutine frame slots, so that
+  // subsequent alias analysis will understand they do not intersect with
+  // user memory.
+  // We do this only if a unique TBAA root has been previously found in the
+  // function.
+  MDNode *TBAATag = nullptr;
+  if (Shape.UniqueTBAARoot) {
+    // Create a "fake" scalar type; all other types defined in the source
+    // language will be assumed non-aliasing with this type.
+    MDNode *Scalar = MDB.createTBAAScalarTypeNode("Coroutine Frame Slot",
----------------
ChuanqiXu9 wrote:

Didn't know there are a lot of users using Coroutines. What's the FE language are you using? 

Usually, for such information which needs to be interacted between the FE and ME, we will add an intrinsic for such information instead of searching. e.g., we can introduce a new intrinsic to specify the TBAA root. And we can emit the corresponding intrinsic in the frontend.

https://github.com/llvm/llvm-project/pull/176543


More information about the llvm-commits mailing list