summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-09-12 23:29:02 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-09-12 23:29:02 +0000
commit299f11f662c420d4da6ad11cf1a0863b26fcd20b (patch)
treec1cd6296b9c08c7f9aaacb668254fc199ca08214
parent7cb384dcca3f1ccfc993182ee4b972f7fffc8ffa (diff)
downloadllvm-299f11f662c420d4da6ad11cf1a0863b26fcd20b.tar.gz
llvm-299f11f662c420d4da6ad11cf1a0863b26fcd20b.tar.bz2
llvm-299f11f662c420d4da6ad11cf1a0863b26fcd20b.tar.xz
Experimental fix for PR4960.
- Could we just always implement this as __clear_cache for __GNUC__? git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81655 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/System/Memory.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/System/Memory.cpp b/lib/System/Memory.cpp
index 375c73cf02..e2d838dce0 100644
--- a/lib/System/Memory.cpp
+++ b/lib/System/Memory.cpp
@@ -37,13 +37,16 @@ void llvm::sys::Memory::InvalidateInstructionCache(const void *Addr,
// icache invalidation for PPC and ARM.
#if defined(__APPLE__)
-#if (defined(__POWERPC__) || defined (__ppc__) || \
+
+# if (defined(__POWERPC__) || defined (__ppc__) || \
defined(_POWER) || defined(_ARCH_PPC)) || defined(__arm__)
sys_icache_invalidate(Addr, Len);
-#endif
+# endif
+
#else
-#if (defined(__POWERPC__) || defined (__ppc__) || \
- defined(_POWER) || defined(_ARCH_PPC)) && defined(__GNUC__)
+
+# if (defined(__POWERPC__) || defined (__ppc__) || \
+ defined(_POWER) || defined(_ARCH_PPC)) && defined(__GNUC__)
const size_t LineSize = 32;
const intptr_t Mask = ~(LineSize - 1);
@@ -57,6 +60,12 @@ void llvm::sys::Memory::InvalidateInstructionCache(const void *Addr,
for (intptr_t Line = StartLine; Line < EndLine; Line += LineSize)
asm volatile("icbi 0, %0" : : "r"(Line));
asm volatile("isync");
-#endif
+# elif defined(__arm__) && defined(__GNUC__)
+ // FIXME: Can we safely always call this for __GNUC__ everywhere?
+ char *Start = (char*) Addr;
+ char *End = Start + Len;
+ __clear_cache(Start, End);
+# endif
+
#endif // end apple
}