Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Coroutines] Move util headers to include/llvm #111599

Merged

Conversation

TylerNowicki
Copy link
Collaborator

Plugin libraries that use coroutines can do so right now, however, to provide their own ABI they need to be able to use various headers, some of which such are required (such as the ABI header). This change exposes the coro utils and required headers by moving them to include/llvm/Transforms/Coroutines. My experience with our out-of-tree plugin ABI has been that at least these headers are needed. The headers moved are:

  • ABI.h (ABI object)
  • CoroInstr.h (helpers)
  • Coroshape.h (Shape object)
  • MaterializationUtils.h (helpers)
  • SpillingUtils.h (helpers)
  • SuspendCrossingInfo.h (analysis)

This has no code changes other than those required to move the headers and these are:

  • include guard name changes
  • include path changes
  • minor clang-format induced changes
  • removal of LLVM_LIBRARY_VISIBILITY

Plugin libraries that use coroutines can do so right now, however, to provide their own ABI they need to be able to use various headers, some of which such are required. This change exposes the coro utils and required headers by moving them to include/llvm/Transforms/Coroutines. Headers moved:
* ABI.h (ABI object)
* CoroInstr.h (helpers)
* Coroshape.h (Shape object)
* MaterializationUtils.h (helpers)
* SpillingUtils.h (helpers)
* SuspendCrossingInfo.h (analysis)

The patch has no code changes other than those required to move the headers and these are:
* include guard name changes
* include path changes
* minor clang-format induced changes
* removal of LLVM_LIBRARY_VISIBILITY
@llvmbot
Copy link
Collaborator

llvmbot commented Oct 8, 2024

@llvm/pr-subscribers-coroutines

Author: Tyler Nowicki (TylerNowicki)

Changes

Plugin libraries that use coroutines can do so right now, however, to provide their own ABI they need to be able to use various headers, some of which such are required (such as the ABI header). This change exposes the coro utils and required headers by moving them to include/llvm/Transforms/Coroutines. My experience with our out-of-tree plugin ABI has been that at least these headers are needed. The headers moved are:

  • ABI.h (ABI object)
  • CoroInstr.h (helpers)
  • Coroshape.h (Shape object)
  • MaterializationUtils.h (helpers)
  • SpillingUtils.h (helpers)
  • SuspendCrossingInfo.h (analysis)

This has no code changes other than those required to move the headers and these are:

  • include guard name changes
  • include path changes
  • minor clang-format induced changes
  • removal of LLVM_LIBRARY_VISIBILITY

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

16 Files Affected:

  • (renamed) llvm/include/llvm/Transforms/Coroutines/ABI.h (+9-8)
  • (renamed) llvm/include/llvm/Transforms/Coroutines/CoroInstr.h (+42-46)
  • (renamed) llvm/include/llvm/Transforms/Coroutines/CoroShape.h (+2-2)
  • (modified) llvm/include/llvm/Transforms/Coroutines/CoroSplit.h (+1)
  • (renamed) llvm/include/llvm/Transforms/Coroutines/MaterializationUtils.h (+4-5)
  • (renamed) llvm/include/llvm/Transforms/Coroutines/SpillUtils.h (+3-2)
  • (renamed) llvm/include/llvm/Transforms/Coroutines/SuspendCrossingInfo.h (+3-3)
  • (modified) llvm/lib/Transforms/Coroutines/CoroEarly.cpp (+1-1)
  • (modified) llvm/lib/Transforms/Coroutines/CoroFrame.cpp (+5-4)
  • (modified) llvm/lib/Transforms/Coroutines/CoroInternal.h (+2-2)
  • (modified) llvm/lib/Transforms/Coroutines/CoroSplit.cpp (+3-3)
  • (modified) llvm/lib/Transforms/Coroutines/Coroutines.cpp (+3-3)
  • (modified) llvm/lib/Transforms/Coroutines/MaterializationUtils.cpp (+3-2)
  • (modified) llvm/lib/Transforms/Coroutines/SpillUtils.cpp (+2-1)
  • (modified) llvm/lib/Transforms/Coroutines/SuspendCrossingInfo.cpp (+1-1)
  • (modified) llvm/unittests/Transforms/Coroutines/ExtraRematTest.cpp (+1)
diff --git a/llvm/lib/Transforms/Coroutines/ABI.h b/llvm/include/llvm/Transforms/Coroutines/ABI.h
similarity index 89%
rename from llvm/lib/Transforms/Coroutines/ABI.h
rename to llvm/include/llvm/Transforms/Coroutines/ABI.h
index 7fa835e84ca336..e7568d275c1615 100644
--- a/llvm/lib/Transforms/Coroutines/ABI.h
+++ b/llvm/include/llvm/Transforms/Coroutines/ABI.h
@@ -12,12 +12,13 @@
 // ABI enum and ABI class are used by the Coroutine passes when lowering.
 //===----------------------------------------------------------------------===//
 
-#ifndef LIB_TRANSFORMS_COROUTINES_ABI_H
-#define LIB_TRANSFORMS_COROUTINES_ABI_H
+#ifndef LLVM_TRANSFORMS_COROUTINES_ABI_H
+#define LLVM_TRANSFORMS_COROUTINES_ABI_H
 
-#include "CoroShape.h"
-#include "SuspendCrossingInfo.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
+#include "llvm/Transforms/Coroutines/CoroShape.h"
+#include "llvm/Transforms/Coroutines/MaterializationUtils.h"
+#include "llvm/Transforms/Coroutines/SuspendCrossingInfo.h"
 
 namespace llvm {
 
@@ -30,7 +31,7 @@ namespace coro {
 // ABI operations. The ABIs (e.g. Switch, Async, Retcon{Once}) are the common
 // ABIs.
 
-class LLVM_LIBRARY_VISIBILITY BaseABI {
+class BaseABI {
 public:
   BaseABI(Function &F, coro::Shape &S,
           std::function<bool(Instruction &)> IsMaterializable)
@@ -56,7 +57,7 @@ class LLVM_LIBRARY_VISIBILITY BaseABI {
   std::function<bool(Instruction &I)> IsMaterializable;
 };
 
-class LLVM_LIBRARY_VISIBILITY SwitchABI : public BaseABI {
+class SwitchABI : public BaseABI {
 public:
   SwitchABI(Function &F, coro::Shape &S,
             std::function<bool(Instruction &)> IsMaterializable)
@@ -69,7 +70,7 @@ class LLVM_LIBRARY_VISIBILITY SwitchABI : public BaseABI {
                       TargetTransformInfo &TTI) override;
 };
 
-class LLVM_LIBRARY_VISIBILITY AsyncABI : public BaseABI {
+class AsyncABI : public BaseABI {
 public:
   AsyncABI(Function &F, coro::Shape &S,
            std::function<bool(Instruction &)> IsMaterializable)
@@ -82,7 +83,7 @@ class LLVM_LIBRARY_VISIBILITY AsyncABI : public BaseABI {
                       TargetTransformInfo &TTI) override;
 };
 
-class LLVM_LIBRARY_VISIBILITY AnyRetconABI : public BaseABI {
+class AnyRetconABI : public BaseABI {
 public:
   AnyRetconABI(Function &F, coro::Shape &S,
                std::function<bool(Instruction &)> IsMaterializable)
diff --git a/llvm/lib/Transforms/Coroutines/CoroInstr.h b/llvm/include/llvm/Transforms/Coroutines/CoroInstr.h
similarity index 90%
rename from llvm/lib/Transforms/Coroutines/CoroInstr.h
rename to llvm/include/llvm/Transforms/Coroutines/CoroInstr.h
index a31703fe01304c..a329a06bf13891 100644
--- a/llvm/lib/Transforms/Coroutines/CoroInstr.h
+++ b/llvm/include/llvm/Transforms/Coroutines/CoroInstr.h
@@ -22,8 +22,8 @@
 // the Coroutine library.
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_LIB_TRANSFORMS_COROUTINES_COROINSTR_H
-#define LLVM_LIB_TRANSFORMS_COROUTINES_COROINSTR_H
+#ifndef LLVM_TRANSFORMS_COROUTINES_COROINSTR_H
+#define LLVM_TRANSFORMS_COROUTINES_COROINSTR_H
 
 #include "llvm/IR/GlobalVariable.h"
 #include "llvm/IR/IntrinsicInst.h"
@@ -32,7 +32,7 @@
 namespace llvm {
 
 /// This class represents the llvm.coro.subfn.addr instruction.
-class LLVM_LIBRARY_VISIBILITY CoroSubFnInst : public IntrinsicInst {
+class CoroSubFnInst : public IntrinsicInst {
   enum { FrameArg, IndexArg };
 
 public:
@@ -67,7 +67,7 @@ class LLVM_LIBRARY_VISIBILITY CoroSubFnInst : public IntrinsicInst {
 };
 
 /// This represents the llvm.coro.alloc instruction.
-class LLVM_LIBRARY_VISIBILITY CoroAllocInst : public IntrinsicInst {
+class CoroAllocInst : public IntrinsicInst {
 public:
   // Methods to support type inquiry through isa, cast, and dyn_cast:
   static bool classof(const IntrinsicInst *I) {
@@ -82,7 +82,7 @@ class LLVM_LIBRARY_VISIBILITY CoroAllocInst : public IntrinsicInst {
 // FIXME: add callback metadata
 // FIXME: make a proper IntrinisicInst. Currently this is not possible,
 // because llvm.coro.await.suspend.* can be invoked.
-class LLVM_LIBRARY_VISIBILITY CoroAwaitSuspendInst : public CallBase {
+class CoroAwaitSuspendInst : public CallBase {
   enum { AwaiterArg, FrameArg, WrapperArg };
 
 public:
@@ -112,7 +112,7 @@ class LLVM_LIBRARY_VISIBILITY CoroAwaitSuspendInst : public CallBase {
 };
 
 /// This represents a common base class for llvm.coro.id instructions.
-class LLVM_LIBRARY_VISIBILITY AnyCoroIdInst : public IntrinsicInst {
+class AnyCoroIdInst : public IntrinsicInst {
 public:
   CoroAllocInst *getCoroAlloc() {
     for (User *U : users())
@@ -143,7 +143,7 @@ class LLVM_LIBRARY_VISIBILITY AnyCoroIdInst : public IntrinsicInst {
 };
 
 /// This represents the llvm.coro.id instruction.
-class LLVM_LIBRARY_VISIBILITY CoroIdInst : public AnyCoroIdInst {
+class CoroIdInst : public AnyCoroIdInst {
   enum { AlignArg, PromiseArg, CoroutineArg, InfoArg };
 
 public:
@@ -232,7 +232,7 @@ class LLVM_LIBRARY_VISIBILITY CoroIdInst : public AnyCoroIdInst {
 
 /// This represents either the llvm.coro.id.retcon or
 /// llvm.coro.id.retcon.once instruction.
-class LLVM_LIBRARY_VISIBILITY AnyCoroIdRetconInst : public AnyCoroIdInst {
+class AnyCoroIdRetconInst : public AnyCoroIdInst {
   enum { SizeArg, AlignArg, StorageArg, PrototypeArg, AllocArg, DeallocArg };
 
 public:
@@ -246,9 +246,7 @@ class LLVM_LIBRARY_VISIBILITY AnyCoroIdRetconInst : public AnyCoroIdInst {
     return cast<ConstantInt>(getArgOperand(AlignArg))->getAlignValue();
   }
 
-  Value *getStorage() const {
-    return getArgOperand(StorageArg);
-  }
+  Value *getStorage() const { return getArgOperand(StorageArg); }
 
   /// Return the prototype for the continuation function.  The type,
   /// attributes, and calling convention of the continuation function(s)
@@ -270,8 +268,8 @@ class LLVM_LIBRARY_VISIBILITY AnyCoroIdRetconInst : public AnyCoroIdInst {
   // Methods to support type inquiry through isa, cast, and dyn_cast:
   static bool classof(const IntrinsicInst *I) {
     auto ID = I->getIntrinsicID();
-    return ID == Intrinsic::coro_id_retcon
-        || ID == Intrinsic::coro_id_retcon_once;
+    return ID == Intrinsic::coro_id_retcon ||
+           ID == Intrinsic::coro_id_retcon_once;
   }
   static bool classof(const Value *V) {
     return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
@@ -279,8 +277,7 @@ class LLVM_LIBRARY_VISIBILITY AnyCoroIdRetconInst : public AnyCoroIdInst {
 };
 
 /// This represents the llvm.coro.id.retcon instruction.
-class LLVM_LIBRARY_VISIBILITY CoroIdRetconInst
-    : public AnyCoroIdRetconInst {
+class CoroIdRetconInst : public AnyCoroIdRetconInst {
 public:
   // Methods to support type inquiry through isa, cast, and dyn_cast:
   static bool classof(const IntrinsicInst *I) {
@@ -292,8 +289,7 @@ class LLVM_LIBRARY_VISIBILITY CoroIdRetconInst
 };
 
 /// This represents the llvm.coro.id.retcon.once instruction.
-class LLVM_LIBRARY_VISIBILITY CoroIdRetconOnceInst
-    : public AnyCoroIdRetconInst {
+class CoroIdRetconOnceInst : public AnyCoroIdRetconInst {
 public:
   // Methods to support type inquiry through isa, cast, and dyn_cast:
   static bool classof(const IntrinsicInst *I) {
@@ -305,7 +301,7 @@ class LLVM_LIBRARY_VISIBILITY CoroIdRetconOnceInst
 };
 
 /// This represents the llvm.coro.id.async instruction.
-class LLVM_LIBRARY_VISIBILITY CoroIdAsyncInst : public AnyCoroIdInst {
+class CoroIdAsyncInst : public AnyCoroIdInst {
   enum { SizeArg, AlignArg, StorageArg, AsyncFuncPtrArg };
 
 public:
@@ -356,7 +352,7 @@ class LLVM_LIBRARY_VISIBILITY CoroIdAsyncInst : public AnyCoroIdInst {
 };
 
 /// This represents the llvm.coro.context.alloc instruction.
-class LLVM_LIBRARY_VISIBILITY CoroAsyncContextAllocInst : public IntrinsicInst {
+class CoroAsyncContextAllocInst : public IntrinsicInst {
   enum { AsyncFuncPtrArg };
 
 public:
@@ -375,8 +371,7 @@ class LLVM_LIBRARY_VISIBILITY CoroAsyncContextAllocInst : public IntrinsicInst {
 };
 
 /// This represents the llvm.coro.context.dealloc instruction.
-class LLVM_LIBRARY_VISIBILITY CoroAsyncContextDeallocInst
-    : public IntrinsicInst {
+class CoroAsyncContextDeallocInst : public IntrinsicInst {
   enum { AsyncContextArg };
 
 public:
@@ -396,7 +391,7 @@ class LLVM_LIBRARY_VISIBILITY CoroAsyncContextDeallocInst
 /// This represents the llvm.coro.async.resume instruction.
 /// During lowering this is replaced by the resume function of a suspend point
 /// (the continuation function).
-class LLVM_LIBRARY_VISIBILITY CoroAsyncResumeInst : public IntrinsicInst {
+class CoroAsyncResumeInst : public IntrinsicInst {
 public:
   // Methods to support type inquiry through isa, cast, and dyn_cast:
   static bool classof(const IntrinsicInst *I) {
@@ -408,7 +403,7 @@ class LLVM_LIBRARY_VISIBILITY CoroAsyncResumeInst : public IntrinsicInst {
 };
 
 /// This represents the llvm.coro.async.size.replace instruction.
-class LLVM_LIBRARY_VISIBILITY CoroAsyncSizeReplace : public IntrinsicInst {
+class CoroAsyncSizeReplace : public IntrinsicInst {
 public:
   // Methods to support type inquiry through isa, cast, and dyn_cast:
   static bool classof(const IntrinsicInst *I) {
@@ -420,7 +415,7 @@ class LLVM_LIBRARY_VISIBILITY CoroAsyncSizeReplace : public IntrinsicInst {
 };
 
 /// This represents the llvm.coro.frame instruction.
-class LLVM_LIBRARY_VISIBILITY CoroFrameInst : public IntrinsicInst {
+class CoroFrameInst : public IntrinsicInst {
 public:
   // Methods to support type inquiry through isa, cast, and dyn_cast:
   static bool classof(const IntrinsicInst *I) {
@@ -432,7 +427,7 @@ class LLVM_LIBRARY_VISIBILITY CoroFrameInst : public IntrinsicInst {
 };
 
 /// This represents the llvm.coro.free instruction.
-class LLVM_LIBRARY_VISIBILITY CoroFreeInst : public IntrinsicInst {
+class CoroFreeInst : public IntrinsicInst {
   enum { IdArg, FrameArg };
 
 public:
@@ -447,8 +442,8 @@ class LLVM_LIBRARY_VISIBILITY CoroFreeInst : public IntrinsicInst {
   }
 };
 
-/// This class represents the llvm.coro.begin instruction.
-class LLVM_LIBRARY_VISIBILITY CoroBeginInst : public IntrinsicInst {
+/// This class represents the llvm.coro.begin instructions.
+class CoroBeginInst : public IntrinsicInst {
   enum { IdArg, MemArg };
 
 public:
@@ -468,7 +463,7 @@ class LLVM_LIBRARY_VISIBILITY CoroBeginInst : public IntrinsicInst {
 };
 
 /// This represents the llvm.coro.save instruction.
-class LLVM_LIBRARY_VISIBILITY CoroSaveInst : public IntrinsicInst {
+class CoroSaveInst : public IntrinsicInst {
 public:
   // Methods to support type inquiry through isa, cast, and dyn_cast:
   static bool classof(const IntrinsicInst *I) {
@@ -480,7 +475,7 @@ class LLVM_LIBRARY_VISIBILITY CoroSaveInst : public IntrinsicInst {
 };
 
 /// This represents the llvm.coro.promise instruction.
-class LLVM_LIBRARY_VISIBILITY CoroPromiseInst : public IntrinsicInst {
+class CoroPromiseInst : public IntrinsicInst {
   enum { FrameArg, AlignArg, FromArg };
 
 public:
@@ -505,7 +500,7 @@ class LLVM_LIBRARY_VISIBILITY CoroPromiseInst : public IntrinsicInst {
   }
 };
 
-class LLVM_LIBRARY_VISIBILITY AnyCoroSuspendInst : public IntrinsicInst {
+class AnyCoroSuspendInst : public IntrinsicInst {
 public:
   CoroSaveInst *getCoroSave() const;
 
@@ -521,7 +516,7 @@ class LLVM_LIBRARY_VISIBILITY AnyCoroSuspendInst : public IntrinsicInst {
 };
 
 /// This represents the llvm.coro.suspend instruction.
-class LLVM_LIBRARY_VISIBILITY CoroSuspendInst : public AnyCoroSuspendInst {
+class CoroSuspendInst : public AnyCoroSuspendInst {
   enum { SaveArg, FinalArg };
 
 public:
@@ -553,7 +548,7 @@ inline CoroSaveInst *AnyCoroSuspendInst::getCoroSave() const {
 }
 
 /// This represents the llvm.coro.suspend.async instruction.
-class LLVM_LIBRARY_VISIBILITY CoroSuspendAsyncInst : public AnyCoroSuspendInst {
+class CoroSuspendAsyncInst : public AnyCoroSuspendInst {
 public:
   enum {
     StorageArgNoArg,
@@ -594,7 +589,7 @@ class LLVM_LIBRARY_VISIBILITY CoroSuspendAsyncInst : public AnyCoroSuspendInst {
 };
 
 /// This represents the llvm.coro.suspend.retcon instruction.
-class LLVM_LIBRARY_VISIBILITY CoroSuspendRetconInst : public AnyCoroSuspendInst {
+class CoroSuspendRetconInst : public AnyCoroSuspendInst {
 public:
   op_iterator value_begin() { return arg_begin(); }
   const_op_iterator value_begin() const { return arg_begin(); }
@@ -619,7 +614,7 @@ class LLVM_LIBRARY_VISIBILITY CoroSuspendRetconInst : public AnyCoroSuspendInst
 };
 
 /// This represents the llvm.coro.size instruction.
-class LLVM_LIBRARY_VISIBILITY CoroSizeInst : public IntrinsicInst {
+class CoroSizeInst : public IntrinsicInst {
 public:
   // Methods to support type inquiry through isa, cast, and dyn_cast:
   static bool classof(const IntrinsicInst *I) {
@@ -631,7 +626,7 @@ class LLVM_LIBRARY_VISIBILITY CoroSizeInst : public IntrinsicInst {
 };
 
 /// This represents the llvm.coro.align instruction.
-class LLVM_LIBRARY_VISIBILITY CoroAlignInst : public IntrinsicInst {
+class CoroAlignInst : public IntrinsicInst {
 public:
   // Methods to support type inquiry through isa, cast, and dyn_cast:
   static bool classof(const IntrinsicInst *I) {
@@ -643,7 +638,7 @@ class LLVM_LIBRARY_VISIBILITY CoroAlignInst : public IntrinsicInst {
 };
 
 /// This represents the llvm.end.results instruction.
-class LLVM_LIBRARY_VISIBILITY CoroEndResults : public IntrinsicInst {
+class CoroEndResults : public IntrinsicInst {
 public:
   op_iterator retval_begin() { return arg_begin(); }
   const_op_iterator retval_begin() const { return arg_begin(); }
@@ -671,7 +666,7 @@ class LLVM_LIBRARY_VISIBILITY CoroEndResults : public IntrinsicInst {
   }
 };
 
-class LLVM_LIBRARY_VISIBILITY AnyCoroEndInst : public IntrinsicInst {
+class AnyCoroEndInst : public IntrinsicInst {
   enum { FrameArg, UnwindArg, TokenArg };
 
 public:
@@ -700,7 +695,7 @@ class LLVM_LIBRARY_VISIBILITY AnyCoroEndInst : public IntrinsicInst {
 };
 
 /// This represents the llvm.coro.end instruction.
-class LLVM_LIBRARY_VISIBILITY CoroEndInst : public AnyCoroEndInst {
+class CoroEndInst : public AnyCoroEndInst {
 public:
   // Methods to support type inquiry through isa, cast, and dyn_cast:
   static bool classof(const IntrinsicInst *I) {
@@ -712,7 +707,7 @@ class LLVM_LIBRARY_VISIBILITY CoroEndInst : public AnyCoroEndInst {
 };
 
 /// This represents the llvm.coro.end instruction.
-class LLVM_LIBRARY_VISIBILITY CoroAsyncEndInst : public AnyCoroEndInst {
+class CoroAsyncEndInst : public AnyCoroEndInst {
   enum { FrameArg, UnwindArg, MustTailCallFuncArg };
 
 public:
@@ -736,12 +731,11 @@ class LLVM_LIBRARY_VISIBILITY CoroAsyncEndInst : public AnyCoroEndInst {
 };
 
 /// This represents the llvm.coro.alloca.alloc instruction.
-class LLVM_LIBRARY_VISIBILITY CoroAllocaAllocInst : public IntrinsicInst {
+class CoroAllocaAllocInst : public IntrinsicInst {
   enum { SizeArg, AlignArg };
+
 public:
-  Value *getSize() const {
-    return getArgOperand(SizeArg);
-  }
+  Value *getSize() const { return getArgOperand(SizeArg); }
   Align getAlignment() const {
     return cast<ConstantInt>(getArgOperand(AlignArg))->getAlignValue();
   }
@@ -756,8 +750,9 @@ class LLVM_LIBRARY_VISIBILITY CoroAllocaAllocInst : public IntrinsicInst {
 };
 
 /// This represents the llvm.coro.alloca.get instruction.
-class LLVM_LIBRARY_VISIBILITY CoroAllocaGetInst : public IntrinsicInst {
+class CoroAllocaGetInst : public IntrinsicInst {
   enum { AllocArg };
+
 public:
   CoroAllocaAllocInst *getAlloc() const {
     return cast<CoroAllocaAllocInst>(getArgOperand(AllocArg));
@@ -773,8 +768,9 @@ class LLVM_LIBRARY_VISIBILITY CoroAllocaGetInst : public IntrinsicInst {
 };
 
 /// This represents the llvm.coro.alloca.free instruction.
-class LLVM_LIBRARY_VISIBILITY CoroAllocaFreeInst : public IntrinsicInst {
+class CoroAllocaFreeInst : public IntrinsicInst {
   enum { AllocArg };
+
 public:
   CoroAllocaAllocInst *getAlloc() const {
     return cast<CoroAllocaAllocInst>(getArgOperand(AllocArg));
@@ -791,4 +787,4 @@ class LLVM_LIBRARY_VISIBILITY CoroAllocaFreeInst : public IntrinsicInst {
 
 } // End namespace llvm.
 
-#endif
+#endif // LLVM_TRANSFORMS_COROUTINES_COROINSTR_H
diff --git a/llvm/lib/Transforms/Coroutines/CoroShape.h b/llvm/include/llvm/Transforms/Coroutines/CoroShape.h
similarity index 99%
rename from llvm/lib/Transforms/Coroutines/CoroShape.h
rename to llvm/include/llvm/Transforms/Coroutines/CoroShape.h
index 7daa03beb2542a..ea93ced1ce29e6 100644
--- a/llvm/lib/Transforms/Coroutines/CoroShape.h
+++ b/llvm/include/llvm/Transforms/Coroutines/CoroShape.h
@@ -12,9 +12,9 @@
 #ifndef LLVM_TRANSFORMS_COROUTINES_COROSHAPE_H
 #define LLVM_TRANSFORMS_COROUTINES_COROSHAPE_H
 
-#include "CoroInstr.h"
 #include "llvm/IR/IRBuilder.h"
 #include "llvm/IR/PassManager.h"
+#include "llvm/Transforms/Coroutines/CoroInstr.h"
 
 namespace llvm {
 
@@ -49,7 +49,7 @@ enum class ABI {
 
 // Holds structural Coroutine Intrinsics for a particular function and other
 // values used during CoroSplit pass.
-struct LLVM_LIBRARY_VISIBILITY Shape {
+struct Shape {
   CoroBeginInst *CoroBegin = nullptr;
   SmallVector<AnyCoroEndInst *, 4> CoroEnds;
   SmallVector<CoroSizeInst *, 2> CoroSizes;
diff --git a/llvm/include/llvm/Transforms/Coroutines/CoroSplit.h b/llvm/include/llvm/Transforms/Coroutines/CoroSplit.h
index 52b6c4918ada9b..a5fd57f8f9dfab 100644
--- a/llvm/include/llvm/Transforms/Coroutines/CoroSplit.h
+++ b/llvm/include/llvm/Transforms/Coroutines/CoroSplit.h
@@ -18,6 +18,7 @@
 #include "llvm/Analysis/CGSCCPassManager.h"
 #include "llvm/Analysis/LazyCallGraph.h"
 #include "llvm/IR/PassManager.h"
+#include "llvm/Transforms/Coroutines/ABI.h"
 
 namespace llvm {
 
diff --git a/llvm/lib/Transforms/Coroutines/MaterializationUtils.h b/llvm/include/llvm/Transforms/Coroutines/MaterializationUtils.h
similarity index 76%
rename from llvm/lib/Transforms/Coroutines/MaterializationUtils.h
rename to llvm/include/llvm/Transforms/Coroutines/MaterializationUtils.h
index f391851c97b3b6..d8fc0c86a6fb50 100644
--- a/llvm/lib/Transforms/Coroutines/MaterializationUtils.h
+++ b/llvm/include/llvm/Transforms/Coroutines/MaterializationUtils.h
@@ -6,11 +6,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "SuspendCrossingInfo.h"
-#include "llvm/IR/Instruction.h"
+#include "llvm/Transforms/Coroutines/SuspendCrossingInfo.h"
 
-#ifndef LIB_TRANSFORMS_COROUTINES_MATERIALIZATIONUTILS_H
-#define LIB_TRANSFORMS_COROUTINES_MATERIALIZATIONUTILS_H
+#ifndef LLVM_TRANSFORMS_COROUTINES_MATERIALIZATIONUTILS_H
+#define LLVM_TRANSFORMS_COROUTINES_MATERIALIZATIONUTILS_H
 
 namespace llvm {
 
@@ -27,4 +26,4 @@ void doRematerializations(Function &F, SuspendCrossingInfo &Checker,
 
 } // namespace llvm
 
-#endif // LIB_TRANSFORMS_COROUTINES_MATERIALIZATIONUTILS_H
+#endif // LLVM_TRANSFORMS_COROUTINES_MATERIALIZATIONUTILS_H
diff --git a/llvm/lib/Transforms/Coroutines/SpillUtils.h b/llvm/include/llvm/Transforms/Coroutines/SpillUtils.h
similarity index 93%
rename from llvm/lib/Transforms/Coroutines/SpillUtils.h
rename to llvm/include/llvm/Transforms/Coroutines/SpillUtils.h
index 8843b611e08424..6cdf83c0603f4d 100644
--- a/llvm/lib/Transforms/Coroutines/SpillUtils.h
+++ b/llvm/include/llvm/Transforms/Coroutines/SpillUtils.h
@@ -6,8 +6,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "CoroInternal.h"
-#include "SuspendCrossingInfo.h"
+#include "llvm/IR/Dominators.h"
+#include "llvm/Transforms/Coroutines/CoroShape.h"
+#include "llvm/Transforms/Coroutines/SuspendCrossingInfo.h"
 
 #ifndef LLVM_TRANSFORMS_COROUTINES_SPILLINGINFO_H
 #define LLVM_TRANSFORMS_COROUTINES_SPILLINGINFO_H
diff --git a/llvm/lib/Transforms/Coroutines/SuspendCrossingInfo.h b/llvm/include/llvm/Transforms/Coroutines/SuspendCrossingInfo.h
similarity index 97%
rename from llvm/lib/Transforms/Coroutines/SuspendCrossingInfo.h
rename to llvm/include/llvm/Transforms/Coroutines/SuspendCrossingInfo.h
index db889966dcf1db..49cae6dde47e54 100644
--- a/llvm/lib/Transforms/Coroutines/SuspendCrossingInfo.h
+++ b/llvm/include/llvm/Transforms/Coroutines/SuspendCrossingInfo.h
@@ -12,16 +12,16 @@
 // ptrs in the BlockToIndexMapping.
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_LIB_TRANSFORMS_COROUTINES_SUSPENDCROSSINGINFO_H
-#define LLVM_LIB_TRANSFORMS_COROUTINES_SUSPENDCROSSINGINFO_H
+#ifndef LLVM_TRANSFORMS_COROUTINES_SUSPENDCROSSINGINFO_H
+#define LLVM_TRANSFORMS_COROUTINES_SUSPENDCROSSINGINFO_H
 
-#include "CoroIns...
[truncated]

@llvmbot
Copy link
Collaborator

llvmbot commented Oct 8, 2024

@llvm/pr-subscribers-llvm-transforms

Author: Tyler Nowicki (TylerNowicki)

Changes

Plugin libraries that use coroutines can do so right now, however, to provide their own ABI they need to be able to use various headers, some of which such are required (such as the ABI header). This change exposes the coro utils and required headers by moving them to include/llvm/Transforms/Coroutines. My experience with our out-of-tree plugin ABI has been that at least these headers are needed. The headers moved are:

  • ABI.h (ABI object)
  • CoroInstr.h (helpers)
  • Coroshape.h (Shape object)
  • MaterializationUtils.h (helpers)
  • SpillingUtils.h (helpers)
  • SuspendCrossingInfo.h (analysis)

This has no code changes other than those required to move the headers and these are:

  • include guard name changes
  • include path changes
  • minor clang-format induced changes
  • removal of LLVM_LIBRARY_VISIBILITY

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

16 Files Affected:

  • (renamed) llvm/include/llvm/Transforms/Coroutines/ABI.h (+9-8)
  • (renamed) llvm/include/llvm/Transforms/Coroutines/CoroInstr.h (+42-46)
  • (renamed) llvm/include/llvm/Transforms/Coroutines/CoroShape.h (+2-2)
  • (modified) llvm/include/llvm/Transforms/Coroutines/CoroSplit.h (+1)
  • (renamed) llvm/include/llvm/Transforms/Coroutines/MaterializationUtils.h (+4-5)
  • (renamed) llvm/include/llvm/Transforms/Coroutines/SpillUtils.h (+3-2)
  • (renamed) llvm/include/llvm/Transforms/Coroutines/SuspendCrossingInfo.h (+3-3)
  • (modified) llvm/lib/Transforms/Coroutines/CoroEarly.cpp (+1-1)
  • (modified) llvm/lib/Transforms/Coroutines/CoroFrame.cpp (+5-4)
  • (modified) llvm/lib/Transforms/Coroutines/CoroInternal.h (+2-2)
  • (modified) llvm/lib/Transforms/Coroutines/CoroSplit.cpp (+3-3)
  • (modified) llvm/lib/Transforms/Coroutines/Coroutines.cpp (+3-3)
  • (modified) llvm/lib/Transforms/Coroutines/MaterializationUtils.cpp (+3-2)
  • (modified) llvm/lib/Transforms/Coroutines/SpillUtils.cpp (+2-1)
  • (modified) llvm/lib/Transforms/Coroutines/SuspendCrossingInfo.cpp (+1-1)
  • (modified) llvm/unittests/Transforms/Coroutines/ExtraRematTest.cpp (+1)
diff --git a/llvm/lib/Transforms/Coroutines/ABI.h b/llvm/include/llvm/Transforms/Coroutines/ABI.h
similarity index 89%
rename from llvm/lib/Transforms/Coroutines/ABI.h
rename to llvm/include/llvm/Transforms/Coroutines/ABI.h
index 7fa835e84ca336..e7568d275c1615 100644
--- a/llvm/lib/Transforms/Coroutines/ABI.h
+++ b/llvm/include/llvm/Transforms/Coroutines/ABI.h
@@ -12,12 +12,13 @@
 // ABI enum and ABI class are used by the Coroutine passes when lowering.
 //===----------------------------------------------------------------------===//
 
-#ifndef LIB_TRANSFORMS_COROUTINES_ABI_H
-#define LIB_TRANSFORMS_COROUTINES_ABI_H
+#ifndef LLVM_TRANSFORMS_COROUTINES_ABI_H
+#define LLVM_TRANSFORMS_COROUTINES_ABI_H
 
-#include "CoroShape.h"
-#include "SuspendCrossingInfo.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
+#include "llvm/Transforms/Coroutines/CoroShape.h"
+#include "llvm/Transforms/Coroutines/MaterializationUtils.h"
+#include "llvm/Transforms/Coroutines/SuspendCrossingInfo.h"
 
 namespace llvm {
 
@@ -30,7 +31,7 @@ namespace coro {
 // ABI operations. The ABIs (e.g. Switch, Async, Retcon{Once}) are the common
 // ABIs.
 
-class LLVM_LIBRARY_VISIBILITY BaseABI {
+class BaseABI {
 public:
   BaseABI(Function &F, coro::Shape &S,
           std::function<bool(Instruction &)> IsMaterializable)
@@ -56,7 +57,7 @@ class LLVM_LIBRARY_VISIBILITY BaseABI {
   std::function<bool(Instruction &I)> IsMaterializable;
 };
 
-class LLVM_LIBRARY_VISIBILITY SwitchABI : public BaseABI {
+class SwitchABI : public BaseABI {
 public:
   SwitchABI(Function &F, coro::Shape &S,
             std::function<bool(Instruction &)> IsMaterializable)
@@ -69,7 +70,7 @@ class LLVM_LIBRARY_VISIBILITY SwitchABI : public BaseABI {
                       TargetTransformInfo &TTI) override;
 };
 
-class LLVM_LIBRARY_VISIBILITY AsyncABI : public BaseABI {
+class AsyncABI : public BaseABI {
 public:
   AsyncABI(Function &F, coro::Shape &S,
            std::function<bool(Instruction &)> IsMaterializable)
@@ -82,7 +83,7 @@ class LLVM_LIBRARY_VISIBILITY AsyncABI : public BaseABI {
                       TargetTransformInfo &TTI) override;
 };
 
-class LLVM_LIBRARY_VISIBILITY AnyRetconABI : public BaseABI {
+class AnyRetconABI : public BaseABI {
 public:
   AnyRetconABI(Function &F, coro::Shape &S,
                std::function<bool(Instruction &)> IsMaterializable)
diff --git a/llvm/lib/Transforms/Coroutines/CoroInstr.h b/llvm/include/llvm/Transforms/Coroutines/CoroInstr.h
similarity index 90%
rename from llvm/lib/Transforms/Coroutines/CoroInstr.h
rename to llvm/include/llvm/Transforms/Coroutines/CoroInstr.h
index a31703fe01304c..a329a06bf13891 100644
--- a/llvm/lib/Transforms/Coroutines/CoroInstr.h
+++ b/llvm/include/llvm/Transforms/Coroutines/CoroInstr.h
@@ -22,8 +22,8 @@
 // the Coroutine library.
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_LIB_TRANSFORMS_COROUTINES_COROINSTR_H
-#define LLVM_LIB_TRANSFORMS_COROUTINES_COROINSTR_H
+#ifndef LLVM_TRANSFORMS_COROUTINES_COROINSTR_H
+#define LLVM_TRANSFORMS_COROUTINES_COROINSTR_H
 
 #include "llvm/IR/GlobalVariable.h"
 #include "llvm/IR/IntrinsicInst.h"
@@ -32,7 +32,7 @@
 namespace llvm {
 
 /// This class represents the llvm.coro.subfn.addr instruction.
-class LLVM_LIBRARY_VISIBILITY CoroSubFnInst : public IntrinsicInst {
+class CoroSubFnInst : public IntrinsicInst {
   enum { FrameArg, IndexArg };
 
 public:
@@ -67,7 +67,7 @@ class LLVM_LIBRARY_VISIBILITY CoroSubFnInst : public IntrinsicInst {
 };
 
 /// This represents the llvm.coro.alloc instruction.
-class LLVM_LIBRARY_VISIBILITY CoroAllocInst : public IntrinsicInst {
+class CoroAllocInst : public IntrinsicInst {
 public:
   // Methods to support type inquiry through isa, cast, and dyn_cast:
   static bool classof(const IntrinsicInst *I) {
@@ -82,7 +82,7 @@ class LLVM_LIBRARY_VISIBILITY CoroAllocInst : public IntrinsicInst {
 // FIXME: add callback metadata
 // FIXME: make a proper IntrinisicInst. Currently this is not possible,
 // because llvm.coro.await.suspend.* can be invoked.
-class LLVM_LIBRARY_VISIBILITY CoroAwaitSuspendInst : public CallBase {
+class CoroAwaitSuspendInst : public CallBase {
   enum { AwaiterArg, FrameArg, WrapperArg };
 
 public:
@@ -112,7 +112,7 @@ class LLVM_LIBRARY_VISIBILITY CoroAwaitSuspendInst : public CallBase {
 };
 
 /// This represents a common base class for llvm.coro.id instructions.
-class LLVM_LIBRARY_VISIBILITY AnyCoroIdInst : public IntrinsicInst {
+class AnyCoroIdInst : public IntrinsicInst {
 public:
   CoroAllocInst *getCoroAlloc() {
     for (User *U : users())
@@ -143,7 +143,7 @@ class LLVM_LIBRARY_VISIBILITY AnyCoroIdInst : public IntrinsicInst {
 };
 
 /// This represents the llvm.coro.id instruction.
-class LLVM_LIBRARY_VISIBILITY CoroIdInst : public AnyCoroIdInst {
+class CoroIdInst : public AnyCoroIdInst {
   enum { AlignArg, PromiseArg, CoroutineArg, InfoArg };
 
 public:
@@ -232,7 +232,7 @@ class LLVM_LIBRARY_VISIBILITY CoroIdInst : public AnyCoroIdInst {
 
 /// This represents either the llvm.coro.id.retcon or
 /// llvm.coro.id.retcon.once instruction.
-class LLVM_LIBRARY_VISIBILITY AnyCoroIdRetconInst : public AnyCoroIdInst {
+class AnyCoroIdRetconInst : public AnyCoroIdInst {
   enum { SizeArg, AlignArg, StorageArg, PrototypeArg, AllocArg, DeallocArg };
 
 public:
@@ -246,9 +246,7 @@ class LLVM_LIBRARY_VISIBILITY AnyCoroIdRetconInst : public AnyCoroIdInst {
     return cast<ConstantInt>(getArgOperand(AlignArg))->getAlignValue();
   }
 
-  Value *getStorage() const {
-    return getArgOperand(StorageArg);
-  }
+  Value *getStorage() const { return getArgOperand(StorageArg); }
 
   /// Return the prototype for the continuation function.  The type,
   /// attributes, and calling convention of the continuation function(s)
@@ -270,8 +268,8 @@ class LLVM_LIBRARY_VISIBILITY AnyCoroIdRetconInst : public AnyCoroIdInst {
   // Methods to support type inquiry through isa, cast, and dyn_cast:
   static bool classof(const IntrinsicInst *I) {
     auto ID = I->getIntrinsicID();
-    return ID == Intrinsic::coro_id_retcon
-        || ID == Intrinsic::coro_id_retcon_once;
+    return ID == Intrinsic::coro_id_retcon ||
+           ID == Intrinsic::coro_id_retcon_once;
   }
   static bool classof(const Value *V) {
     return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
@@ -279,8 +277,7 @@ class LLVM_LIBRARY_VISIBILITY AnyCoroIdRetconInst : public AnyCoroIdInst {
 };
 
 /// This represents the llvm.coro.id.retcon instruction.
-class LLVM_LIBRARY_VISIBILITY CoroIdRetconInst
-    : public AnyCoroIdRetconInst {
+class CoroIdRetconInst : public AnyCoroIdRetconInst {
 public:
   // Methods to support type inquiry through isa, cast, and dyn_cast:
   static bool classof(const IntrinsicInst *I) {
@@ -292,8 +289,7 @@ class LLVM_LIBRARY_VISIBILITY CoroIdRetconInst
 };
 
 /// This represents the llvm.coro.id.retcon.once instruction.
-class LLVM_LIBRARY_VISIBILITY CoroIdRetconOnceInst
-    : public AnyCoroIdRetconInst {
+class CoroIdRetconOnceInst : public AnyCoroIdRetconInst {
 public:
   // Methods to support type inquiry through isa, cast, and dyn_cast:
   static bool classof(const IntrinsicInst *I) {
@@ -305,7 +301,7 @@ class LLVM_LIBRARY_VISIBILITY CoroIdRetconOnceInst
 };
 
 /// This represents the llvm.coro.id.async instruction.
-class LLVM_LIBRARY_VISIBILITY CoroIdAsyncInst : public AnyCoroIdInst {
+class CoroIdAsyncInst : public AnyCoroIdInst {
   enum { SizeArg, AlignArg, StorageArg, AsyncFuncPtrArg };
 
 public:
@@ -356,7 +352,7 @@ class LLVM_LIBRARY_VISIBILITY CoroIdAsyncInst : public AnyCoroIdInst {
 };
 
 /// This represents the llvm.coro.context.alloc instruction.
-class LLVM_LIBRARY_VISIBILITY CoroAsyncContextAllocInst : public IntrinsicInst {
+class CoroAsyncContextAllocInst : public IntrinsicInst {
   enum { AsyncFuncPtrArg };
 
 public:
@@ -375,8 +371,7 @@ class LLVM_LIBRARY_VISIBILITY CoroAsyncContextAllocInst : public IntrinsicInst {
 };
 
 /// This represents the llvm.coro.context.dealloc instruction.
-class LLVM_LIBRARY_VISIBILITY CoroAsyncContextDeallocInst
-    : public IntrinsicInst {
+class CoroAsyncContextDeallocInst : public IntrinsicInst {
   enum { AsyncContextArg };
 
 public:
@@ -396,7 +391,7 @@ class LLVM_LIBRARY_VISIBILITY CoroAsyncContextDeallocInst
 /// This represents the llvm.coro.async.resume instruction.
 /// During lowering this is replaced by the resume function of a suspend point
 /// (the continuation function).
-class LLVM_LIBRARY_VISIBILITY CoroAsyncResumeInst : public IntrinsicInst {
+class CoroAsyncResumeInst : public IntrinsicInst {
 public:
   // Methods to support type inquiry through isa, cast, and dyn_cast:
   static bool classof(const IntrinsicInst *I) {
@@ -408,7 +403,7 @@ class LLVM_LIBRARY_VISIBILITY CoroAsyncResumeInst : public IntrinsicInst {
 };
 
 /// This represents the llvm.coro.async.size.replace instruction.
-class LLVM_LIBRARY_VISIBILITY CoroAsyncSizeReplace : public IntrinsicInst {
+class CoroAsyncSizeReplace : public IntrinsicInst {
 public:
   // Methods to support type inquiry through isa, cast, and dyn_cast:
   static bool classof(const IntrinsicInst *I) {
@@ -420,7 +415,7 @@ class LLVM_LIBRARY_VISIBILITY CoroAsyncSizeReplace : public IntrinsicInst {
 };
 
 /// This represents the llvm.coro.frame instruction.
-class LLVM_LIBRARY_VISIBILITY CoroFrameInst : public IntrinsicInst {
+class CoroFrameInst : public IntrinsicInst {
 public:
   // Methods to support type inquiry through isa, cast, and dyn_cast:
   static bool classof(const IntrinsicInst *I) {
@@ -432,7 +427,7 @@ class LLVM_LIBRARY_VISIBILITY CoroFrameInst : public IntrinsicInst {
 };
 
 /// This represents the llvm.coro.free instruction.
-class LLVM_LIBRARY_VISIBILITY CoroFreeInst : public IntrinsicInst {
+class CoroFreeInst : public IntrinsicInst {
   enum { IdArg, FrameArg };
 
 public:
@@ -447,8 +442,8 @@ class LLVM_LIBRARY_VISIBILITY CoroFreeInst : public IntrinsicInst {
   }
 };
 
-/// This class represents the llvm.coro.begin instruction.
-class LLVM_LIBRARY_VISIBILITY CoroBeginInst : public IntrinsicInst {
+/// This class represents the llvm.coro.begin instructions.
+class CoroBeginInst : public IntrinsicInst {
   enum { IdArg, MemArg };
 
 public:
@@ -468,7 +463,7 @@ class LLVM_LIBRARY_VISIBILITY CoroBeginInst : public IntrinsicInst {
 };
 
 /// This represents the llvm.coro.save instruction.
-class LLVM_LIBRARY_VISIBILITY CoroSaveInst : public IntrinsicInst {
+class CoroSaveInst : public IntrinsicInst {
 public:
   // Methods to support type inquiry through isa, cast, and dyn_cast:
   static bool classof(const IntrinsicInst *I) {
@@ -480,7 +475,7 @@ class LLVM_LIBRARY_VISIBILITY CoroSaveInst : public IntrinsicInst {
 };
 
 /// This represents the llvm.coro.promise instruction.
-class LLVM_LIBRARY_VISIBILITY CoroPromiseInst : public IntrinsicInst {
+class CoroPromiseInst : public IntrinsicInst {
   enum { FrameArg, AlignArg, FromArg };
 
 public:
@@ -505,7 +500,7 @@ class LLVM_LIBRARY_VISIBILITY CoroPromiseInst : public IntrinsicInst {
   }
 };
 
-class LLVM_LIBRARY_VISIBILITY AnyCoroSuspendInst : public IntrinsicInst {
+class AnyCoroSuspendInst : public IntrinsicInst {
 public:
   CoroSaveInst *getCoroSave() const;
 
@@ -521,7 +516,7 @@ class LLVM_LIBRARY_VISIBILITY AnyCoroSuspendInst : public IntrinsicInst {
 };
 
 /// This represents the llvm.coro.suspend instruction.
-class LLVM_LIBRARY_VISIBILITY CoroSuspendInst : public AnyCoroSuspendInst {
+class CoroSuspendInst : public AnyCoroSuspendInst {
   enum { SaveArg, FinalArg };
 
 public:
@@ -553,7 +548,7 @@ inline CoroSaveInst *AnyCoroSuspendInst::getCoroSave() const {
 }
 
 /// This represents the llvm.coro.suspend.async instruction.
-class LLVM_LIBRARY_VISIBILITY CoroSuspendAsyncInst : public AnyCoroSuspendInst {
+class CoroSuspendAsyncInst : public AnyCoroSuspendInst {
 public:
   enum {
     StorageArgNoArg,
@@ -594,7 +589,7 @@ class LLVM_LIBRARY_VISIBILITY CoroSuspendAsyncInst : public AnyCoroSuspendInst {
 };
 
 /// This represents the llvm.coro.suspend.retcon instruction.
-class LLVM_LIBRARY_VISIBILITY CoroSuspendRetconInst : public AnyCoroSuspendInst {
+class CoroSuspendRetconInst : public AnyCoroSuspendInst {
 public:
   op_iterator value_begin() { return arg_begin(); }
   const_op_iterator value_begin() const { return arg_begin(); }
@@ -619,7 +614,7 @@ class LLVM_LIBRARY_VISIBILITY CoroSuspendRetconInst : public AnyCoroSuspendInst
 };
 
 /// This represents the llvm.coro.size instruction.
-class LLVM_LIBRARY_VISIBILITY CoroSizeInst : public IntrinsicInst {
+class CoroSizeInst : public IntrinsicInst {
 public:
   // Methods to support type inquiry through isa, cast, and dyn_cast:
   static bool classof(const IntrinsicInst *I) {
@@ -631,7 +626,7 @@ class LLVM_LIBRARY_VISIBILITY CoroSizeInst : public IntrinsicInst {
 };
 
 /// This represents the llvm.coro.align instruction.
-class LLVM_LIBRARY_VISIBILITY CoroAlignInst : public IntrinsicInst {
+class CoroAlignInst : public IntrinsicInst {
 public:
   // Methods to support type inquiry through isa, cast, and dyn_cast:
   static bool classof(const IntrinsicInst *I) {
@@ -643,7 +638,7 @@ class LLVM_LIBRARY_VISIBILITY CoroAlignInst : public IntrinsicInst {
 };
 
 /// This represents the llvm.end.results instruction.
-class LLVM_LIBRARY_VISIBILITY CoroEndResults : public IntrinsicInst {
+class CoroEndResults : public IntrinsicInst {
 public:
   op_iterator retval_begin() { return arg_begin(); }
   const_op_iterator retval_begin() const { return arg_begin(); }
@@ -671,7 +666,7 @@ class LLVM_LIBRARY_VISIBILITY CoroEndResults : public IntrinsicInst {
   }
 };
 
-class LLVM_LIBRARY_VISIBILITY AnyCoroEndInst : public IntrinsicInst {
+class AnyCoroEndInst : public IntrinsicInst {
   enum { FrameArg, UnwindArg, TokenArg };
 
 public:
@@ -700,7 +695,7 @@ class LLVM_LIBRARY_VISIBILITY AnyCoroEndInst : public IntrinsicInst {
 };
 
 /// This represents the llvm.coro.end instruction.
-class LLVM_LIBRARY_VISIBILITY CoroEndInst : public AnyCoroEndInst {
+class CoroEndInst : public AnyCoroEndInst {
 public:
   // Methods to support type inquiry through isa, cast, and dyn_cast:
   static bool classof(const IntrinsicInst *I) {
@@ -712,7 +707,7 @@ class LLVM_LIBRARY_VISIBILITY CoroEndInst : public AnyCoroEndInst {
 };
 
 /// This represents the llvm.coro.end instruction.
-class LLVM_LIBRARY_VISIBILITY CoroAsyncEndInst : public AnyCoroEndInst {
+class CoroAsyncEndInst : public AnyCoroEndInst {
   enum { FrameArg, UnwindArg, MustTailCallFuncArg };
 
 public:
@@ -736,12 +731,11 @@ class LLVM_LIBRARY_VISIBILITY CoroAsyncEndInst : public AnyCoroEndInst {
 };
 
 /// This represents the llvm.coro.alloca.alloc instruction.
-class LLVM_LIBRARY_VISIBILITY CoroAllocaAllocInst : public IntrinsicInst {
+class CoroAllocaAllocInst : public IntrinsicInst {
   enum { SizeArg, AlignArg };
+
 public:
-  Value *getSize() const {
-    return getArgOperand(SizeArg);
-  }
+  Value *getSize() const { return getArgOperand(SizeArg); }
   Align getAlignment() const {
     return cast<ConstantInt>(getArgOperand(AlignArg))->getAlignValue();
   }
@@ -756,8 +750,9 @@ class LLVM_LIBRARY_VISIBILITY CoroAllocaAllocInst : public IntrinsicInst {
 };
 
 /// This represents the llvm.coro.alloca.get instruction.
-class LLVM_LIBRARY_VISIBILITY CoroAllocaGetInst : public IntrinsicInst {
+class CoroAllocaGetInst : public IntrinsicInst {
   enum { AllocArg };
+
 public:
   CoroAllocaAllocInst *getAlloc() const {
     return cast<CoroAllocaAllocInst>(getArgOperand(AllocArg));
@@ -773,8 +768,9 @@ class LLVM_LIBRARY_VISIBILITY CoroAllocaGetInst : public IntrinsicInst {
 };
 
 /// This represents the llvm.coro.alloca.free instruction.
-class LLVM_LIBRARY_VISIBILITY CoroAllocaFreeInst : public IntrinsicInst {
+class CoroAllocaFreeInst : public IntrinsicInst {
   enum { AllocArg };
+
 public:
   CoroAllocaAllocInst *getAlloc() const {
     return cast<CoroAllocaAllocInst>(getArgOperand(AllocArg));
@@ -791,4 +787,4 @@ class LLVM_LIBRARY_VISIBILITY CoroAllocaFreeInst : public IntrinsicInst {
 
 } // End namespace llvm.
 
-#endif
+#endif // LLVM_TRANSFORMS_COROUTINES_COROINSTR_H
diff --git a/llvm/lib/Transforms/Coroutines/CoroShape.h b/llvm/include/llvm/Transforms/Coroutines/CoroShape.h
similarity index 99%
rename from llvm/lib/Transforms/Coroutines/CoroShape.h
rename to llvm/include/llvm/Transforms/Coroutines/CoroShape.h
index 7daa03beb2542a..ea93ced1ce29e6 100644
--- a/llvm/lib/Transforms/Coroutines/CoroShape.h
+++ b/llvm/include/llvm/Transforms/Coroutines/CoroShape.h
@@ -12,9 +12,9 @@
 #ifndef LLVM_TRANSFORMS_COROUTINES_COROSHAPE_H
 #define LLVM_TRANSFORMS_COROUTINES_COROSHAPE_H
 
-#include "CoroInstr.h"
 #include "llvm/IR/IRBuilder.h"
 #include "llvm/IR/PassManager.h"
+#include "llvm/Transforms/Coroutines/CoroInstr.h"
 
 namespace llvm {
 
@@ -49,7 +49,7 @@ enum class ABI {
 
 // Holds structural Coroutine Intrinsics for a particular function and other
 // values used during CoroSplit pass.
-struct LLVM_LIBRARY_VISIBILITY Shape {
+struct Shape {
   CoroBeginInst *CoroBegin = nullptr;
   SmallVector<AnyCoroEndInst *, 4> CoroEnds;
   SmallVector<CoroSizeInst *, 2> CoroSizes;
diff --git a/llvm/include/llvm/Transforms/Coroutines/CoroSplit.h b/llvm/include/llvm/Transforms/Coroutines/CoroSplit.h
index 52b6c4918ada9b..a5fd57f8f9dfab 100644
--- a/llvm/include/llvm/Transforms/Coroutines/CoroSplit.h
+++ b/llvm/include/llvm/Transforms/Coroutines/CoroSplit.h
@@ -18,6 +18,7 @@
 #include "llvm/Analysis/CGSCCPassManager.h"
 #include "llvm/Analysis/LazyCallGraph.h"
 #include "llvm/IR/PassManager.h"
+#include "llvm/Transforms/Coroutines/ABI.h"
 
 namespace llvm {
 
diff --git a/llvm/lib/Transforms/Coroutines/MaterializationUtils.h b/llvm/include/llvm/Transforms/Coroutines/MaterializationUtils.h
similarity index 76%
rename from llvm/lib/Transforms/Coroutines/MaterializationUtils.h
rename to llvm/include/llvm/Transforms/Coroutines/MaterializationUtils.h
index f391851c97b3b6..d8fc0c86a6fb50 100644
--- a/llvm/lib/Transforms/Coroutines/MaterializationUtils.h
+++ b/llvm/include/llvm/Transforms/Coroutines/MaterializationUtils.h
@@ -6,11 +6,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "SuspendCrossingInfo.h"
-#include "llvm/IR/Instruction.h"
+#include "llvm/Transforms/Coroutines/SuspendCrossingInfo.h"
 
-#ifndef LIB_TRANSFORMS_COROUTINES_MATERIALIZATIONUTILS_H
-#define LIB_TRANSFORMS_COROUTINES_MATERIALIZATIONUTILS_H
+#ifndef LLVM_TRANSFORMS_COROUTINES_MATERIALIZATIONUTILS_H
+#define LLVM_TRANSFORMS_COROUTINES_MATERIALIZATIONUTILS_H
 
 namespace llvm {
 
@@ -27,4 +26,4 @@ void doRematerializations(Function &F, SuspendCrossingInfo &Checker,
 
 } // namespace llvm
 
-#endif // LIB_TRANSFORMS_COROUTINES_MATERIALIZATIONUTILS_H
+#endif // LLVM_TRANSFORMS_COROUTINES_MATERIALIZATIONUTILS_H
diff --git a/llvm/lib/Transforms/Coroutines/SpillUtils.h b/llvm/include/llvm/Transforms/Coroutines/SpillUtils.h
similarity index 93%
rename from llvm/lib/Transforms/Coroutines/SpillUtils.h
rename to llvm/include/llvm/Transforms/Coroutines/SpillUtils.h
index 8843b611e08424..6cdf83c0603f4d 100644
--- a/llvm/lib/Transforms/Coroutines/SpillUtils.h
+++ b/llvm/include/llvm/Transforms/Coroutines/SpillUtils.h
@@ -6,8 +6,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "CoroInternal.h"
-#include "SuspendCrossingInfo.h"
+#include "llvm/IR/Dominators.h"
+#include "llvm/Transforms/Coroutines/CoroShape.h"
+#include "llvm/Transforms/Coroutines/SuspendCrossingInfo.h"
 
 #ifndef LLVM_TRANSFORMS_COROUTINES_SPILLINGINFO_H
 #define LLVM_TRANSFORMS_COROUTINES_SPILLINGINFO_H
diff --git a/llvm/lib/Transforms/Coroutines/SuspendCrossingInfo.h b/llvm/include/llvm/Transforms/Coroutines/SuspendCrossingInfo.h
similarity index 97%
rename from llvm/lib/Transforms/Coroutines/SuspendCrossingInfo.h
rename to llvm/include/llvm/Transforms/Coroutines/SuspendCrossingInfo.h
index db889966dcf1db..49cae6dde47e54 100644
--- a/llvm/lib/Transforms/Coroutines/SuspendCrossingInfo.h
+++ b/llvm/include/llvm/Transforms/Coroutines/SuspendCrossingInfo.h
@@ -12,16 +12,16 @@
 // ptrs in the BlockToIndexMapping.
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_LIB_TRANSFORMS_COROUTINES_SUSPENDCROSSINGINFO_H
-#define LLVM_LIB_TRANSFORMS_COROUTINES_SUSPENDCROSSINGINFO_H
+#ifndef LLVM_TRANSFORMS_COROUTINES_SUSPENDCROSSINGINFO_H
+#define LLVM_TRANSFORMS_COROUTINES_SUSPENDCROSSINGINFO_H
 
-#include "CoroIns...
[truncated]

@TylerNowicki TylerNowicki merged commit e82fcda into llvm:main Oct 9, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants