llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-driver

Author: Marco Elver (melver)

<details>
<summary>Changes</summary>

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 `-Xclang` when setting the mode; document
it and update the existing tests.

---

This change is part of the following series:
1. https://github.com/llvm/llvm-project/pull/169242
2. https://github.com/llvm/llvm-project/pull/169243
3. https://github.com/llvm/llvm-project/pull/169358
4. https://github.com/llvm/llvm-project/pull/169359
5. https://github.com/llvm/llvm-project/pull/169360

---
Full diff: https://github.com/llvm/llvm-project/pull/169359.diff


4 Files Affected:

- (modified) clang/docs/AllocToken.rst (+2-2) 
- (modified) clang/include/clang/Options/Options.td (+1-1) 
- (modified) clang/lib/Driver/ToolChains/Clang.cpp (+1) 
- (modified) clang/test/Driver/fsanitize-alloc-token.c (+5-5) 


``````````diff
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'

``````````

</details>


https://github.com/llvm/llvm-project/pull/169359
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to