[PATCH] D145849: [Driver][xray] Allow XRay on Apple Silicon

2023-06-17 Thread Oleksii Lozovskyi via Phabricator via cfe-commits
ilammy added a comment.

In D145849#4412286 , @MaskRay wrote:

> However, `Triple.isMacOSX()` is allowed before the feature actually works and 
> `compiler-rt/test/xray/lit.cfg.py` tests it.

I have some patches for `compiler-rt` cooking, fixing the build for AArch64. 
Should those go in first, before `clang` is ultimately allowed to use 
`-fxray-instrument` when targeting AArch64, so that everything works out of the 
box?

For me, Clang is able to compile binaries with XRay sections (with this 
change), but I have `compiler-rt` disabled and not linked in, since it's not 
possible to build it for AArch64 yet.

I thought it could be done separately. I was not aware of those tests in 
compiler-rt, checking all archs.

I guess the build should be fixed first, then this change should simultaneously 
allow clang to target AArch64 and update compiler-rt's expectations of what 
works.

How does that sound to you?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145849/new/

https://reviews.llvm.org/D145849

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145848: [Driver] Correct -f(no-)xray-function-index behavior

2023-06-15 Thread Oleksii Lozovskyi via Phabricator via cfe-commits
ilammy abandoned this revision.
ilammy added a comment.

@MaskRay, thanks!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145848/new/

https://reviews.llvm.org/D145848

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145849: [Driver][xray] Allow XRay on Apple Silicon

2023-06-11 Thread Oleksii Lozovskyi via Phabricator via cfe-commits
ilammy updated this revision to Diff 530285.
ilammy added a comment.

Addressing feedback by  @MaskRay:

- Moved `// REQUIRES:` directive to the top of the test file
- Replaced legacy `-target` option with proper `--target` in tests
- Also rebased on updated trunk


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145849/new/

https://reviews.llvm.org/D145849

Files:
  clang/lib/Driver/XRayArgs.cpp
  clang/test/Driver/XRay/xray-instrument-macos.c
  clang/test/Driver/XRay/xray-instrument-os.c


Index: clang/test/Driver/XRay/xray-instrument-os.c
===
--- clang/test/Driver/XRay/xray-instrument-os.c
+++ clang/test/Driver/XRay/xray-instrument-os.c
@@ -1,4 +1,4 @@
 // RUN: not %clang -o /dev/null -v -fxray-instrument -c %s
-// XFAIL: target={{.*-(linux|freebsd).*}}, 
target=x86_64-apple-{{(darwin|macos).*}}
+// XFAIL: target={{.*-(linux|freebsd).*}}, 
target={{(aarch64|x86_64)-apple-(darwin|macos).*}}
 // REQUIRES: target={{(amd64|x86_64|x86_64h|arm|aarch64|arm64)-.*}}
 typedef int a;
Index: clang/test/Driver/XRay/xray-instrument-macos.c
===
--- clang/test/Driver/XRay/xray-instrument-macos.c
+++ clang/test/Driver/XRay/xray-instrument-macos.c
@@ -1,4 +1,5 @@
-// RUN: %clang -o /dev/null -v -fxray-instrument -target 
x86_64-apple-macos10.11 -c %s
-// RUN: %clang -o /dev/null -v -fxray-instrument -target x86_64-apple-darwin15 
-c %s
-// REQUIRES: x86_64 || x86_64h
+// REQUIRES: aarch64 || x86_64 || x86_64h
+// RUN: %clang -o /dev/null -v -fxray-instrument --target 
aarch64-apple-darwin20 -c %s
+// RUN: %clang -o /dev/null -v -fxray-instrument --target 
x86_64-apple-macos10.11 -c %s
+// RUN: %clang -o /dev/null -v -fxray-instrument --target 
x86_64-apple-darwin15 -c %s
 typedef int a;
Index: clang/lib/Driver/XRayArgs.cpp
===
--- clang/lib/Driver/XRayArgs.cpp
+++ clang/lib/Driver/XRayArgs.cpp
@@ -52,11 +52,20 @@
   << (std::string(XRayInstrumentOption) + " on " + Triple.str());
 }
   } else if (Triple.isOSFreeBSD() || Triple.isOSOpenBSD() ||
- Triple.isOSNetBSD() || Triple.isMacOSX()) {
+ Triple.isOSNetBSD()) {
 if (Triple.getArch() != llvm::Triple::x86_64) {
   D.Diag(diag::err_drv_clang_unsupported)
   << (std::string(XRayInstrumentOption) + " on " + Triple.str());
 }
+  } else if (Triple.isMacOSX()) {
+switch (Triple.getArch()) {
+case llvm::Triple::x86_64:
+case llvm::Triple::aarch64:
+  break;
+default:
+  D.Diag(diag::err_drv_clang_unsupported)
+  << (std::string(XRayInstrumentOption) + " on " + Triple.str());
+}
   } else if (Triple.getOS() == llvm::Triple::Fuchsia) {
 switch (Triple.getArch()) {
 case llvm::Triple::x86_64:


Index: clang/test/Driver/XRay/xray-instrument-os.c
===
--- clang/test/Driver/XRay/xray-instrument-os.c
+++ clang/test/Driver/XRay/xray-instrument-os.c
@@ -1,4 +1,4 @@
 // RUN: not %clang -o /dev/null -v -fxray-instrument -c %s
-// XFAIL: target={{.*-(linux|freebsd).*}}, target=x86_64-apple-{{(darwin|macos).*}}
+// XFAIL: target={{.*-(linux|freebsd).*}}, target={{(aarch64|x86_64)-apple-(darwin|macos).*}}
 // REQUIRES: target={{(amd64|x86_64|x86_64h|arm|aarch64|arm64)-.*}}
 typedef int a;
Index: clang/test/Driver/XRay/xray-instrument-macos.c
===
--- clang/test/Driver/XRay/xray-instrument-macos.c
+++ clang/test/Driver/XRay/xray-instrument-macos.c
@@ -1,4 +1,5 @@
-// RUN: %clang -o /dev/null -v -fxray-instrument -target x86_64-apple-macos10.11 -c %s
-// RUN: %clang -o /dev/null -v -fxray-instrument -target x86_64-apple-darwin15 -c %s
-// REQUIRES: x86_64 || x86_64h
+// REQUIRES: aarch64 || x86_64 || x86_64h
+// RUN: %clang -o /dev/null -v -fxray-instrument --target aarch64-apple-darwin20 -c %s
+// RUN: %clang -o /dev/null -v -fxray-instrument --target x86_64-apple-macos10.11 -c %s
+// RUN: %clang -o /dev/null -v -fxray-instrument --target x86_64-apple-darwin15 -c %s
 typedef int a;
Index: clang/lib/Driver/XRayArgs.cpp
===
--- clang/lib/Driver/XRayArgs.cpp
+++ clang/lib/Driver/XRayArgs.cpp
@@ -52,11 +52,20 @@
   << (std::string(XRayInstrumentOption) + " on " + Triple.str());
 }
   } else if (Triple.isOSFreeBSD() || Triple.isOSOpenBSD() ||
- Triple.isOSNetBSD() || Triple.isMacOSX()) {
+ Triple.isOSNetBSD()) {
 if (Triple.getArch() != llvm::Triple::x86_64) {
   D.Diag(diag::err_drv_clang_unsupported)
   << (std::string(XRayInstrumentOption) + " on " + Triple.str());
 }
+  } else if (Triple.isMacOSX()) {
+switch (Triple.getArch()) {
+case llvm::Triple::x86_64:
+case llvm::Triple::aarch64:
+  break;
+default:
+  

[PATCH] D145848: [Driver] Correct -f(no-)xray-function-index behavior

2023-06-11 Thread Oleksii Lozovskyi via Phabricator via cfe-commits
ilammy updated this revision to Diff 530284.
ilammy added a comment.

Addressing feedback by @MaskRay:

- Moved `// REQUIRES:` directive to the top of the test file


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145848/new/

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,9 @@
+// REQUIRES: x86-registered-target
+// 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: .section xray_fn_idx
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2216,10 +2216,10 @@
   NegFlag>;
 
 defm xray_function_index : BoolFOption<"xray-function-index",
-  CodeGenOpts<"XRayOmitFunctionIndex">, DefaultTrue,
-  NegFlag, DefaultFalse,
+  NegFlag,
-  PosFlag>;
+  PosFlag>;
 
 def fxray_link_deps : Flag<["-"], "fxray-link-deps">, Group,
   Flags<[CC1Option]>,


Index: clang/test/CodeGen/xray-function-index.cpp
===
--- /dev/null
+++ clang/test/CodeGen/xray-function-index.cpp
@@ -0,0 +1,9 @@
+// REQUIRES: x86-registered-target
+// 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: .section xray_fn_idx
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2216,10 +2216,10 @@
   NegFlag>;
 
 defm xray_function_index : BoolFOption<"xray-function-index",
-  CodeGenOpts<"XRayOmitFunctionIndex">, DefaultTrue,
-  NegFlag, DefaultFalse,
+  NegFlag,
-  PosFlag>;
+  PosFlag>;
 
 def fxray_link_deps : Flag<["-"], "fxray-link-deps">, Group,
   Flags<[CC1Option]>,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145848: [Driver] Correct -f(no-)xray-function-index behavior

2023-03-13 Thread Oleksii Lozovskyi via Phabricator via cfe-commits
ilammy updated this revision to Diff 504609.
ilammy added a comment.

Addressed feedback by @MaskRay. Thanks!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145848/new/

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,9 @@
+// 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
+// REQUIRES: x86-registered-target
+
+[[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: .section 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>;
 
 defm xray_function_index : BoolFOption<"xray-function-index",
-  CodeGenOpts<"XRayOmitFunctionIndex">, DefaultTrue,
-  NegFlag, DefaultFalse,
+  NegFlag,
-  PosFlag>;
+  PosFlag>;
 
 def fxray_link_deps : Flag<["-"], "fxray-link-deps">, Group,
   Flags<[CC1Option]>,


Index: clang/test/CodeGen/xray-function-index.cpp
===
--- /dev/null
+++ clang/test/CodeGen/xray-function-index.cpp
@@ -0,0 +1,9 @@
+// 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
+// REQUIRES: x86-registered-target
+
+[[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: .section 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>;
 
 defm xray_function_index : BoolFOption<"xray-function-index",
-  CodeGenOpts<"XRayOmitFunctionIndex">, DefaultTrue,
-  NegFlag, DefaultFalse,
+  NegFlag,
-  PosFlag>;
+  PosFlag>;
 
 def fxray_link_deps : Flag<["-"], "fxray-link-deps">, Group,
   Flags<[CC1Option]>,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145849: [Driver][xray] Allow XRay on Apple Silicon

2023-03-11 Thread Oleksii Lozovskyi via Phabricator via cfe-commits
ilammy created this revision.
ilammy added reviewers: MaskRay, ianlevesque, dberris.
ilammy added a project: clang.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
ilammy requested review of this revision.
Herald added a subscriber: cfe-commits.

Codegen can handle XRay for AArch64, tell the driver to allow it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145849

Files:
  clang/lib/Driver/XRayArgs.cpp
  clang/test/Driver/XRay/xray-instrument-macos.c
  clang/test/Driver/XRay/xray-instrument-os.c


Index: clang/test/Driver/XRay/xray-instrument-os.c
===
--- clang/test/Driver/XRay/xray-instrument-os.c
+++ clang/test/Driver/XRay/xray-instrument-os.c
@@ -1,4 +1,4 @@
 // RUN: not %clang -o /dev/null -v -fxray-instrument -c %s
-// XFAIL: target={{.*-(linux|freebsd).*}}, 
target=x86_64-apple-{{(darwin|macos).*}}
+// XFAIL: target={{.*-(linux|freebsd).*}}, 
target={{(aarch64|x86_64)-apple-(darwin|macos).*}}
 // REQUIRES: target={{(amd64|x86_64|x86_64h|arm|aarch64|arm64)-.*}}
 typedef int a;
Index: clang/test/Driver/XRay/xray-instrument-macos.c
===
--- clang/test/Driver/XRay/xray-instrument-macos.c
+++ clang/test/Driver/XRay/xray-instrument-macos.c
@@ -1,4 +1,5 @@
+// RUN: %clang -o /dev/null -v -fxray-instrument -target 
aarch64-apple-darwin20 -c %s
 // RUN: %clang -o /dev/null -v -fxray-instrument -target 
x86_64-apple-macos10.11 -c %s
 // RUN: %clang -o /dev/null -v -fxray-instrument -target x86_64-apple-darwin15 
-c %s
-// REQUIRES: x86_64 || x86_64h
+// REQUIRES: aarch64 || x86_64 || x86_64h
 typedef int a;
Index: clang/lib/Driver/XRayArgs.cpp
===
--- clang/lib/Driver/XRayArgs.cpp
+++ clang/lib/Driver/XRayArgs.cpp
@@ -52,11 +52,20 @@
   << (std::string(XRayInstrumentOption) + " on " + Triple.str());
 }
   } else if (Triple.isOSFreeBSD() || Triple.isOSOpenBSD() ||
- Triple.isOSNetBSD() || Triple.isMacOSX()) {
+ Triple.isOSNetBSD()) {
 if (Triple.getArch() != llvm::Triple::x86_64) {
   D.Diag(diag::err_drv_clang_unsupported)
   << (std::string(XRayInstrumentOption) + " on " + Triple.str());
 }
+  } else if (Triple.isMacOSX()) {
+switch (Triple.getArch()) {
+case llvm::Triple::x86_64:
+case llvm::Triple::aarch64:
+  break;
+default:
+  D.Diag(diag::err_drv_clang_unsupported)
+  << (std::string(XRayInstrumentOption) + " on " + Triple.str());
+}
   } else if (Triple.getOS() == llvm::Triple::Fuchsia) {
 switch (Triple.getArch()) {
 case llvm::Triple::x86_64:


Index: clang/test/Driver/XRay/xray-instrument-os.c
===
--- clang/test/Driver/XRay/xray-instrument-os.c
+++ clang/test/Driver/XRay/xray-instrument-os.c
@@ -1,4 +1,4 @@
 // RUN: not %clang -o /dev/null -v -fxray-instrument -c %s
-// XFAIL: target={{.*-(linux|freebsd).*}}, target=x86_64-apple-{{(darwin|macos).*}}
+// XFAIL: target={{.*-(linux|freebsd).*}}, target={{(aarch64|x86_64)-apple-(darwin|macos).*}}
 // REQUIRES: target={{(amd64|x86_64|x86_64h|arm|aarch64|arm64)-.*}}
 typedef int a;
Index: clang/test/Driver/XRay/xray-instrument-macos.c
===
--- clang/test/Driver/XRay/xray-instrument-macos.c
+++ clang/test/Driver/XRay/xray-instrument-macos.c
@@ -1,4 +1,5 @@
+// RUN: %clang -o /dev/null -v -fxray-instrument -target aarch64-apple-darwin20 -c %s
 // RUN: %clang -o /dev/null -v -fxray-instrument -target x86_64-apple-macos10.11 -c %s
 // RUN: %clang -o /dev/null -v -fxray-instrument -target x86_64-apple-darwin15 -c %s
-// REQUIRES: x86_64 || x86_64h
+// REQUIRES: aarch64 || x86_64 || x86_64h
 typedef int a;
Index: clang/lib/Driver/XRayArgs.cpp
===
--- clang/lib/Driver/XRayArgs.cpp
+++ clang/lib/Driver/XRayArgs.cpp
@@ -52,11 +52,20 @@
   << (std::string(XRayInstrumentOption) + " on " + Triple.str());
 }
   } else if (Triple.isOSFreeBSD() || Triple.isOSOpenBSD() ||
- Triple.isOSNetBSD() || Triple.isMacOSX()) {
+ Triple.isOSNetBSD()) {
 if (Triple.getArch() != llvm::Triple::x86_64) {
   D.Diag(diag::err_drv_clang_unsupported)
   << (std::string(XRayInstrumentOption) + " on " + Triple.str());
 }
+  } else if (Triple.isMacOSX()) {
+switch (Triple.getArch()) {
+case llvm::Triple::x86_64:
+case llvm::Triple::aarch64:
+  break;
+default:
+  D.Diag(diag::err_drv_clang_unsupported)
+  << (std::string(XRayInstrumentOption) + " on " + Triple.str());
+}
   } else if (Triple.getOS() == llvm::Triple::Fuchsia) {
 switch (Triple.getArch()) {
 case llvm::Triple::x86_64:
___
cfe-commits mailing list

[PATCH] D145848: [Driver] Correct -f(no-)xray-function-index behavior

2023-03-11 Thread Oleksii Lozovskyi via Phabricator via cfe-commits
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>;
 
 defm xray_function_index : BoolFOption<"xray-function-index",
-  CodeGenOpts<"XRayOmitFunctionIndex">, DefaultTrue,
-  NegFlag, DefaultFalse,
+  NegFlag,
-  PosFlag>;
+  PosFlag>;
 
 def fxray_link_deps : Flag<["-"], "fxray-link-deps">, 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>;
 
 defm xray_function_index : BoolFOption<"xray-function-index",
-  CodeGenOpts<"XRayOmitFunctionIndex">, DefaultTrue,
-  NegFlag, DefaultFalse,
+  NegFlag,
-  PosFlag>;
+  PosFlag>;
 
 def fxray_link_deps : Flag<["-"], "fxray-link-deps">, Group,
   Flags<[CC1Option]>,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits