1313// ===----------------------------------------------------------------------===//
1414
1515#include " xray_interface_internal.h"
16- #include " llvm/Support/ErrorHandling.h"
1716
1817#include < cinttypes>
1918#include < cstdio>
@@ -154,8 +153,8 @@ namespace {
154153
155154bool isObjectLoaded (int32_t ObjId) {
156155 SpinMutexLock Guard (&XRayInstrMapMutex);
157- if (ObjId < 0 ||
158- ObjId >= atomic_load (&XRayNumObjects, memory_order_acquire)) {
156+ if (ObjId < 0 || static_cast < uint32_t >(ObjId) >=
157+ atomic_load (&XRayNumObjects, memory_order_acquire)) {
159158 return false ;
160159 }
161160 return XRayInstrMaps[ObjId].Loaded ;
@@ -166,28 +165,24 @@ bool patchSled(const XRaySledEntry &Sled, bool Enable, int32_t FuncId,
166165 bool Success = false ;
167166 switch (Sled.Kind ) {
168167 case XRayEntryType::ENTRY:
169- Success =
170- patchFunctionEntry (Enable, FuncId, Sled, Trampolines. EntryTrampoline );
168+ Success = patchFunctionEntry (Enable, FuncId, Sled, Trampolines,
169+ /* LogArgs= */ false );
171170 break ;
172171 case XRayEntryType::EXIT:
173- Success =
174- patchFunctionExit (Enable, FuncId, Sled, Trampolines.ExitTrampoline );
172+ Success = patchFunctionExit (Enable, FuncId, Sled, Trampolines);
175173 break ;
176174 case XRayEntryType::TAIL:
177- Success = patchFunctionTailExit (Enable, FuncId, Sled,
178- Trampolines.TailExitTrampoline );
175+ Success = patchFunctionTailExit (Enable, FuncId, Sled, Trampolines);
179176 break ;
180177 case XRayEntryType::LOG_ARGS_ENTRY:
181- Success =
182- patchFunctionEntry (Enable, FuncId, Sled, Trampolines. LogArgsTrampoline );
178+ Success = patchFunctionEntry (Enable, FuncId, Sled, Trampolines,
179+ /* LogArgs= */ true );
183180 break ;
184181 case XRayEntryType::CUSTOM_EVENT:
185- Success = patchCustomEvent (Enable, FuncId, Sled,
186- Trampolines.CustomEventTrampoline );
182+ Success = patchCustomEvent (Enable, FuncId, Sled);
187183 break ;
188184 case XRayEntryType::TYPED_EVENT:
189- Success =
190- patchTypedEvent (Enable, FuncId, Sled, Trampolines.TypedEventTrampoline );
185+ Success = patchTypedEvent (Enable, FuncId, Sled);
191186 break ;
192187 default :
193188 Report (" Unsupported sled kind '%" PRIu64 " ' @%04x\n " , Sled.Address ,
@@ -236,8 +231,8 @@ XRayPatchingStatus patchFunction(int32_t FuncId, int32_t ObjId,
236231 XRaySledMap InstrMap;
237232 {
238233 SpinMutexLock Guard (&XRayInstrMapMutex);
239- if (ObjId < 0 ||
240- ObjId >= atomic_load (&XRayNumObjects, memory_order_acquire)) {
234+ if (ObjId < 0 || static_cast < uint32_t >(ObjId) >=
235+ atomic_load (&XRayNumObjects, memory_order_acquire)) {
241236 Report (" Unable to patch function: invalid sled map index: %d" , ObjId);
242237 return XRayPatchingStatus::FAILED;
243238 }
@@ -296,8 +291,8 @@ XRayPatchingStatus controlPatchingObjectUnchecked(bool Enable, int32_t ObjId) {
296291 XRaySledMap InstrMap;
297292 {
298293 SpinMutexLock Guard (&XRayInstrMapMutex);
299- if (ObjId < 0 ||
300- ObjId >= atomic_load (&XRayNumObjects, memory_order_acquire)) {
294+ if (ObjId < 0 || static_cast < uint32_t >(ObjId) >=
295+ atomic_load (&XRayNumObjects, memory_order_acquire)) {
301296 Report (" Unable to patch functions: invalid sled map index: %d\n " , ObjId);
302297 return XRayPatchingStatus::FAILED;
303298 }
@@ -411,9 +406,7 @@ XRayPatchingStatus controlPatching(bool Enable) XRAY_NEVER_INSTRUMENT {
411406 CombinedStatus = NOT_INITIALIZED;
412407 break ;
413408 case ONGOING:
414- llvm_unreachable (" Status ONGOING should not appear at this point" );
415- default :
416- llvm_unreachable (" Unhandled patching status" );
409+ UNREACHABLE (" Status ONGOING should not appear at this point" );
417410 }
418411 }
419412 return CombinedStatus;
@@ -442,8 +435,8 @@ XRayPatchingStatus mprotectAndPatchFunction(int32_t FuncId, int32_t ObjId,
442435 XRaySledMap InstrMap;
443436 {
444437 SpinMutexLock Guard (&XRayInstrMapMutex);
445- if (ObjId < 0 ||
446- ObjId >= atomic_load (&XRayNumObjects, memory_order_acquire)) {
438+ if (ObjId < 0 || static_cast < uint32_t >(ObjId) >=
439+ atomic_load (&XRayNumObjects, memory_order_acquire)) {
447440 Report (" Unable to patch function: invalid sled map index: %d\n " , ObjId);
448441 return XRayPatchingStatus::FAILED;
449442 }
@@ -637,7 +630,7 @@ uintptr_t __xray_function_address_in_object(int32_t FuncId, int32_t ObjId)
637630 {
638631 SpinMutexLock Guard (&XRayInstrMapMutex);
639632 auto count = atomic_load (&XRayNumObjects, memory_order_acquire);
640- if (ObjId < 0 || ObjId >= count) {
633+ if (ObjId < 0 || static_cast < uint32_t >( ObjId) >= count) {
641634 Report (" Unable to determine function address: invalid sled map index %d "
642635 " (size is %d)\n " ,
643636 ObjId, (int )count);
@@ -667,7 +660,8 @@ size_t __xray_max_function_id() XRAY_NEVER_INSTRUMENT {
667660
668661size_t __xray_max_function_id_in_object (int32_t ObjId) XRAY_NEVER_INSTRUMENT {
669662 SpinMutexLock Guard (&XRayInstrMapMutex);
670- if (ObjId < 0 || ObjId >= atomic_load (&XRayNumObjects, memory_order_acquire))
663+ if (ObjId < 0 || static_cast <uint32_t >(ObjId) >=
664+ atomic_load (&XRayNumObjects, memory_order_acquire))
671665 return 0 ;
672666 return XRayInstrMaps[ObjId].Functions ;
673667}
0 commit comments