Skip to content

Commit 4451f9f

Browse files
[XRay] Fix LLVM include in xray_interface.cpp (llvm#111978)
Removes a dependency on LLVM in `xray_interface.cpp` by replacing `llvm_unreachable` with compiler-rt's `UNREACHABLE`. Applies clang-format to some unformatted changes. Original PR: llvm#90959
1 parent d941254 commit 4451f9f

File tree

4 files changed

+29
-28
lines changed

4 files changed

+29
-28
lines changed

clang/include/clang/Driver/XRayArgs.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ class XRayArgs {
3636
llvm::opt::ArgStringList &CmdArgs, types::ID InputType) const;
3737

3838
bool needsXRayRt() const { return XRayInstrument && XRayRT; }
39-
bool needsXRayDSORt() const {
40-
return XRayInstrument && XRayRT && XRayShared;
41-
}
39+
bool needsXRayDSORt() const { return XRayInstrument && XRayRT && XRayShared; }
4240
llvm::ArrayRef<std::string> modeList() const { return Modes; }
4341
XRayInstrSet instrumentationBundle() const { return InstrumentationBundle; }
4442
};

clang/lib/Driver/XRayArgs.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ XRayArgs::XRayArgs(const ToolChain &TC, const ArgList &Args) {
6363
<< XRayInstrument->getSpelling() << Triple.str();
6464
}
6565

66-
if (Args.hasFlag(options::OPT_fxray_shared,
67-
options::OPT_fno_xray_shared, false)) {
66+
if (Args.hasFlag(options::OPT_fxray_shared, options::OPT_fno_xray_shared,
67+
false)) {
6868
XRayShared = true;
6969

7070
// DSO instrumentation is currently limited to x86_64
@@ -75,8 +75,8 @@ XRayArgs::XRayArgs(const ToolChain &TC, const ArgList &Args) {
7575

7676
unsigned PICLvl = std::get<1>(tools::ParsePICArgs(TC, Args));
7777
if (!PICLvl) {
78-
D.Diag(diag::err_opt_not_valid_without_opt)
79-
<< "-fxray-shared" << "-fPIC";
78+
D.Diag(diag::err_opt_not_valid_without_opt) << "-fxray-shared"
79+
<< "-fPIC";
8080
}
8181
}
8282

compiler-rt/include/xray/xray_interface.h

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ enum XRayPatchingStatus {
9393
FAILED = 3,
9494
};
9595

96-
/// This tells XRay to patch the instrumentation points in all currently loaded objects. See XRayPatchingStatus
97-
/// for possible result values.
96+
/// This tells XRay to patch the instrumentation points in all currently loaded
97+
/// objects. See XRayPatchingStatus for possible result values.
9898
extern XRayPatchingStatus __xray_patch();
9999

100100
/// This tells XRay to patch the instrumentation points in the given object.
@@ -105,17 +105,17 @@ extern XRayPatchingStatus __xray_patch_object(int32_t ObjId);
105105
/// result values.
106106
extern XRayPatchingStatus __xray_unpatch();
107107

108-
/// Reverses the effect of __xray_patch_object. See XRayPatchingStatus for possible
109-
/// result values.
108+
/// Reverses the effect of __xray_patch_object. See XRayPatchingStatus for
109+
/// possible result values.
110110
extern XRayPatchingStatus __xray_unpatch_object(int32_t ObjId);
111111

112112
/// This unpacks the given (packed) function id and patches
113113
/// the corresponding function. See XRayPatchingStatus for possible
114114
/// result values.
115115
extern XRayPatchingStatus __xray_patch_function(int32_t FuncId);
116116

117-
/// This patches a specific function in the given object. See XRayPatchingStatus for possible
118-
/// result values.
117+
/// This patches a specific function in the given object. See XRayPatchingStatus
118+
/// for possible result values.
119119
extern XRayPatchingStatus __xray_patch_function_in_object(int32_t FuncId,
120120
int32_t ObjId);
121121

@@ -129,26 +129,29 @@ extern XRayPatchingStatus __xray_unpatch_function(int32_t FuncId);
129129
extern XRayPatchingStatus __xray_unpatch_function_in_object(int32_t FuncId,
130130
int32_t ObjId);
131131

132-
/// This function unpacks the given (packed) function id and returns the address of the corresponding function. We return 0 if we encounter any error, even if 0 may be a valid function
133-
/// address.
132+
/// This function unpacks the given (packed) function id and returns the address
133+
/// of the corresponding function. We return 0 if we encounter any error, even
134+
/// if 0 may be a valid function address.
134135
extern uintptr_t __xray_function_address(int32_t FuncId);
135136

136-
/// This function returns the address of the function in the given object provided valid function and object
137-
/// ids. We return 0 if we encounter any error, even if 0 may be a valid function
138-
/// address.
137+
/// This function returns the address of the function in the given object
138+
/// provided valid function and object ids. We return 0 if we encounter any
139+
/// error, even if 0 may be a valid function address.
139140
extern uintptr_t __xray_function_address_in_object(int32_t FuncId,
140141
int32_t ObjId);
141142

142-
/// This function returns the maximum valid function id for the main executable (object id = 0). Returns 0 if we
143-
/// encounter errors (when there are no instrumented functions, etc.).
143+
/// This function returns the maximum valid function id for the main executable
144+
/// (object id = 0). Returns 0 if we encounter errors (when there are no
145+
/// instrumented functions, etc.).
144146
extern size_t __xray_max_function_id();
145147

146-
/// This function returns the maximum valid function id for the given object. Returns 0 if we
147-
/// encounter errors (when there are no instrumented functions, etc.).
148+
/// This function returns the maximum valid function id for the given object.
149+
/// Returns 0 if we encounter errors (when there are no instrumented functions,
150+
/// etc.).
148151
extern size_t __xray_max_function_id_in_object(int32_t ObjId);
149152

150-
/// This function returns the number of previously registered objects (executable + loaded DSOs).
151-
/// Returns 0 if XRay has not been initialized.
153+
/// This function returns the number of previously registered objects
154+
/// (executable + loaded DSOs). Returns 0 if XRay has not been initialized.
152155
extern size_t __xray_num_objects();
153156

154157
/// Unpacks the function id from the given packed id.
@@ -158,7 +161,8 @@ extern int32_t __xray_unpack_function_id(int32_t PackedId);
158161
extern int32_t __xray_unpack_object_id(int32_t PackedId);
159162

160163
/// Creates and returns a packed id from the given function and object ids.
161-
/// If the ids do not fit within the reserved number of bits for each part, the high bits are truncated.
164+
/// If the ids do not fit within the reserved number of bits for each part, the
165+
/// high bits are truncated.
162166
extern int32_t __xray_pack_id(int32_t FuncId, int32_t ObjId);
163167

164168
/// Initialize the required XRay data structures. This is useful in cases where

compiler-rt/lib/xray/xray_interface.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
#include "xray_interface_internal.h"
16-
#include "llvm/Support/ErrorHandling.h"
1716

1817
#include <cinttypes>
1918
#include <cstdio>
@@ -411,9 +410,9 @@ XRayPatchingStatus controlPatching(bool Enable) XRAY_NEVER_INSTRUMENT {
411410
CombinedStatus = NOT_INITIALIZED;
412411
break;
413412
case ONGOING:
414-
llvm_unreachable("Status ONGOING should not appear at this point");
413+
UNREACHABLE("Status ONGOING should not appear at this point");
415414
default:
416-
llvm_unreachable("Unhandled patching status");
415+
UNREACHABLE("Unhandled patching status");
417416
}
418417
}
419418
return CombinedStatus;

0 commit comments

Comments
 (0)