Skip to content

Commit cb9700e

Browse files
Revert "[XRay][AArch64] Support -fxray-shared" (#115022)
Reverts #114431
1 parent 616aff1 commit cb9700e

File tree

11 files changed

+28
-47
lines changed

11 files changed

+28
-47
lines changed

clang/lib/Driver/XRayArgs.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,8 @@ XRayArgs::XRayArgs(const ToolChain &TC, const ArgList &Args) {
6767
false)) {
6868
XRayShared = true;
6969

70-
// Certain targets support DSO instrumentation
71-
switch (Triple.getArch()) {
72-
case llvm::Triple::aarch64:
73-
case llvm::Triple::x86_64:
74-
break;
75-
default:
70+
// DSO instrumentation is currently limited to x86_64
71+
if (Triple.getArch() != llvm::Triple::x86_64) {
7672
D.Diag(diag::err_drv_unsupported_opt_for_target)
7773
<< "-fxray-shared" << Triple.str();
7874
}

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

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
1-
// Check supported targets
21
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fPIC -fxray-instrument -fxray-shared -c %s -o /dev/null 2>&1 | FileCheck %s
3-
// RUN: %clang -### --target=aarch64-unknown-linux-gnu -fPIC -fxray-instrument -fxray-shared -c %s -o /dev/null 2>&1 | FileCheck %s
4-
5-
// Check unsupported targets
6-
// RUN: not %clang -### --target=arm-unknown-linux-gnu -fPIC -fxray-instrument -fxray-shared -c %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR-TARGET
7-
// RUN: not %clang -### --target=mips-unknown-linux-gnu -fPIC -fxray-instrument -fxray-shared -c %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR-TARGET
8-
// RUN: not %clang -### --target=loongarch64-unknown-linux-gnu -fPIC -fxray-instrument -fxray-shared -c %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR-TARGET
9-
// RUN: not %clang -### --target=hexagon-unknown-linux-gnu -fPIC -fxray-instrument -fxray-shared -c %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR-TARGET
10-
// RUN: not %clang -### --target=powerpc64le-unknown-linux-gnu -fPIC -fxray-instrument -fxray-shared -c %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR-TARGET
11-
12-
// Check PIC requirement
132
// RUN: %clang -### --target=x86_64-unknown-linux-gnu -fpic -fxray-instrument -fxray-shared -c %s -o /dev/null 2>&1 | FileCheck %s
143
// RUN: not %clang -### --target=x86_64-unknown-linux-gnu -fno-PIC -fxray-instrument -fxray-shared -c %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR-PIC
154
// RUN: not %clang -### --target=x86_64-unknown-linux-gnu -fno-pic -fxray-instrument -fxray-shared -c %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR-PIC
5+
166
// On 64 bit darwin, PIC is always enabled
177
// RUN: %clang -### --target=x86_64-apple-darwin -fxray-instrument -fxray-shared -c %s -o /dev/null 2>&1 | FileCheck %s
188

9+
// Check unsupported targets
10+
// RUN: not %clang -### --target=aarch64-pc-freebsd -fPIC -fxray-instrument -fxray-shared -c %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR-TARGET
11+
// RUN: not %clang -### --target=arm64-apple-macos -fPIC -fxray-instrument -fxray-shared -c %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR-TARGET
12+
1913
// CHECK: "-cc1" {{.*}}"-fxray-instrument" {{.*}}"-fxray-shared"
2014
// ERR-TARGET: error: unsupported option '-fxray-shared' for target
2115
// ERR-PIC: error: option '-fxray-shared' cannot be specified without '-fPIC'

compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ 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} ${ARM64})
107+
set(ALL_XRAY_DSO_SUPPORTED_ARCH ${X86_64})
108108
set(ALL_SHADOWCALLSTACK_SUPPORTED_ARCH ${ARM64})
109109

110110
if (UNIX)

compiler-rt/lib/xray/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@ set(aarch64_SOURCES
5656
xray_trampoline_AArch64.S
5757
)
5858

59-
set(aarch64_DSO_SOURCES
60-
xray_trampoline_AArch64.S
61-
)
62-
6359
set(loongarch64_SOURCES
6460
xray_loongarch64.cpp
6561
xray_trampoline_loongarch64.S

compiler-rt/lib/xray/xray_trampoline_AArch64.S

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,6 @@
2626
ldp x1, x2, [sp], #16
2727
.endm
2828

29-
.macro LOAD_HANDLER_ADDR reg handler
30-
#if !defined(XRAY_PIC)
31-
adrp \reg, ASM_SYMBOL(\handler)
32-
ldr \reg, [\reg, :lo12:ASM_SYMBOL(\handler)]
33-
#else
34-
adrp \reg, :got:ASM_SYMBOL(\handler)
35-
ldr \reg, [\reg, :got_lo12:ASM_SYMBOL(\handler)]
36-
ldr \reg, [\reg]
37-
#endif
38-
.endm
39-
4029
.text
4130
.p2align 2
4231
.global ASM_SYMBOL(__xray_FunctionEntry)
@@ -53,7 +42,8 @@ ASM_SYMBOL(__xray_FunctionEntry):
5342
SAVE_REGISTERS
5443

5544
// Load the handler function pointer.
56-
LOAD_HANDLER_ADDR x2, _ZN6__xray19XRayPatchedFunctionE
45+
adrp x2, ASM_SYMBOL(_ZN6__xray19XRayPatchedFunctionE)
46+
ldr x2, [x2, #:lo12:ASM_SYMBOL(_ZN6__xray19XRayPatchedFunctionE)]
5747
cbz x2, 1f
5848
// Set w0 to the function ID (w17). Set x1 to XRayEntryType::ENTRY = 0.
5949
mov w0, w17
@@ -79,7 +69,8 @@ ASM_SYMBOL(__xray_FunctionExit):
7969
SAVE_REGISTERS
8070

8171
// Load the handler function pointer into x2.
82-
LOAD_HANDLER_ADDR x2, _ZN6__xray19XRayPatchedFunctionE
72+
adrp x2, ASM_SYMBOL(_ZN6__xray19XRayPatchedFunctionE)
73+
ldr x2, [x2, #:lo12:ASM_SYMBOL(_ZN6__xray19XRayPatchedFunctionE)]
8374
cbz x2, 1f
8475
// Set w0 to the function ID (w17). Set x1 to XRayEntryType::EXIT = 1.
8576
mov w0, w17
@@ -105,7 +96,8 @@ ASM_SYMBOL(__xray_FunctionTailExit):
10596
// Save the registers which may be modified by the handler function.
10697
SAVE_REGISTERS
10798
// Load the handler function pointer into x2.
108-
LOAD_HANDLER_ADDR x2, _ZN6__xray19XRayPatchedFunctionE
99+
adrp x2, ASM_SYMBOL(_ZN6__xray19XRayPatchedFunctionE)
100+
ldr x2, [x2, #:lo12:ASM_SYMBOL(_ZN6__xray19XRayPatchedFunctionE)]
109101
cbz x2, 1f
110102
// Set w0 to the function ID (w17). Set x1 to XRayEntryType::TAIL = 2.
111103
mov w0, w17
@@ -126,11 +118,13 @@ ASM_SYMBOL(__xray_ArgLoggerEntry):
126118
// Push the registers which may be modified by the handler function.
127119
SAVE_REGISTERS
128120

129-
LOAD_HANDLER_ADDR x8, _ZN6__xray13XRayArgLoggerE
121+
adrp x8, ASM_SYMBOL(_ZN6__xray13XRayArgLoggerE)
122+
ldr x8, [x8, #:lo12:ASM_SYMBOL(_ZN6__xray13XRayArgLoggerE)]
130123
cbnz x8, 2f
131124

132125
// Load the handler function pointer.
133-
LOAD_HANDLER_ADDR x8, _ZN6__xray19XRayPatchedFunctionE
126+
adrp x8, ASM_SYMBOL(_ZN6__xray19XRayPatchedFunctionE)
127+
ldr x8, [x8, #:lo12:ASM_SYMBOL(_ZN6__xray19XRayPatchedFunctionE)]
134128
cbz x8, 1f
135129

136130
2:
@@ -150,7 +144,8 @@ ASM_SIZE(__xray_ArgLoggerEntry)
150144
ASM_TYPE_FUNCTION(__xray_CustomEvent)
151145
ASM_SYMBOL(__xray_CustomEvent):
152146
SAVE_REGISTERS
153-
LOAD_HANDLER_ADDR x8, _ZN6__xray22XRayPatchedCustomEventE
147+
adrp x8, ASM_SYMBOL(_ZN6__xray22XRayPatchedCustomEventE)
148+
ldr x8, [x8, #:lo12:ASM_SYMBOL(_ZN6__xray22XRayPatchedCustomEventE)]
154149
cbz x8, 1f
155150
blr x8
156151
1:
@@ -162,7 +157,8 @@ ASM_SIZE(__xray_CustomEvent)
162157
ASM_TYPE_FUNCTION(__xray_TypedEvent)
163158
ASM_SYMBOL(__xray_TypedEvent):
164159
SAVE_REGISTERS
165-
LOAD_HANDLER_ADDR x8, _ZN6__xray21XRayPatchedTypedEventE
160+
adrp x8, ASM_SYMBOL(_ZN6__xray21XRayPatchedTypedEventE)
161+
ldr x8, [x8, #:lo12:ASM_SYMBOL(_ZN6__xray21XRayPatchedTypedEventE)]
166162
cbz x8, 1f
167163
blr x8
168164
1:

compiler-rt/test/xray/TestCases/Posix/basic-mode-dso.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
// RUN: %llvm_xray account --format=csv --sort=funcid "`ls basic-mode-dso-* | head -1`" | FileCheck --check-prefix=ACCOUNT %s
99
// RUN: rm basic-mode-dso-*
1010

11-
// REQUIRES: target={{(aarch64|x86_64)-.*}}
12-
// REQUIRES: built-in-llvm-tree
11+
// REQUIRES: target=x86_64{{.*}}
1312

1413
//--- main.cpp
1514

compiler-rt/test/xray/TestCases/Posix/clang-xray-shared.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// RUN: %clangxx -fxray-instrument %s -shared -o %t.so
77
// RUN: llvm-nm %t.so | FileCheck %s --check-prefix DISABLED
88
//
9-
// REQUIRES: target={{(aarch64|x86_64)-.*}}
9+
// REQUIRES: target=x86_64{{.*}}
1010

1111
[[clang::xray_always_instrument]] int always_instrumented() { return 42; }
1212

compiler-rt/test/xray/TestCases/Posix/dlopen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88
// RUN: XRAY_OPTIONS="patch_premain=true" %run %t/main.o %t/testlib.so 2>&1 | FileCheck %s
99

10-
// REQUIRES: target={{(aarch64|x86_64)-.*}}
10+
// REQUIRES: target=x86_64{{.*}}
1111

1212
//--- main.cpp
1313

compiler-rt/test/xray/TestCases/Posix/dso-dep-chains.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
//
1818
// RUN: XRAY_OPTIONS="patch_premain=true" %run %t/main.o %t/testlibd.so %t/testlibe.so 2>&1 | FileCheck %s
1919

20-
// REQUIRES: target={{(aarch64|x86_64)-.*}}
20+
// REQUIRES: target=x86_64{{.*}}
2121

2222
//--- main.cpp
2323

compiler-rt/test/xray/TestCases/Posix/patch-premain-dso.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
// RUN: XRAY_OPTIONS="patch_premain=true,verbosity=1" %run %t/main.o 2>&1 | FileCheck %s
88

9-
// REQUIRES: target={{(aarch64|x86_64)-.*}}
9+
// REQUIRES: target=x86_64{{.*}}
1010

1111
//--- main.cpp
1212

compiler-rt/test/xray/TestCases/Posix/patching-unpatching-dso.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
// RUN: XRAY_OPTIONS="patch_premain=false" %run %t/main.o 2>&1 | FileCheck %s
1010

11-
// REQUIRES: target={{(aarch64|x86_64)-.*}}
11+
// REQUIRES: target=x86_64{{.*}}
1212

1313
//--- main.cpp
1414

0 commit comments

Comments
 (0)