| 1 |
// RUN: %clang_cc1 -fxray-instrument -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s |
| 2 |
|
| 3 |
// CHECK-LABEL: @_Z16alwaysInstrumentv |
| 4 |
[[clang::xray_always_instrument]] void alwaysInstrument() { |
| 5 |
// Event types would normally come from calling __xray_register_event_type |
| 6 |
// from compiler-rt |
| 7 |
auto EventType = 1; |
| 8 |
static constexpr char kPhase[] = "instrument"; |
| 9 |
__xray_typedevent(EventType, kPhase, 10); |
| 10 |
// CHECK: call void @llvm.xray.typedevent(i64 {{.*}}, ptr{{.*}}, i64 10) |
| 11 |
} |
| 12 |
|
| 13 |
// CHECK-LABEL: @_Z15neverInstrumentv |
| 14 |
[[clang::xray_never_instrument]] void neverInstrument() { |
| 15 |
auto EventType = 2; |
| 16 |
static constexpr char kPhase[] = "never"; |
| 17 |
__xray_typedevent(EventType, kPhase, 5); |
| 18 |
// CHECK-NOT: call void @llvm.xray.typedevent(i64 {{.*}}, ptr{{.*}}, i64 5) |
| 19 |
} |
| 20 |
|
| 21 |
// CHECK-LABEL: @_Z21conditionalInstrumenti |
| 22 |
[[clang::xray_always_instrument]] void conditionalInstrument(int v) { |
| 23 |
auto TrueEventType = 3; |
| 24 |
auto UntrueEventType = 4; |
| 25 |
static constexpr char kTrue[] = "true"; |
| 26 |
static constexpr char kUntrue[] = "untrue"; |
| 27 |
if (v % 2) |
| 28 |
__xray_typedevent(TrueEventType, kTrue, 4); |
| 29 |
else |
| 30 |
__xray_typedevent(UntrueEventType, kUntrue, 6); |
| 31 |
|
| 32 |
// CHECK: call void @llvm.xray.typedevent(i64 {{.*}}, ptr{{.*}}, i64 4) |
| 33 |
// CHECK: call void @llvm.xray.typedevent(i64 {{.*}}, ptr{{.*}}, i64 6) |
| 34 |
} |