[llvm] [CodeGen] Expose the extensibility of PassConfig to plugins (PR #139059)

Stefan Gränitz via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 25 07:10:53 PDT 2025


================
@@ -0,0 +1,114 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "Plugin/CodeGenTestPass.h"
+
+#include "llvm/CodeGen/MachineModuleInfo.h"
+#include "llvm/CodeGen/Passes.h"
+#include "llvm/CodeGen/TargetPassConfig.h"
+#include "llvm/Config/config.h"
+#include "llvm/IR/LegacyPassManager.h"
+#include "llvm/MC/TargetRegistry.h"
+#include "llvm/Support/DynamicLibrary.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/TargetSelect.h"
+#include "llvm/Target/TargetMachine.h"
+
+#include "gtest/gtest.h"
+
+using namespace llvm;
+
+namespace {
+void anchor() {}
+
+std::optional<std::string> libPath(const std::string &Name) {
+  const auto &Argvs = testing::internal::GetArgvs();
+  if (Argvs.size() <= 0)
+    return std::nullopt;
+  void *Ptr = (void *)(intptr_t)anchor;
----------------
weliveindetail wrote:

Same here, the other plugin unittests do just the same. Personally I wouldn't worry too much in test code, but you can switch to sth like this https://github.com/llvm/llvm-project/blob/release/20.x/llvm/include/llvm/ExecutionEngine/JITSymbol.h#L50 (I'd prefer a separate NFC for all 4 locations)

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


More information about the llvm-commits mailing list