Skip to content

Commit 90627a5

Browse files
committed
Revert "[XRay] Add support for instrumentation of DSOs on x86_64 (#90959)"
This reverts commit a440203 and 4451f9f
1 parent 303c8d2 commit 90627a5

22 files changed

+147
-1219
lines changed

clang/include/clang/Basic/CodeGenOptions.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,6 @@ CODEGENOPT(XRayIgnoreLoops , 1, 0)
136136
///< Emit the XRay function index section.
137137
CODEGENOPT(XRayFunctionIndex , 1, 1)
138138

139-
///< Set when -fxray-shared is enabled
140-
CODEGENOPT(XRayShared , 1, 0)
141139

142140
///< Set the minimum number of instructions in a function to determine selective
143141
///< XRay instrumentation.

clang/include/clang/Driver/Options.td

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2946,11 +2946,6 @@ def fxray_selected_function_group :
29462946
HelpText<"When using -fxray-function-groups, select which group of functions to instrument. Valid range is 0 to fxray-function-groups - 1">,
29472947
MarshallingInfoInt<CodeGenOpts<"XRaySelectedFunctionGroup">, "0">;
29482948

2949-
defm xray_shared : BoolFOption<"xray-shared",
2950-
CodeGenOpts<"XRayShared">, DefaultFalse,
2951-
PosFlag<SetTrue, [], [ClangOption, CC1Option],
2952-
"Enable shared library instrumentation with XRay">,
2953-
NegFlag<SetFalse>>;
29542949

29552950
defm fine_grained_bitfield_accesses : BoolOption<"f", "fine-grained-bitfield-accesses",
29562951
CodeGenOpts<"FineGrainedBitfieldAccesses">, DefaultFalse,

clang/include/clang/Driver/XRayArgs.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ class XRayArgs {
2727
XRayInstrSet InstrumentationBundle;
2828
llvm::opt::Arg *XRayInstrument = nullptr;
2929
bool XRayRT = true;
30-
bool XRayShared = false;
3130

3231
public:
3332
/// Parses the XRay arguments from an argument list.
@@ -36,7 +35,6 @@ class XRayArgs {
3635
llvm::opt::ArgStringList &CmdArgs, types::ID InputType) const;
3736

3837
bool needsXRayRt() const { return XRayInstrument && XRayRT; }
39-
bool needsXRayDSORt() const { return XRayInstrument && XRayRT && XRayShared; }
4038
llvm::ArrayRef<std::string> modeList() const { return Modes; }
4139
XRayInstrSet instrumentationBundle() const { return InstrumentationBundle; }
4240
};

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,14 +1613,10 @@ bool tools::addSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
16131613
}
16141614

16151615
bool tools::addXRayRuntime(const ToolChain&TC, const ArgList &Args, ArgStringList &CmdArgs) {
1616-
if (Args.hasArg(options::OPT_shared)) {
1617-
if (TC.getXRayArgs().needsXRayDSORt()) {
1618-
CmdArgs.push_back("--whole-archive");
1619-
CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray-dso"));
1620-
CmdArgs.push_back("--no-whole-archive");
1621-
return true;
1622-
}
1623-
} else if (TC.getXRayArgs().needsXRayRt()) {
1616+
if (Args.hasArg(options::OPT_shared))
1617+
return false;
1618+
1619+
if (TC.getXRayArgs().needsXRayRt()) {
16241620
CmdArgs.push_back("--whole-archive");
16251621
CmdArgs.push_back(TC.getCompilerRTArgString(Args, "xray"));
16261622
for (const auto &Mode : TC.getXRayArgs().modeList())

clang/lib/Driver/XRayArgs.cpp

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

66-
if (Args.hasFlag(options::OPT_fxray_shared, options::OPT_fno_xray_shared,
67-
false)) {
68-
XRayShared = true;
69-
70-
// DSO instrumentation is currently limited to x86_64
71-
if (Triple.getArch() != llvm::Triple::x86_64) {
72-
D.Diag(diag::err_drv_unsupported_opt_for_target)
73-
<< "-fxray-shared" << Triple.str();
74-
}
75-
76-
unsigned PICLvl = std::get<1>(tools::ParsePICArgs(TC, Args));
77-
if (!PICLvl) {
78-
D.Diag(diag::err_opt_not_valid_without_opt) << "-fxray-shared"
79-
<< "-fPIC";
80-
}
81-
}
82-
8366
// Both XRay and -fpatchable-function-entry use
8467
// TargetOpcode::PATCHABLE_FUNCTION_ENTER.
8568
if (Arg *A = Args.getLastArg(options::OPT_fpatchable_function_entry_EQ))
@@ -194,10 +177,6 @@ void XRayArgs::addArgs(const ToolChain &TC, const ArgList &Args,
194177
Args.addOptOutFlag(CmdArgs, options::OPT_fxray_function_index,
195178
options::OPT_fno_xray_function_index);
196179

197-
if (XRayShared)
198-
Args.addOptInFlag(CmdArgs, options::OPT_fxray_shared,
199-
options::OPT_fno_xray_shared);
200-
201180
if (const Arg *A =
202181
Args.getLastArg(options::OPT_fxray_instruction_threshold_EQ)) {
203182
int Value;

clang/test/Driver/XRay/xray-shared.cpp

Lines changed: 0 additions & 17 deletions
This file was deleted.

compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ else()
104104
set(ALL_XRAY_SUPPORTED_ARCH ${X86_64} ${ARM32} ${ARM64} ${MIPS32} ${MIPS64}
105105
powerpc64le ${HEXAGON} ${LOONGARCH64})
106106
endif()
107-
set(ALL_XRAY_DSO_SUPPORTED_ARCH ${X86_64})
108107
set(ALL_SHADOWCALLSTACK_SUPPORTED_ARCH ${ARM64})
109108

110109
if (UNIX)

compiler-rt/cmake/config-ix.cmake

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -668,9 +668,6 @@ if(APPLE)
668668
list_intersect(XRAY_SUPPORTED_ARCH
669669
ALL_XRAY_SUPPORTED_ARCH
670670
SANITIZER_COMMON_SUPPORTED_ARCH)
671-
list_intersect(XRAY_DSO_SUPPORTED_ARCH
672-
ALL_XRAY_DSO_SUPPORTED_ARCH
673-
SANITIZER_COMMON_SUPPORTED_ARCH)
674671
list_intersect(SHADOWCALLSTACK_SUPPORTED_ARCH
675672
ALL_SHADOWCALLSTACK_SUPPORTED_ARCH
676673
SANITIZER_COMMON_SUPPORTED_ARCH)
@@ -705,7 +702,6 @@ else()
705702
filter_available_targets(CFI_SUPPORTED_ARCH ${ALL_CFI_SUPPORTED_ARCH})
706703
filter_available_targets(SCUDO_STANDALONE_SUPPORTED_ARCH ${ALL_SCUDO_STANDALONE_SUPPORTED_ARCH})
707704
filter_available_targets(XRAY_SUPPORTED_ARCH ${ALL_XRAY_SUPPORTED_ARCH})
708-
filter_available_targets(XRAY_DSO_SUPPORTED_ARCH ${ALL_XRAY_DSO_SUPPORTED_ARCH})
709705
filter_available_targets(SHADOWCALLSTACK_SUPPORTED_ARCH
710706
${ALL_SHADOWCALLSTACK_SUPPORTED_ARCH})
711707
filter_available_targets(GWP_ASAN_SUPPORTED_ARCH ${ALL_GWP_ASAN_SUPPORTED_ARCH})

compiler-rt/include/xray/xray_interface.h

Lines changed: 9 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -93,78 +93,31 @@ enum XRayPatchingStatus {
9393
FAILED = 3,
9494
};
9595

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

100-
/// This tells XRay to patch the instrumentation points in the given object.
101-
/// See XRayPatchingStatus for possible result values.
102-
extern XRayPatchingStatus __xray_patch_object(int32_t ObjId);
103-
104100
/// Reverses the effect of __xray_patch(). See XRayPatchingStatus for possible
105101
/// result values.
106102
extern XRayPatchingStatus __xray_unpatch();
107103

108-
/// Reverses the effect of __xray_patch_object. See XRayPatchingStatus for
109-
/// possible result values.
110-
extern XRayPatchingStatus __xray_unpatch_object(int32_t ObjId);
111-
112-
/// This unpacks the given (packed) function id and patches
113-
/// the corresponding function. See XRayPatchingStatus for possible
104+
/// This patches a specific function id. See XRayPatchingStatus for possible
114105
/// result values.
115106
extern XRayPatchingStatus __xray_patch_function(int32_t FuncId);
116107

117-
/// This patches a specific function in the given object. See XRayPatchingStatus
118-
/// for possible result values.
119-
extern XRayPatchingStatus __xray_patch_function_in_object(int32_t FuncId,
120-
int32_t ObjId);
121-
122-
/// This unpacks the given (packed) function id and unpatches
123-
/// the corresponding function. See XRayPatchingStatus for possible
108+
/// This unpatches a specific function id. See XRayPatchingStatus for possible
124109
/// result values.
125110
extern XRayPatchingStatus __xray_unpatch_function(int32_t FuncId);
126111

127-
/// This unpatches a specific function in the given object.
128-
/// See XRayPatchingStatus for possible result values.
129-
extern XRayPatchingStatus __xray_unpatch_function_in_object(int32_t FuncId,
130-
int32_t ObjId);
131-
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.
112+
/// This function returns the address of the function provided a valid function
113+
/// id. We return 0 if we encounter any error, even if 0 may be a valid function
114+
/// address.
135115
extern uintptr_t __xray_function_address(int32_t FuncId);
136116

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.
140-
extern uintptr_t __xray_function_address_in_object(int32_t FuncId,
141-
int32_t ObjId);
142-
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.).
117+
/// This function returns the maximum valid function id. Returns 0 if we
118+
/// encounter errors (when there are no instrumented functions, etc.).
146119
extern size_t __xray_max_function_id();
147120

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.).
151-
extern size_t __xray_max_function_id_in_object(int32_t ObjId);
152-
153-
/// This function returns the number of previously registered objects
154-
/// (executable + loaded DSOs). Returns 0 if XRay has not been initialized.
155-
extern size_t __xray_num_objects();
156-
157-
/// Unpacks the function id from the given packed id.
158-
extern int32_t __xray_unpack_function_id(int32_t PackedId);
159-
160-
/// Unpacks the object id from the given packed id.
161-
extern int32_t __xray_unpack_object_id(int32_t PackedId);
162-
163-
/// Creates and returns a packed id from the given function and object ids.
164-
/// If the ids do not fit within the reserved number of bits for each part, the
165-
/// high bits are truncated.
166-
extern int32_t __xray_pack_id(int32_t FuncId, int32_t ObjId);
167-
168121
/// Initialize the required XRay data structures. This is useful in cases where
169122
/// users want to control precisely when the XRay instrumentation data
170123
/// structures are initialized, for example when the XRay library is built with

compiler-rt/lib/xray/CMakeLists.txt

Lines changed: 10 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ set(XRAY_SOURCES
1010
xray_utils.cpp
1111
)
1212

13-
set(XRAY_DSO_SOURCES
14-
xray_dso_init.cpp
15-
)
16-
1713
# Implementation files for all XRay modes.
1814
set(XRAY_FDR_MODE_SOURCES
1915
xray_fdr_flags.cpp
@@ -37,11 +33,6 @@ set(x86_64_SOURCES
3733
xray_trampoline_x86_64.S
3834
)
3935

40-
set(x86_64_DSO_SOURCES
41-
xray_trampoline_x86_64.S
42-
)
43-
44-
4536
set(arm_SOURCES
4637
xray_arm.cpp
4738
xray_trampoline_arm.S
@@ -137,12 +128,10 @@ set(XRAY_IMPL_HEADERS
137128
# consumption by tests.
138129
set(XRAY_ALL_SOURCE_FILES
139130
${XRAY_SOURCES}
140-
${XRAY_DSO_SOURCES}
141131
${XRAY_FDR_MODE_SOURCES}
142132
${XRAY_BASIC_MODE_SOURCES}
143133
${XRAY_PROFILING_MODE_SOURCES}
144134
${x86_64_SOURCES}
145-
${x86_64_DSO_SOURCES}
146135
${arm_SOURCES}
147136
${armhf_SOURCES}
148137
${hexagon_SOURCES}
@@ -173,9 +162,6 @@ set(XRAY_CFLAGS
173162
${COMPILER_RT_CXX_CFLAGS})
174163
set(XRAY_COMMON_DEFINITIONS SANITIZER_COMMON_NO_REDEFINE_BUILTINS XRAY_HAS_EXCEPTIONS=1)
175164

176-
# DSO trampolines need to be compiled with GOT addressing
177-
set(XRAY_COMMON_DEFINITIONS_DSO ${XRAY_COMMON_DEFINITIONS} XRAY_PIC)
178-
179165
# Too many existing bugs, needs cleanup.
180166
append_list_if(COMPILER_RT_HAS_WNO_FORMAT -Wno-format XRAY_CFLAGS)
181167

@@ -215,16 +201,7 @@ if (APPLE)
215201
CFLAGS ${XRAY_CFLAGS}
216202
DEFS ${XRAY_COMMON_DEFINITIONS}
217203
DEPS ${XRAY_DEPS})
218-
add_compiler_rt_object_libraries(RTXrayDSO
219-
OS ${XRAY_SUPPORTED_OS}
220-
ARCHS ${XRAY_DSO_SUPPORTED_ARCH}
221-
SOURCES ${XRAY_DSO_SOURCES}
222-
ADDITIONAL_HEADERS ${XRAY_IMPL_HEADERS}
223-
CFLAGS ${XRAY_CFLAGS}
224-
DEFS ${XRAY_COMMON_DEFINITIONS_DSO}
225-
DEPS ${XRAY_DEPS})
226204
set(XRAY_RTXRAY_ARCH_LIBS "")
227-
set(XRAY_DSO_RTXRAY_ARCH_LIBS "")
228205
foreach(arch ${XRAY_SUPPORTED_ARCH})
229206
if(NOT ${arch} IN_LIST XRAY_SOURCE_ARCHS)
230207
continue()
@@ -238,17 +215,6 @@ if (APPLE)
238215
DEFS ${XRAY_COMMON_DEFINITIONS}
239216
DEPS ${XRAY_DEPS})
240217
list(APPEND XRAY_RTXRAY_ARCH_LIBS RTXray_${arch})
241-
if (${arch} IN_LIST XRAY_DSO_SUPPORTED_ARCH)
242-
add_compiler_rt_object_libraries(RTXrayDSO_${arch}
243-
OS ${XRAY_SUPPORTED_OS}
244-
ARCHS ${XRAY_DSO_SUPPORTED_ARCH}
245-
SOURCES ${${arch}_DSO_SOURCES}
246-
ADDITIONAL_HEADERS ${XRAY_IMPL_HEADERS}
247-
CFLAGS ${XRAY_CFLAGS}
248-
DEFS ${XRAY_COMMON_DEFINITIONS_DSO}
249-
DEPS ${XRAY_DEPS})
250-
list(APPEND XRAY_DSO_RTXRAY_ARCH_LIBS RTXrayDSO_${arch})
251-
endif()
252218
endforeach()
253219
add_compiler_rt_object_libraries(RTXrayFDR
254220
OS ${XRAY_SUPPORTED_OS}
@@ -286,17 +252,6 @@ if (APPLE)
286252
LINK_FLAGS ${XRAY_LINK_FLAGS} ${WEAK_SYMBOL_LINK_FLAGS}
287253
LINK_LIBS ${XRAY_LINK_LIBS}
288254
PARENT_TARGET xray)
289-
add_compiler_rt_runtime(clang_rt.xray-dso
290-
STATIC
291-
OS ${XRAY_SUPPORTED_OS}
292-
ARCHS ${XRAY_DSO_SUPPORTED_ARCH}
293-
OBJECT_LIBS RTXrayDSO ${XRAY_DSO_RTXRAY_ARCH_LIBS}
294-
CFLAGS ${XRAY_CFLAGS}
295-
DEFS ${XRAY_COMMON_DEFINITIONS}
296-
LINK_FLAGS ${XRAY_LINK_FLAGS} ${WEAK_SYMBOL_LINK_FLAGS}
297-
LINK_LIBS ${XRAY_LINK_LIBS}
298-
PARENT_TARGET xray)
299-
300255
add_compiler_rt_runtime(clang_rt.xray-fdr
301256
STATIC
302257
OS ${XRAY_SUPPORTED_OS}
@@ -391,37 +346,16 @@ else() # not Apple
391346
DEFS ${XRAY_COMMON_DEFINITIONS}
392347
OBJECT_LIBS RTXrayBASIC
393348
PARENT_TARGET xray)
394-
# Profiler Mode runtime
395-
add_compiler_rt_runtime(clang_rt.xray-profiling
396-
STATIC
397-
ARCHS ${arch}
398-
CFLAGS ${XRAY_CFLAGS}
399-
LINK_FLAGS ${XRAY_LINK_FLAGS}
400-
LINK_LIBS ${XRAY_LINK_LIBS}
401-
DEFS ${XRAY_COMMON_DEFINITIONS}
402-
OBJECT_LIBS RTXrayPROFILING
403-
PARENT_TARGET xray)
404-
405-
if (${arch} IN_LIST XRAY_DSO_SUPPORTED_ARCH)
406-
# TODO: Only implemented for X86 at the moment
407-
add_compiler_rt_object_libraries(RTXrayDSO
408-
ARCHS ${arch}
409-
SOURCES ${XRAY_DSO_SOURCES} ${${arch}_DSO_SOURCES}
410-
ADDITIONAL_HEADERS ${XRAY_IMPL_HEADERS}
411-
CFLAGS ${XRAY_CFLAGS}
412-
DEFS ${XRAY_COMMON_DEFINITIONS_DSO}
413-
DEPS ${XRAY_DEPS})
414-
# DSO runtime archive
415-
add_compiler_rt_runtime(clang_rt.xray-dso
416-
STATIC
417-
ARCHS ${arch}
418-
CFLAGS ${XRAY_CFLAGS}
419-
LINK_FLAGS ${XRAY_LINK_FLAGS}
420-
LINK_LIBS ${XRAY_LINK_LIBS}
421-
DEFS ${XRAY_COMMON_DEFINITIONS}
422-
OBJECT_LIBS RTXrayDSO
423-
PARENT_TARGET xray)
424-
endif()
349+
# Profiler Mode runtime
350+
add_compiler_rt_runtime(clang_rt.xray-profiling
351+
STATIC
352+
ARCHS ${arch}
353+
CFLAGS ${XRAY_CFLAGS}
354+
LINK_FLAGS ${XRAY_LINK_FLAGS}
355+
LINK_LIBS ${XRAY_LINK_LIBS}
356+
DEFS ${XRAY_COMMON_DEFINITIONS}
357+
OBJECT_LIBS RTXrayPROFILING
358+
PARENT_TARGET xray)
425359
endforeach()
426360
endif() # not Apple
427361

0 commit comments

Comments
 (0)