-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[Clang] Make -falloc-token-mode a hidden frontend option #169359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: users/melver/spr/main.clang-make-falloc-token-mode-a-hidden-frontend-option
Are you sure you want to change the base?
Conversation
Created using spr 1.3.8-beta.1
|
@llvm/pr-subscribers-clang @llvm/pr-subscribers-clang-driver Author: Marco Elver (melver) ChangesIn preparation of moving AllocToken instrumentation to backend LTO This removes the need to use This change is part of the following series:
Full diff: https://github.com/llvm/llvm-project/pull/169359.diff 4 Files Affected:
diff --git a/clang/docs/AllocToken.rst b/clang/docs/AllocToken.rst
index 3f319e8be6421..b591c39057cdc 100644
--- a/clang/docs/AllocToken.rst
+++ b/clang/docs/AllocToken.rst
@@ -37,8 +37,8 @@ The default mode to calculate tokens is:
pointers.
Other token ID assignment modes are supported, but they may be subject to
-change or removal. These may (experimentally) be selected with ``-Xclang
--falloc-token-mode=<mode>``:
+change or removal. These may (experimentally) be selected with
+``-falloc-token-mode=<mode>``:
* ``typehash``: This mode assigns a token ID based on the hash of the allocated
type's name.
diff --git a/clang/include/clang/Options/Options.td b/clang/include/clang/Options/Options.td
index 34a6651d2445c..fb10973a6e581 100644
--- a/clang/include/clang/Options/Options.td
+++ b/clang/include/clang/Options/Options.td
@@ -2767,7 +2767,7 @@ def falloc_token_max_EQ : Joined<["-"], "falloc-token-max=">,
HelpText<"Limit to maximum N allocation tokens (0 = target SIZE_MAX)">;
def falloc_token_mode_EQ : Joined<["-"], "falloc-token-mode=">,
- Group<f_Group>, Visibility<[CC1Option]>,
+ Group<f_Group>, Visibility<[ClangOption, CC1Option]>, Flags<[HelpHidden]>,
HelpText<"Set the allocation token mode (experimental)">;
def fallow_runtime_check_skip_hot_cutoff_EQ
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 2f0aec3ec3c37..b1b41e4c24b81 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -7584,6 +7584,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
SanitizeArgs.addArgs(TC, Args, CmdArgs, InputType);
Args.AddLastArg(CmdArgs, options::OPT_falloc_token_max_EQ);
+ Args.AddLastArg(CmdArgs, options::OPT_falloc_token_mode_EQ);
#if CLANG_ENABLE_CIR
// Forward -mmlir arguments to to the MLIR option parser.
diff --git a/clang/test/Driver/fsanitize-alloc-token.c b/clang/test/Driver/fsanitize-alloc-token.c
index 0ffe9abad8053..073b211d7b671 100644
--- a/clang/test/Driver/fsanitize-alloc-token.c
+++ b/clang/test/Driver/fsanitize-alloc-token.c
@@ -43,13 +43,13 @@
// RUN: not %clang --target=x86_64-linux-gnu -fsanitize=alloc-token -falloc-token-max=-1 %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-MAX %s
// CHECK-INVALID-MAX: error: invalid value
-// RUN: %clang --target=x86_64-linux-gnu -Xclang -falloc-token-mode=increment %s -### 2>&1 | FileCheck -check-prefix=CHECK-MODE-INCREMENT %s
+// RUN: %clang --target=x86_64-linux-gnu -falloc-token-mode=increment %s -### 2>&1 | FileCheck -check-prefix=CHECK-MODE-INCREMENT %s
// CHECK-MODE-INCREMENT: "-falloc-token-mode=increment"
-// RUN: %clang --target=x86_64-linux-gnu -Xclang -falloc-token-mode=random %s -### 2>&1 | FileCheck -check-prefix=CHECK-MODE-RANDOM %s
+// RUN: %clang --target=x86_64-linux-gnu -falloc-token-mode=random %s -### 2>&1 | FileCheck -check-prefix=CHECK-MODE-RANDOM %s
// CHECK-MODE-RANDOM: "-falloc-token-mode=random"
-// RUN: %clang --target=x86_64-linux-gnu -Xclang -falloc-token-mode=typehash %s -### 2>&1 | FileCheck -check-prefix=CHECK-MODE-TYPEHASH %s
+// RUN: %clang --target=x86_64-linux-gnu -falloc-token-mode=typehash %s -### 2>&1 | FileCheck -check-prefix=CHECK-MODE-TYPEHASH %s
// CHECK-MODE-TYPEHASH: "-falloc-token-mode=typehash"
-// RUN: %clang --target=x86_64-linux-gnu -Xclang -falloc-token-mode=typehashpointersplit %s -### 2>&1 | FileCheck -check-prefix=CHECK-MODE-TYPEHASHPTRSPLIT %s
+// RUN: %clang --target=x86_64-linux-gnu -falloc-token-mode=typehashpointersplit %s -### 2>&1 | FileCheck -check-prefix=CHECK-MODE-TYPEHASHPTRSPLIT %s
// CHECK-MODE-TYPEHASHPTRSPLIT: "-falloc-token-mode=typehashpointersplit"
-// RUN: not %clang --target=x86_64-linux-gnu -Xclang -falloc-token-mode=asdf %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-MODE %s
+// RUN: not %clang --target=x86_64-linux-gnu -falloc-token-mode=asdf %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-MODE %s
// CHECK-INVALID-MODE: error: invalid value 'asdf'
|
|
We don't strictly need this anymore, so I'm inclined to drop this PR. Unless we want to make this option more officially supported, which I think is premature as it commits us to never removing some modes, I'd postpone. |
In preparation of moving AllocToken instrumentation to backend LTO
phases, we need to make this option a frontend option that can be
converted to the appropriate linker plugin command line option.
This removes the need to use
-Xclangwhen setting the mode; documentit and update the existing tests.
This change is part of the following series: