Index: lib/xray/xray_AArch64.cc =================================================================== --- lib/xray/xray_AArch64.cc +++ lib/xray/xray_AArch64.cc @@ -19,6 +19,8 @@ #include #include +extern "C" void __clear_cache(void* start, void* end); + namespace __xray { uint64_t cycleFrequency() XRAY_NEVER_INSTRUMENT { @@ -75,8 +77,8 @@ // B #32 uint32_t *FirstAddress = reinterpret_cast(Sled.Address); + uint32_t *CurAddress = FirstAddress + 1; if (Enable) { - uint32_t *CurAddress = FirstAddress + 1; *CurAddress = uint32_t(PatchOpcodes::PO_LdrW0_12); CurAddress++; *CurAddress = uint32_t(PatchOpcodes::PO_LdrX16_12); @@ -88,6 +90,7 @@ *reinterpret_cast(CurAddress) = TracingHook; CurAddress += 2; *CurAddress = uint32_t(PatchOpcodes::PO_LdpX0X30SP_16); + CurAddress++; std::atomic_store_explicit( reinterpret_cast *>(FirstAddress), uint32_t(PatchOpcodes::PO_StpX0X30SP_m16e), std::memory_order_release); @@ -96,6 +99,8 @@ reinterpret_cast *>(FirstAddress), uint32_t(PatchOpcodes::PO_B32), std::memory_order_release); } + __clear_cache(reinterpret_cast(FirstAddress), + reinterpret_cast(CurAddress)); return true; } Index: test/xray/TestCases/Linux/patching-unpatching.cc =================================================================== --- test/xray/TestCases/Linux/patching-unpatching.cc +++ test/xray/TestCases/Linux/patching-unpatching.cc @@ -3,7 +3,6 @@ // // RUN: %clangxx_xray -fxray-instrument -std=c++11 %s -o %t // RUN: XRAY_OPTIONS="patch_premain=false" %run %t 2>&1 | FileCheck %s -// REQUIRES: stable-runtime #include "xray/xray_interface.h"