[llvm] [llvm/llvm-project][Coroutines] ABI Object (PR #106306)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 3 22:18:39 PDT 2024


================
@@ -0,0 +1,182 @@
+//===- SuspendCrossingInfo.cpp - Utility for suspend crossing values ------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+// The SuspendCrossingInfo maintains data that allows to answer a question
+// whether given two BasicBlocks A and B there is a path from A to B that
+// passes through a suspend point.
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIB_TRANSFORMS_COROUTINES_SUSPENDCROSSINGINFO_H
+#define LLVM_LIB_TRANSFORMS_COROUTINES_SUSPENDCROSSINGINFO_H
+
+#include "CoroInstr.h"
+#include "llvm/ADT/BitVector.h"
+#include "llvm/ADT/PostOrderIterator.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/IR/BasicBlock.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/Instruction.h"
+
+namespace llvm {
+
+// Provides two way mapping between the blocks and numbers.
+class BlockToIndexMapping {
+  SmallVector<BasicBlock *, 32> V;
+
+public:
+  size_t size() const { return V.size(); }
+
+  BlockToIndexMapping(Function &F) {
+    for (BasicBlock &BB : F)
+      V.push_back(&BB);
+    llvm::sort(V);
----------------
arsenm wrote:

You can, but it requires chasing the block list. Is this used in a way that introduces runtime pointer value dependence? 

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


More information about the llvm-commits mailing list