llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-driver Author: Sebastian Kreutzer (sebastiankreutzer) <details> <summary>Changes</summary> 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: #<!-- -->90959 --- Full diff: https://github.com/llvm/llvm-project/pull/111978.diff 4 Files Affected: - (modified) clang/include/clang/Driver/XRayArgs.h (+1-3) - (modified) clang/lib/Driver/XRayArgs.cpp (+4-4) - (modified) compiler-rt/include/xray/xray_interface.h (+22-18) - (modified) compiler-rt/lib/xray/xray_interface.cpp (+2-3) ``````````diff diff --git a/clang/include/clang/Driver/XRayArgs.h b/clang/include/clang/Driver/XRayArgs.h index 8fbcf469e5bad1..1b5c4a4c42f12a 100644 --- a/clang/include/clang/Driver/XRayArgs.h +++ b/clang/include/clang/Driver/XRayArgs.h @@ -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; } }; diff --git a/clang/lib/Driver/XRayArgs.cpp b/clang/lib/Driver/XRayArgs.cpp index 411054e067cb42..d0bb5d4887c184 100644 --- a/clang/lib/Driver/XRayArgs.cpp +++ b/clang/lib/Driver/XRayArgs.cpp @@ -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 @@ -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"; } } diff --git a/compiler-rt/include/xray/xray_interface.h b/compiler-rt/include/xray/xray_interface.h index 717cfe292ce416..675ea0cbc48c83 100644 --- a/compiler-rt/include/xray/xray_interface.h +++ b/compiler-rt/include/xray/xray_interface.h @@ -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. @@ -105,8 +105,8 @@ 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 @@ -114,8 +114,8 @@ extern XRayPatchingStatus __xray_unpatch_object(int32_t ObjId); /// 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); @@ -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. @@ -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 diff --git a/compiler-rt/lib/xray/xray_interface.cpp b/compiler-rt/lib/xray/xray_interface.cpp index 16e60bfc22cd10..402fc3d07b4e2a 100644 --- a/compiler-rt/lib/xray/xray_interface.cpp +++ b/compiler-rt/lib/xray/xray_interface.cpp @@ -13,7 +13,6 @@ //===----------------------------------------------------------------------===// #include "xray_interface_internal.h" -#include "llvm/Support/ErrorHandling.h" #include <cinttypes> #include <cstdio> @@ -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; `````````` </details> https://github.com/llvm/llvm-project/pull/111978 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits