[clang] [llvm] [Sanitizer] Make sanitizer passes idempotent (PR #99439)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 29 08:56:42 PDT 2024
================
@@ -12,12 +12,33 @@
//===----------------------------------------------------------------------===//
#include "llvm/Transforms/Instrumentation.h"
+#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Module.h"
#include "llvm/TargetParser/Triple.h"
using namespace llvm;
+static cl::opt<bool> ClIgnoreRedundantInstrumentation(
+ "ignore-redundant-instrumentation",
+ cl::desc("Ignore redundant instrumentation"), cl::Hidden, cl::init(false));
+
+/// Check if module has flag attached, if not add the flag.
+bool llvm::checkIfAlreadyInstrumented(Module &M, StringRef flag) {
+ if (M.getModuleFlag(flag)) {
+ if (ClIgnoreRedundantInstrumentation)
+ return true;
+ std::string diagInfo =
+ "Redundant instrumentation detected, with module flag: " +
+ std::string(flag);
+ M.getContext().diagnose(
+ DiagnosticInfoInlineAsm(diagInfo, DiagnosticSeverity::DS_Warning));
----------------
skc7 wrote:
Couldn't find existing DiagInfo classes for reporting IR instrumentation. Have created DiagnosticInfoInstrumentation in latest commit.
https://github.com/llvm/llvm-project/pull/99439
More information about the cfe-commits
mailing list