[compiler-rt] r283421 - [compiler-rt][XRay][NFC] clang-format XRay sources

Dean Michael Berris via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 6 00:09:41 PDT 2016


Author: dberris
Date: Thu Oct  6 02:09:40 2016
New Revision: 283421

URL: http://llvm.org/viewvc/llvm-project?rev=283421&view=rev
Log:
[compiler-rt][XRay][NFC] clang-format XRay sources

Modified:
    compiler-rt/trunk/lib/xray/xray_arm.cc
    compiler-rt/trunk/lib/xray/xray_inmemory_log.cc
    compiler-rt/trunk/lib/xray/xray_interface.cc
    compiler-rt/trunk/lib/xray/xray_interface_internal.h
    compiler-rt/trunk/lib/xray/xray_x86_64.cc

Modified: compiler-rt/trunk/lib/xray/xray_arm.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/xray/xray_arm.cc?rev=283421&r1=283420&r2=283421&view=diff
==============================================================================
--- compiler-rt/trunk/lib/xray/xray_arm.cc (original)
+++ compiler-rt/trunk/lib/xray/xray_arm.cc Thu Oct  6 02:09:40 2016
@@ -12,20 +12,19 @@
 // Implementation of ARM-specific routines (32-bit).
 //
 //===----------------------------------------------------------------------===//
-#include "xray_interface_internal.h"
 #include "sanitizer_common/sanitizer_common.h"
+#include "xray_interface_internal.h"
 #include <atomic>
 #include <cassert>
 
 namespace __xray {
 
 // The machine codes for some instructions used in runtime patching.
-enum class PatchOpcodes : uint32_t
-{
+enum class PatchOpcodes : uint32_t {
   PO_PushR0Lr = 0xE92D4001, // PUSH {r0, lr}
-  PO_BlxIp = 0xE12FFF3C, // BLX ip
-  PO_PopR0Lr = 0xE8BD4001, // POP {r0, lr}
-  PO_B20 = 0xEA000005 // B #20
+  PO_BlxIp = 0xE12FFF3C,    // BLX ip
+  PO_PopR0Lr = 0xE8BD4001,  // POP {r0, lr}
+  PO_B20 = 0xEA000005       // B #20
 };
 
 // 0xUUUUWXYZ -> 0x000W0XYZ
@@ -41,15 +40,15 @@ inline static uint32_t getMovtMask(const
 // Writes the following instructions:
 //   MOVW R<regNo>, #<lower 16 bits of the |Value|>
 //   MOVT R<regNo>, #<higher 16 bits of the |Value|>
-inline static uint32_t* write32bitLoadReg(uint8_t regNo, uint32_t* Address,
-    const uint32_t Value) {
-  //This is a fatal error: we cannot just report it and continue execution.
+inline static uint32_t *write32bitLoadReg(uint8_t regNo, uint32_t *Address,
+                                          const uint32_t Value) {
+  // This is a fatal error: we cannot just report it and continue execution.
   assert(regNo <= 15 && "Register number must be 0 to 15.");
   // MOVW R, #0xWXYZ in machine code is 0xE30WRXYZ
-  *Address = (0xE3000000 | (uint32_t(regNo)<<12) | getMovwMask(Value));
+  *Address = (0xE3000000 | (uint32_t(regNo) << 12) | getMovwMask(Value));
   Address++;
   // MOVT R, #0xWXYZ in machine code is 0xE34WRXYZ
-  *Address = (0xE3400000 | (uint32_t(regNo)<<12) | getMovtMask(Value));
+  *Address = (0xE3400000 | (uint32_t(regNo) << 12) | getMovtMask(Value));
   return Address + 1;
 }
 

Modified: compiler-rt/trunk/lib/xray/xray_inmemory_log.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/xray/xray_inmemory_log.cc?rev=283421&r1=283420&r2=283421&view=diff
==============================================================================
--- compiler-rt/trunk/lib/xray/xray_inmemory_log.cc (original)
+++ compiler-rt/trunk/lib/xray/xray_inmemory_log.cc Thu Oct  6 02:09:40 2016
@@ -26,11 +26,11 @@
 #include <unistd.h>
 
 #if defined(__x86_64__)
-  #include <x86intrin.h>
+#include <x86intrin.h>
 #elif defined(__arm__)
-  static const int64_t NanosecondsPerSecond = 1000LL*1000*1000;
+static const int64_t NanosecondsPerSecond = 1000LL * 1000 * 1000;
 #else
-  #error "Unsupported CPU Architecture"
+#error "Unsupported CPU Architecture"
 #endif /* CPU architecture */
 
 #include "sanitizer_common/sanitizer_libc.h"
@@ -197,7 +197,7 @@ void __xray_InMemoryRawLog(int32_t FuncI
     //   one TSC tick is 1 nanosecond.
     CPUFrequency = NanosecondsPerSecond;
 #else
-  #error "Unsupported CPU Architecture"
+#error "Unsupported CPU Architecture"
 #endif /* CPU architecture */
 
     // Since we're here, we get to write the header. We set it up so that the
@@ -237,8 +237,7 @@ void __xray_InMemoryRawLog(int32_t FuncI
   {
     timespec TS;
     int result = clock_gettime(CLOCK_REALTIME, &TS);
-    if(result != 0)
-    {
+    if (result != 0) {
       Report("clock_gettime() returned %d, errno=%d.", result, int(errno));
       TS.tv_sec = 0;
       TS.tv_nsec = 0;
@@ -247,7 +246,7 @@ void __xray_InMemoryRawLog(int32_t FuncI
     R.CPU = 0;
   }
 #else
-  #error "Unsupported CPU Architecture"
+#error "Unsupported CPU Architecture"
 #endif /* CPU architecture */
   R.TId = TId;
   R.Type = Type;

Modified: compiler-rt/trunk/lib/xray/xray_interface.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/xray/xray_interface.cc?rev=283421&r1=283420&r2=283421&view=diff
==============================================================================
--- compiler-rt/trunk/lib/xray/xray_interface.cc (original)
+++ compiler-rt/trunk/lib/xray/xray_interface.cc Thu Oct  6 02:09:40 2016
@@ -27,12 +27,13 @@
 namespace __xray {
 
 #if defined(__x86_64__)
-  // FIXME: The actual length is 11 bytes. Why was length 12 passed to mprotect() ?
-  static const int16_t cSledLength = 12;
+// FIXME: The actual length is 11 bytes. Why was length 12 passed to mprotect()
+// ?
+static const int16_t cSledLength = 12;
 #elif defined(__arm__)
-  static const int16_t cSledLength = 28;
+static const int16_t cSledLength = 28;
 #else
-  #error "Unsupported CPU Architecture"
+#error "Unsupported CPU Architecture"
 #endif /* CPU architecture */
 
 // This is the function to call when we encounter the entry or exit sleds.
@@ -136,7 +137,7 @@ XRayPatchingStatus ControlPatching(bool
     return XRayPatchingStatus::NOT_INITIALIZED;
 
   const uint64_t PageSize = GetPageSizeCached();
-  if((PageSize == 0) || ( (PageSize & (PageSize-1)) != 0) ) {
+  if ((PageSize == 0) || ((PageSize & (PageSize - 1)) != 0)) {
     Report("System page size is not a power of two: %lld", PageSize);
     return XRayPatchingStatus::FAILED;
   }
@@ -156,9 +157,9 @@ XRayPatchingStatus ControlPatching(bool
     // While we're here, we should patch the nop sled. To do that we mprotect
     // the page containing the function to be writeable.
     void *PageAlignedAddr =
-        reinterpret_cast<void *>(Sled.Address & ~(PageSize-1));
-    std::size_t MProtectLen =
-        (Sled.Address + cSledLength) - reinterpret_cast<uint64_t>(PageAlignedAddr);
+        reinterpret_cast<void *>(Sled.Address & ~(PageSize - 1));
+    std::size_t MProtectLen = (Sled.Address + cSledLength) -
+                              reinterpret_cast<uint64_t>(PageAlignedAddr);
     MProtectHelper Protector(PageAlignedAddr, MProtectLen);
     if (Protector.MakeWriteable() == -1) {
       printf("Failed mprotect: %d\n", errno);
@@ -166,7 +167,7 @@ XRayPatchingStatus ControlPatching(bool
     }
 
     bool Success = false;
-    switch(Sled.Kind) {
+    switch (Sled.Kind) {
     case XRayEntryType::ENTRY:
       Success = patchFunctionEntry(Enable, FuncId, Sled);
       break;

Modified: compiler-rt/trunk/lib/xray/xray_interface_internal.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/xray/xray_interface_internal.h?rev=283421&r1=283420&r2=283421&view=diff
==============================================================================
--- compiler-rt/trunk/lib/xray/xray_interface_internal.h (original)
+++ compiler-rt/trunk/lib/xray/xray_interface_internal.h Thu Oct  6 02:09:40 2016
@@ -15,8 +15,8 @@
 #ifndef XRAY_INTERFACE_INTERNAL_H
 #define XRAY_INTERFACE_INTERNAL_H
 
-#include "xray/xray_interface.h"
 #include "sanitizer_common/sanitizer_platform.h"
+#include "xray/xray_interface.h"
 #include <cstddef>
 #include <cstdint>
 
@@ -36,10 +36,9 @@ struct XRaySledEntry {
   unsigned char AlwaysInstrument;
   unsigned char Padding[6]; // Need 16 bytes
 #else
-	#error "Unsupported word size."
+#error "Unsupported word size."
 #endif
 };
-
 }
 
 namespace __xray {
@@ -49,8 +48,10 @@ struct XRaySledMap {
   size_t Entries;
 };
 
-bool patchFunctionEntry(const bool Enable, const uint32_t FuncId, const XRaySledEntry& Sled);
-bool patchFunctionExit(const bool Enable, const uint32_t FuncId, const XRaySledEntry& Sled);
+bool patchFunctionEntry(const bool Enable, const uint32_t FuncId,
+                        const XRaySledEntry &Sled);
+bool patchFunctionExit(const bool Enable, const uint32_t FuncId,
+                       const XRaySledEntry &Sled);
 
 } // namespace __xray
 

Modified: compiler-rt/trunk/lib/xray/xray_x86_64.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/xray/xray_x86_64.cc?rev=283421&r1=283420&r2=283421&view=diff
==============================================================================
--- compiler-rt/trunk/lib/xray/xray_x86_64.cc (original)
+++ compiler-rt/trunk/lib/xray/xray_x86_64.cc Thu Oct  6 02:09:40 2016
@@ -1,5 +1,5 @@
-#include "xray_interface_internal.h"
 #include "sanitizer_common/sanitizer_common.h"
+#include "xray_interface_internal.h"
 #include <atomic>
 #include <cstdint>
 #include <limits>
@@ -15,8 +15,8 @@ static constexpr uint8_t RetOpCode = 0xc
 static constexpr int64_t MinOffset{std::numeric_limits<int32_t>::min()};
 static constexpr int64_t MaxOffset{std::numeric_limits<int32_t>::max()};
 
-bool patchFunctionEntry(const bool Enable, const uint32_t FuncId, const XRaySledEntry& Sled)
-{
+bool patchFunctionEntry(const bool Enable, const uint32_t FuncId,
+                        const XRaySledEntry &Sled) {
   // Here we do the dance of replacing the following sled:
   //
   // xray_sled_n:
@@ -39,9 +39,8 @@ bool patchFunctionEntry(const bool Enabl
   //
   // Prerequisite is to compute the relative offset to the
   // __xray_FunctionEntry function's address.
-  int64_t TrampolineOffset =
-      reinterpret_cast<int64_t>(__xray_FunctionEntry) -
-      (static_cast<int64_t>(Sled.Address) + 11);
+  int64_t TrampolineOffset = reinterpret_cast<int64_t>(__xray_FunctionEntry) -
+                             (static_cast<int64_t>(Sled.Address) + 11);
   if (TrampolineOffset < MinOffset || TrampolineOffset > MaxOffset) {
     Report("XRay Entry trampoline (%p) too far from sled (%p); distance = "
            "%ld\n",
@@ -65,8 +64,8 @@ bool patchFunctionEntry(const bool Enabl
   return true;
 }
 
-bool patchFunctionExit(const bool Enable, const uint32_t FuncId, const XRaySledEntry& Sled)
-{
+bool patchFunctionExit(const bool Enable, const uint32_t FuncId,
+                       const XRaySledEntry &Sled) {
   // Here we do the dance of replacing the following sled:
   //
   // xray_sled_n:
@@ -87,9 +86,8 @@ bool patchFunctionExit(const bool Enable
   //
   // Prerequisite is to compute the relative offset fo the
   // __xray_FunctionExit function's address.
-  int64_t TrampolineOffset =
-      reinterpret_cast<int64_t>(__xray_FunctionExit) -
-      (static_cast<int64_t>(Sled.Address) + 11);
+  int64_t TrampolineOffset = reinterpret_cast<int64_t>(__xray_FunctionExit) -
+                             (static_cast<int64_t>(Sled.Address) + 11);
   if (TrampolineOffset < MinOffset || TrampolineOffset > MaxOffset) {
     Report("XRay Exit trampoline (%p) too far from sled (%p); distance = "
            "%ld\n",




More information about the llvm-commits mailing list