[clang] [llvm] [Instrumentor] A configurable instrumentation pass plugin (PR #151551)
Stefan Gränitz via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 6 03:36:50 PDT 2025
================
@@ -0,0 +1,86 @@
+//===- tools/plugins-shlib/ReferencePlugin.cpp ----------------------------===//
+//
+// 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 "Instrumentor.h"
+
+#include "llvm/Passes/PassBuilder.h"
+#include "llvm/Passes/PassPlugin.h"
+
+#include <algorithm>
+#include <cstdlib>
+#include <optional>
+#include <string>
+
+using namespace llvm;
+
+static std::optional<std::string> getEnv(const std::string &Var) {
+ const char *Val = std::getenv(Var.c_str());
+ if (!Val)
+ return std::nullopt;
+ return std::string(Val);
+}
----------------
weliveindetail wrote:
For the moment, I was aiming for minimal changes on the Instrumentor, so I kept it as a leftover from my [previous draft](https://github.com/weliveindetail/llvm-project/commit/pass-plugins-dev) that used a generic plugin. They define in which part(s) of the pass pipeline we insert the pass. In contrast to the current command-line options this is not specific for the Instrumentor. I am happy to change it to whatever fits best.
https://github.com/llvm/llvm-project/pull/151551
More information about the llvm-commits
mailing list