[llvm] r295994 - [AddressSanitizer] Add PS4 offset

Filipe Cabecinhas via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 23 09:10:29 PST 2017


Author: filcab
Date: Thu Feb 23 11:10:28 2017
New Revision: 295994

URL: http://llvm.org/viewvc/llvm-project?rev=295994&view=rev
Log:
[AddressSanitizer] Add PS4 offset

Added:
    llvm/trunk/test/Instrumentation/AddressSanitizer/ps4.ll
Modified:
    llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Modified: llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp?rev=295994&r1=295993&r2=295994&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp Thu Feb 23 11:10:28 2017
@@ -80,6 +80,7 @@ static const uint64_t kMIPS64_ShadowOffs
 static const uint64_t kAArch64_ShadowOffset64 = 1ULL << 36;
 static const uint64_t kFreeBSD_ShadowOffset32 = 1ULL << 30;
 static const uint64_t kFreeBSD_ShadowOffset64 = 1ULL << 46;
+static const uint64_t kPS4CPU_ShadowOffset64 = 1ULL << 40;
 static const uint64_t kWindowsShadowOffset32 = 3ULL << 28;
 // The shadow memory space is dynamically allocated.
 static const uint64_t kWindowsShadowOffset64 = kDynamicShadowSentinel;
@@ -380,6 +381,7 @@ static ShadowMapping getShadowMapping(Tr
   bool IsAndroid = TargetTriple.isAndroid();
   bool IsIOS = TargetTriple.isiOS() || TargetTriple.isWatchOS();
   bool IsFreeBSD = TargetTriple.isOSFreeBSD();
+  bool IsPS4CPU = TargetTriple.isPS4CPU();
   bool IsLinux = TargetTriple.isOSLinux();
   bool IsPPC64 = TargetTriple.getArch() == llvm::Triple::ppc64 ||
                  TargetTriple.getArch() == llvm::Triple::ppc64le;
@@ -418,6 +420,8 @@ static ShadowMapping getShadowMapping(Tr
       Mapping.Offset = kSystemZ_ShadowOffset64;
     else if (IsFreeBSD)
       Mapping.Offset = kFreeBSD_ShadowOffset64;
+    else if (IsPS4CPU)
+      Mapping.Offset = kPS4CPU_ShadowOffset64;
     else if (IsLinux && IsX86_64) {
       if (IsKasan)
         Mapping.Offset = kLinuxKasan_ShadowOffset64;
@@ -456,9 +460,9 @@ static ShadowMapping getShadowMapping(Tr
   // offset is not necessary 1/8-th of the address space.  On SystemZ,
   // we could OR the constant in a single instruction, but it's more
   // efficient to load it once and use indexed addressing.
-  Mapping.OrShadowOffset = !IsAArch64 && !IsPPC64 && !IsSystemZ
-                           && !(Mapping.Offset & (Mapping.Offset - 1))
-                           && Mapping.Offset != kDynamicShadowSentinel;
+  Mapping.OrShadowOffset = !IsAArch64 && !IsPPC64 && !IsSystemZ && !IsPS4CPU &&
+                           !(Mapping.Offset & (Mapping.Offset - 1)) &&
+                           Mapping.Offset != kDynamicShadowSentinel;
 
   return Mapping;
 }

Added: llvm/trunk/test/Instrumentation/AddressSanitizer/ps4.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/AddressSanitizer/ps4.ll?rev=295994&view=auto
==============================================================================
--- llvm/trunk/test/Instrumentation/AddressSanitizer/ps4.ll (added)
+++ llvm/trunk/test/Instrumentation/AddressSanitizer/ps4.ll Thu Feb 23 11:10:28 2017
@@ -0,0 +1,14 @@
+; RUN: opt < %s -asan -asan-module -S -mtriple=x86_64-scei-ps4 | FileCheck %s
+
+define i32 @read_4_bytes(i32* %a) sanitize_address {
+entry:
+  %tmp1 = load i32, i32* %a, align 4
+  ret i32 %tmp1
+}
+
+; CHECK: @read_4_bytes
+; CHECK-NOT: ret
+; Check for ASAN's Offset on the PS4 (2^40 or 0x10000000000)
+; CHECK: lshr {{.*}} 3
+; CHECK-NEXT: {{1099511627776}}
+; CHECK: ret




More information about the llvm-commits mailing list