ilammy created this revision.
ilammy added reviewers: MaskRay, ianlevesque, dberris.
ilammy added a project: clang.
Herald added a subscriber: arphaman.
Herald added a project: All.
ilammy requested review of this revision.
Herald added a subscriber: cfe-commits.

This option has undergone several refactorings and got inverted along
the way. The `XRayOmitFunctionIndex` flag governs codegen behavior,
*omitting* "xray_fn_idx" section if it is set. But the command-line
flag behavior was not adjusted at the time. Right now it's like this:

                 (default): no function index
     -fxray-function-index: no function index
  -fno-xray-function-index: "xray_fn_idx" is present

While the default behavior should be keep "xray_fn_idx", unless
-fno-xray-function-index is given:

                 (default): "xray_fn_idx" is present
     -fxray-function-index: same, present, but explicitly
  -fno-xray-function-index: no function index

Flip the flags to make it so.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145848

Files:
  clang/include/clang/Driver/Options.td
  clang/test/CodeGen/xray-function-index.cpp


Index: clang/test/CodeGen/xray-function-index.cpp
===================================================================
--- /dev/null
+++ clang/test/CodeGen/xray-function-index.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fxray-instrument                          -x c++ 
-std=c++11 -triple x86_64-unknown-linux-gnu -S -o - %s | FileCheck %s 
--check-prefixes=CHECK,CHECK-ENABLED
+// RUN: %clang_cc1 -fxray-instrument -fno-xray-function-index -x c++ 
-std=c++11 -triple x86_64-unknown-linux-gnu -S -o - %s | FileCheck %s 
--check-prefixes=CHECK,CHECK-DISABLED
+
+[[clang::xray_always_instrument]] void foo() {}
+
+// CHECK-LABEL: .section xray_instr_map,"ao",@progbits,_Z3foov
+// CHECK-ENABLED: .section xray_fn_idx,"awo",@progbits,_Z3foov
+// CHECK-DISABLED-NOT: xray_fn_idx
Index: clang/include/clang/Driver/Options.td
===================================================================
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2173,10 +2173,10 @@
   NegFlag<SetFalse>>;
 
 defm xray_function_index : BoolFOption<"xray-function-index",
-  CodeGenOpts<"XRayOmitFunctionIndex">, DefaultTrue,
-  NegFlag<SetFalse, [CC1Option], "Omit function index section at the"
+  CodeGenOpts<"XRayOmitFunctionIndex">, DefaultFalse,
+  NegFlag<SetTrue, [CC1Option], "Omit function index section at the"
           " expense of single-function patching performance">,
-  PosFlag<SetTrue>>;
+  PosFlag<SetFalse>>;
 
 def fxray_link_deps : Flag<["-"], "fxray-link-deps">, Group<f_Group>,
   Flags<[CC1Option]>,


Index: clang/test/CodeGen/xray-function-index.cpp
===================================================================
--- /dev/null
+++ clang/test/CodeGen/xray-function-index.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fxray-instrument                          -x c++ -std=c++11 -triple x86_64-unknown-linux-gnu -S -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-ENABLED
+// RUN: %clang_cc1 -fxray-instrument -fno-xray-function-index -x c++ -std=c++11 -triple x86_64-unknown-linux-gnu -S -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-DISABLED
+
+[[clang::xray_always_instrument]] void foo() {}
+
+// CHECK-LABEL: .section xray_instr_map,"ao",@progbits,_Z3foov
+// CHECK-ENABLED: .section xray_fn_idx,"awo",@progbits,_Z3foov
+// CHECK-DISABLED-NOT: xray_fn_idx
Index: clang/include/clang/Driver/Options.td
===================================================================
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2173,10 +2173,10 @@
   NegFlag<SetFalse>>;
 
 defm xray_function_index : BoolFOption<"xray-function-index",
-  CodeGenOpts<"XRayOmitFunctionIndex">, DefaultTrue,
-  NegFlag<SetFalse, [CC1Option], "Omit function index section at the"
+  CodeGenOpts<"XRayOmitFunctionIndex">, DefaultFalse,
+  NegFlag<SetTrue, [CC1Option], "Omit function index section at the"
           " expense of single-function patching performance">,
-  PosFlag<SetTrue>>;
+  PosFlag<SetFalse>>;
 
 def fxray_link_deps : Flag<["-"], "fxray-link-deps">, Group<f_Group>,
   Flags<[CC1Option]>,
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to