[llvm-branch-commits] [ModuleUtils] Add updateGlobalCtors/updateGlobalDtors (PR #101757)
Thurston Dang via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Aug 2 16:41:16 PDT 2024
================
@@ -44,6 +45,14 @@ void appendToGlobalCtors(Module &M, Function *F, int Priority,
void appendToGlobalDtors(Module &M, Function *F, int Priority,
Constant *Data = nullptr);
+/// Apply 'Fn' to the list of global ctors of module M and replace contructor
+/// record with the one returned by `Fn`. If `nullptr` was returned, the
+/// corresponding constructor will be removed from the array. For details see
+/// https://llvm.org/docs/LangRef.html#the-llvm-global-ctors-global-variable
+using GlobalCtorUpdateFn = llvm::function_ref<Constant *(Constant *)>;
+void updateGlobalCtors(Module &M, const GlobalCtorUpdateFn &Fn);
----------------
thurstond wrote:
'updateGlobalCtors' is a very generic name - is there a name that could be descriptive? (e.g., it's somewhat similar to 'map' in Haskell/Python or std::transform.)
https://github.com/llvm/llvm-project/pull/101757
More information about the llvm-branch-commits
mailing list