[clang] [llvm] [LTO][AllocToken] Support AllocToken instrumentation in backend (PR #169358)

Marco Elver via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 26 07:57:07 PST 2025


================
@@ -198,6 +204,31 @@ static void RegisterPassPlugins(ArrayRef<std::string> PassPlugins,
   }
 }
 
+// Register instrumentation passes that need to run late in the pipeline; these
+// are non-optimization passes and need to run after most optimizations to avoid
+// interfering with them (e.g. PGHO) or to capture the final state of the code.
+static void registerBackendInstrumentation(PassBuilder &PB) {
+  if (!LTOAllocTokenMode.empty()) {
+    AllocTokenOptions Opts;
+    if (auto Mode = getAllocTokenModeFromString(LTOAllocTokenMode))
+      Opts.Mode = *Mode;
+    else
+      report_fatal_error("invalid lto-alloc-token-mode: " +
+                         Twine(LTOAllocTokenMode));
+
+    // ThinLTO backend
+    PB.registerOptimizerLastEPCallback(
----------------
melver wrote:

Thanks, I reworked the patches. PTAL.

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


More information about the llvm-commits mailing list