Skip to content

Commit 9bce1e7

Browse files
author
Serge Rogatch
committedJan 19, 2017
[XRay][Arm] Enable back XRay testing on Arm32 and fix the failing tests
Summary: Testing of XRay was occasionally disabled on 32-bit Arm targets (someone assumed that XRay was supported on 64-bit targets only). This patch should fix that problem. Also here the instruction&data cache incoherency problem is fixed, because it may be causing a test to fail. This patch is one of a series: see also - https://reviews.llvm.org/D28624 Reviewers: dberris, rengolin Reviewed By: rengolin Subscribers: llvm-commits, aemerson, rengolin, dberris, iid_iunknown Differential Revision: https://reviews.llvm.org/D28623 llvm-svn: 292517
1 parent f83d2a2 commit 9bce1e7

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed
 

‎compiler-rt/lib/xray/xray_arm.cc

+6-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include <atomic>
2020
#include <cassert>
2121

22+
extern "C" void __clear_cache(void* start, void* end);
23+
2224
namespace __xray {
2325

2426
uint64_t cycleFrequency() XRAY_NEVER_INSTRUMENT {
@@ -116,15 +118,16 @@ inline static bool patchSled(const bool Enable, const uint32_t FuncId,
116118
// B #20
117119

118120
uint32_t *FirstAddress = reinterpret_cast<uint32_t *>(Sled.Address);
121+
uint32_t *CurAddress = FirstAddress + 1;
119122
if (Enable) {
120-
uint32_t *CurAddress = FirstAddress + 1;
121123
CurAddress =
122124
Write32bitLoadR0(CurAddress, reinterpret_cast<uint32_t>(FuncId));
123125
CurAddress =
124126
Write32bitLoadIP(CurAddress, reinterpret_cast<uint32_t>(TracingHook));
125127
*CurAddress = uint32_t(PatchOpcodes::PO_BlxIp);
126128
CurAddress++;
127129
*CurAddress = uint32_t(PatchOpcodes::PO_PopR0Lr);
130+
CurAddress++;
128131
std::atomic_store_explicit(
129132
reinterpret_cast<std::atomic<uint32_t> *>(FirstAddress),
130133
uint32_t(PatchOpcodes::PO_PushR0Lr), std::memory_order_release);
@@ -133,6 +136,8 @@ inline static bool patchSled(const bool Enable, const uint32_t FuncId,
133136
reinterpret_cast<std::atomic<uint32_t> *>(FirstAddress),
134137
uint32_t(PatchOpcodes::PO_B20), std::memory_order_release);
135138
}
139+
__clear_cache(reinterpret_cast<char*>(FirstAddress),
140+
reinterpret_cast<char*>(CurAddress));
136141
return true;
137142
}
138143

‎compiler-rt/test/xray/lit.cfg

+7-1
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,14 @@ config.substitutions.append(
3030
# Default test suffixes.
3131
config.suffixes = ['.c', '.cc', '.cpp']
3232

33-
if config.host_os not in ['Linux'] or config.host_arch.find('64') == -1:
33+
if config.host_os not in ['Linux']:
3434
config.unsupported = True
35+
elif '64' not in config.host_arch:
36+
if 'arm' in config.host_arch:
37+
if '-mthumb' in config.target_cflags:
38+
config.unsupported = True
39+
else:
40+
config.unsupported = True
3541

3642
# Allow tests to use REQUIRES=stable-runtime. For use when you cannot use XFAIL
3743
# e.g. because the test sometimes passes, sometimes fails.

0 commit comments

Comments
 (0)
Please sign in to comment.