[llvm] [Instrumentation] Declare command line options in TableGen (PR #230746)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 10 09:37:05 PDT 2026
================
@@ -0,0 +1,780 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 "llvm/Option/LibraryOptions.td"
+
+def InstrumentationOptions : OptionsStruct;
+
+// AddressSanitizer.cpp
+defm : BoolField<"asan-always-slow-path", "false",
+ "Use instrumentation with slow path for all accesses">;
+defm : EnumField<"asan-constructor-kind", "std::optional<AsanCtorKind>", "std::nullopt",
+ "none,global",
+ ["AsanCtorKind::None", "AsanCtorKind::Global"],
+ "Sets the ASan constructor kind">;
+defm : ValueField<"asan-debug-func", "StringRef", "",
+ "Do not instrument the function with this name">;
+defm : ValueField<"asan-debug-max", "int", "-1",
+ "With -asan-debug-min, instrument only the memory accesses whose index within the function is in [min, max]">;
+defm : ValueField<"asan-debug-min", "int", "-1",
+ "With -asan-debug-max, instrument only the memory accesses whose index within the function is in [min, max]">;
+defm : BoolField<"asan-debug-stack", "false",
+ "Print each function after stack instrumentation (with -debug-only=asan)">;
+defm : EnumField<"asan-destructor-kind", "std::optional<AsanDtorKind>", "std::nullopt",
+ "none,global",
+ ["AsanDtorKind::None", "AsanDtorKind::Global"],
+ "Sets the ASan destructor kind. The default is to use the value provided to the pass constructor">;
+defm : BoolField<"asan-detect-invalid-pointer-cmp", "false",
+ "Instrument <, <=, >, >= with pointer operands">;
+defm : BoolField<"asan-detect-invalid-pointer-pair", "false",
+ "Instrument <, <=, >, >=, - with pointer operands">;
+defm : BoolField<"asan-detect-invalid-pointer-sub", "false",
+ "Instrument - operations with pointer operands">;
+defm : BoolField<"asan-force-dynamic-shadow", "false",
+ "Load shadow address into a local variable for each function">;
+defm : ValueField<"asan-force-experiment", "uint32_t", "0",
+ "Force optimization experiment (for testing)">;
+// This flag may need to be replaced with -f[no]asan-globals.
+defm : BoolField<"asan-globals", "true",
+ "Handle global objects">;
+defm : BoolField<"asan-globals-live-support", "true",
+ "Use linker features to support dead code stripping of globals">;
+defm : OptionalBoolField<"asan-guard-against-version-mismatch",
+ "Guard against compiler/runtime version mismatch">;
+defm : BoolField<"asan-initialization-order", "true",
+ "Handle C++ initializer order">;
+defm : BoolField<"asan-instrument-atomics", "true",
+ "Instrument atomic instructions (rmw, cmpxchg)">;
+defm : BoolField<"asan-instrument-byval", "true",
+ "Instrument byval call arguments">;
+defm : BoolField<"asan-instrument-dynamic-allocas", "true",
+ "Instrument dynamic allocas">;
+// This flag may need to be replaced with -f[no-]asan-reads.
+defm : BoolField<"asan-instrument-reads", "true",
+ "Instrument read instructions">;
+defm : BoolField<"asan-instrument-writes", "true",
+ "Instrument write instructions">;
+defm : ValueField<"asan-instrumentation-with-call-threshold", "std::optional<int>", "std::nullopt",
+ "If the function being instrumented contains more than this number of memory accesses, use callbacks instead of inline checks (-1 means never use callbacks)">;
+defm : OptionalBoolField<"asan-kernel",
+ "Enable KernelAddressSanitizer instrumentation">;
+defm : BoolField<"asan-kernel-mem-intrinsic-prefix", "false",
+ "Use prefix for memory intrinsics in KASAN mode">;
+// The shadow mapping looks like
+// Shadow = (Mem >> scale) + offset
+defm : ValueField<"asan-mapping-offset", "std::optional<uint64_t>", "std::nullopt",
+ "Offset of asan shadow mapping [EXPERIMENTAL]">;
+defm : ValueField<"asan-mapping-scale", "std::optional<int>", "std::nullopt",
----------------
MaskRay wrote:
We can introduce OptionalValueField and OptionalEnumField to omit `std::optional` and `std::nullopt`
https://github.com/llvm/llvm-project/pull/230746
More information about the llvm-commits
mailing list