[clang] 63bd6d9 - [Driver] Default to -fxray-function-index

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Sun Jun 11 15:38:18 PDT 2023


Author: Fangrui Song
Date: 2023-06-11T15:38:13-07:00
New Revision: 63bd6d9e644335c8138a59281aafbf65a82fc47a

URL: https://github.com/llvm/llvm-project/commit/63bd6d9e644335c8138a59281aafbf65a82fc47a
DIFF: https://github.com/llvm/llvm-project/commit/63bd6d9e644335c8138a59281aafbf65a82fc47a.diff

LOG: [Driver] Default to -fxray-function-index

As explained by commit 849f1dd15e92fda2b83dbb6144e6b28b2cb946e0,
-fxray-function-index was the original default but was accidentally flipped by
commit d8a8e5d6240a1db809cd95106910358e69bbf299. Restore the previous behavior.

Originally reported by Oleksii Lozovskyi in D145848.

Added: 
    

Modified: 
    clang/include/clang/Driver/Options.td
    clang/lib/Driver/XRayArgs.cpp
    clang/test/CodeGen/xray-function-index.c
    clang/test/Driver/xray-function-index.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index abb3254188aff..36baebed78099 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2216,9 +2216,9 @@ defm xray_ignore_loops : BoolFOption<"xray-ignore-loops",
   NegFlag<SetFalse>>;
 
 defm xray_function_index : BoolFOption<"xray-function-index",
-  CodeGenOpts<"XRayFunctionIndex">, DefaultFalse,
-  PosFlag<SetTrue, [CC1Option]>,
-  NegFlag<SetFalse, [], "Omit function index section at the"
+  CodeGenOpts<"XRayFunctionIndex">, DefaultTrue,
+  PosFlag<SetTrue, []>,
+  NegFlag<SetFalse, [CC1Option], "Omit function index section at the"
           " expense of single-function patching performance">>;
 
 def fxray_link_deps : Flag<["-"], "fxray-link-deps">, Group<f_Group>,

diff  --git a/clang/lib/Driver/XRayArgs.cpp b/clang/lib/Driver/XRayArgs.cpp
index 89aeb20aa68cd..f15a91f1aba44 100644
--- a/clang/lib/Driver/XRayArgs.cpp
+++ b/clang/lib/Driver/XRayArgs.cpp
@@ -178,8 +178,8 @@ void XRayArgs::addArgs(const ToolChain &TC, const ArgList &Args,
                     options::OPT_fno_xray_always_emit_typedevents);
   Args.addOptInFlag(CmdArgs, options::OPT_fxray_ignore_loops,
                     options::OPT_fno_xray_ignore_loops);
-  Args.addOptInFlag(CmdArgs, options::OPT_fxray_function_index,
-                    options::OPT_fno_xray_function_index);
+  Args.addOptOutFlag(CmdArgs, options::OPT_fxray_function_index,
+                     options::OPT_fno_xray_function_index);
 
   if (const Arg *A =
           Args.getLastArg(options::OPT_fxray_instruction_threshold_EQ)) {

diff  --git a/clang/test/CodeGen/xray-function-index.c b/clang/test/CodeGen/xray-function-index.c
index bdaef655abcfc..0b18c2a530247 100644
--- a/clang/test/CodeGen/xray-function-index.c
+++ b/clang/test/CodeGen/xray-function-index.c
@@ -1,6 +1,6 @@
 // REQUIRES: x86-registered-target
-// RUN: %clang_cc1 -S -triple x86_64 -fxray-instrument -fxray-instruction-threshold=1 -fxray-function-index %s -o - | FileCheck %s
-// RUN: %clang_cc1 -S -triple x86_64 -fxray-instrument -fxray-instruction-threshold=1 %s -o - | FileCheck %s --check-prefix=NO
+// RUN: %clang_cc1 -S -triple x86_64 -fxray-instrument -fxray-instruction-threshold=1 %s -o - | FileCheck %s
+// RUN: %clang_cc1 -S -triple x86_64 -fxray-instrument -fxray-instruction-threshold=1 -fno-xray-function-index %s -o - | FileCheck %s --check-prefix=NO
 
 // CHECK: .section xray_fn_idx,"awo", at progbits,foo
 // NO-NOT: .section xray_fn_idx

diff  --git a/clang/test/Driver/xray-function-index.cpp b/clang/test/Driver/xray-function-index.cpp
index 550de3d17305a..6cc8d47c638c6 100644
--- a/clang/test/Driver/xray-function-index.cpp
+++ b/clang/test/Driver/xray-function-index.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang -### -c --target=x86_64 -fxray-instrument -fxray-function-index %s 2>&1 | FileCheck %s
-// RUN: %clang -### -c --target=x86_64 -fxray-instrument %s 2>&1 | FileCheck %s --check-prefix=DISABLED
+// RUN: %clang -### -c --target=x86_64 -fxray-instrument %s 2>&1 | FileCheck %s
+// RUN: %clang -### -c --target=x86_64 -fxray-instrument -fxray-function-index -fno-xray-function-index %s 2>&1 | FileCheck %s --check-prefix=DISABLED
 
-// CHECK:      "-fxray-function-index"
-// DISABLED-NOT: "-fxray-function-index"
+// CHECK-NOT:  "-fxray-function-index"
+// DISABLED:   "-fno-xray-function-index"


        


More information about the cfe-commits mailing list