Skip to content

[XRay] Fix LLVM include in xray_interface.cpp #111978

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions clang/include/clang/Driver/XRayArgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ class XRayArgs {
llvm::opt::ArgStringList &CmdArgs, types::ID InputType) const;

bool needsXRayRt() const { return XRayInstrument && XRayRT; }
bool needsXRayDSORt() const {
return XRayInstrument && XRayRT && XRayShared;
}
bool needsXRayDSORt() const { return XRayInstrument && XRayRT && XRayShared; }
llvm::ArrayRef<std::string> modeList() const { return Modes; }
XRayInstrSet instrumentationBundle() const { return InstrumentationBundle; }
};
Expand Down
8 changes: 4 additions & 4 deletions clang/lib/Driver/XRayArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ XRayArgs::XRayArgs(const ToolChain &TC, const ArgList &Args) {
<< XRayInstrument->getSpelling() << Triple.str();
}

if (Args.hasFlag(options::OPT_fxray_shared,
options::OPT_fno_xray_shared, false)) {
if (Args.hasFlag(options::OPT_fxray_shared, options::OPT_fno_xray_shared,
false)) {
XRayShared = true;

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

unsigned PICLvl = std::get<1>(tools::ParsePICArgs(TC, Args));
if (!PICLvl) {
D.Diag(diag::err_opt_not_valid_without_opt)
<< "-fxray-shared" << "-fPIC";
D.Diag(diag::err_opt_not_valid_without_opt) << "-fxray-shared"
<< "-fPIC";
}
}

Expand Down
40 changes: 22 additions & 18 deletions compiler-rt/include/xray/xray_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ enum XRayPatchingStatus {
FAILED = 3,
};

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

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

/// Reverses the effect of __xray_patch_object. See XRayPatchingStatus for possible
/// result values.
/// Reverses the effect of __xray_patch_object. See XRayPatchingStatus for
/// possible result values.
extern XRayPatchingStatus __xray_unpatch_object(int32_t ObjId);

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

/// This patches a specific function in the given object. See XRayPatchingStatus for possible
/// result values.
/// This patches a specific function in the given object. See XRayPatchingStatus
/// for possible result values.
extern XRayPatchingStatus __xray_patch_function_in_object(int32_t FuncId,
int32_t ObjId);

Expand All @@ -129,26 +129,29 @@ extern XRayPatchingStatus __xray_unpatch_function(int32_t FuncId);
extern XRayPatchingStatus __xray_unpatch_function_in_object(int32_t FuncId,
int32_t ObjId);

/// 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
/// address.
/// 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 address.
extern uintptr_t __xray_function_address(int32_t FuncId);

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

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

/// This function returns the maximum valid function id for the given object. Returns 0 if we
/// encounter errors (when there are no instrumented functions, etc.).
/// This function returns the maximum valid function id for the given object.
/// Returns 0 if we encounter errors (when there are no instrumented functions,
/// etc.).
extern size_t __xray_max_function_id_in_object(int32_t ObjId);

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

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

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

/// Initialize the required XRay data structures. This is useful in cases where
Expand Down
5 changes: 2 additions & 3 deletions compiler-rt/lib/xray/xray_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
//===----------------------------------------------------------------------===//

#include "xray_interface_internal.h"
#include "llvm/Support/ErrorHandling.h"

#include <cinttypes>
#include <cstdio>
Expand Down Expand Up @@ -411,9 +410,9 @@ XRayPatchingStatus controlPatching(bool Enable) XRAY_NEVER_INSTRUMENT {
CombinedStatus = NOT_INITIALIZED;
break;
case ONGOING:
llvm_unreachable("Status ONGOING should not appear at this point");
UNREACHABLE("Status ONGOING should not appear at this point");
default:
llvm_unreachable("Unhandled patching status");
UNREACHABLE("Unhandled patching status");
}
}
return CombinedStatus;
Expand Down
Loading