[llvm-commits] [llvm] r59291 - /llvm/trunk/lib/System/Memory.cpp

Evan Cheng evan.cheng at apple.com
Thu Nov 13 18:33:18 PST 2008


Author: evancheng
Date: Thu Nov 13 20:33:17 2008
New Revision: 59291

URL: http://llvm.org/viewvc/llvm-project?rev=59291&view=rev
Log:
ARM / Mac OS X also wants to invalidate icache after jitting.

Modified:
    llvm/trunk/lib/System/Memory.cpp

Modified: llvm/trunk/lib/System/Memory.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Memory.cpp?rev=59291&r1=59290&r2=59291&view=diff

==============================================================================
--- llvm/trunk/lib/System/Memory.cpp (original)
+++ llvm/trunk/lib/System/Memory.cpp Thu Nov 13 20:33:17 2008
@@ -35,26 +35,28 @@
 void llvm::sys::Memory::InvalidateInstructionCache(const void *Addr,
                                                    size_t Len) {
   
-// icache invalidation for PPC.
+// icache invalidation for PPC and ARM.
+#if defined(__APPLE__)
 #if (defined(__POWERPC__) || defined (__ppc__) || \
-     defined(_POWER) || defined(_ARCH_PPC))
-   #if defined(__APPLE__)
-       sys_icache_invalidate(Addr, Len);
-   #elif defined(__GNUC__)
-        const size_t LineSize = 32;
-
-        const intptr_t Mask = ~(LineSize - 1);
-        const intptr_t StartLine = ((intptr_t) Addr) & Mask;
-        const intptr_t EndLine = ((intptr_t) Addr + Len + LineSize - 1) & Mask;
+     defined(_POWER) || defined(_ARCH_PPC)) || defined(__arm__)
+  sys_icache_invalidate(Addr, Len);
+#endif
+#else
+#if (defined(__POWERPC__) || defined (__ppc__) || \
+     defined(_POWER) || defined(_ARCH_PPC)) && defined(__GNUC__)
+  const size_t LineSize = 32;
 
-        for (intptr_t Line = StartLine; Line < EndLine; Line += LineSize)
-          asm volatile("dcbf 0, %0" : : "r"(Line));
-        asm volatile("sync");
+  const intptr_t Mask = ~(LineSize - 1);
+  const intptr_t StartLine = ((intptr_t) Addr) & Mask;
+  const intptr_t EndLine = ((intptr_t) Addr + Len + LineSize - 1) & Mask;
 
-        for (intptr_t Line = StartLine; Line < EndLine; Line += LineSize)
-          asm volatile("icbi 0, %0" : : "r"(Line));
-        asm volatile("isync");
-   #endif
-#endif  // end PPC
+  for (intptr_t Line = StartLine; Line < EndLine; Line += LineSize)
+    asm volatile("dcbf 0, %0" : : "r"(Line));
+  asm volatile("sync");
 
+  for (intptr_t Line = StartLine; Line < EndLine; Line += LineSize)
+    asm volatile("icbi 0, %0" : : "r"(Line));
+  asm volatile("isync");
+#endif
+#endif  // end apple
 }





More information about the llvm-commits mailing list