Skip to content

Commit

Permalink
[mips] Use __clear_cache builtin instead of cacheflush() in Unix Memo…
Browse files Browse the repository at this point in the history
…ry::InvalidateInstructionCache()

MIPS64 Android bionic has removed cacheflush(). Use __clear_cache() instead for 32-bit and 64-bit MIPS

Patch by Duane Sand <[email protected]>



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211588 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
dsandersllvm committed Jun 24, 2014
1 parent 0e6156a commit 2523346
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions lib/Support/Unix/Memory.inc
Original file line number Diff line number Diff line change
Expand Up @@ -333,23 +333,15 @@ void Memory::InvalidateInstructionCache(const void *Addr,
for (intptr_t Line = StartLine; Line < EndLine; Line += LineSize)
asm volatile("icbi 0, %0" : : "r"(Line));
asm volatile("isync");
# elif (defined(__arm__) || defined(__aarch64__)) && defined(__GNUC__)
# elif (defined(__arm__) || defined(__aarch64__) || defined(__mips__)) && defined(__GNUC__)
// FIXME: Can we safely always call this for __GNUC__ everywhere?
// Use compiler's builtin
const char *Start = static_cast<const char *>(Addr);
const char *End = Start + Len;
__clear_cache(const_cast<char *>(Start), const_cast<char *>(End));
# elif defined(__mips__)
const char *Start = static_cast<const char *>(Addr);
# if defined(ANDROID)
// The declaration of "cacheflush" in Android bionic:
// extern int cacheflush(long start, long end, long flags);
const char *End = Start + Len;
long LStart = reinterpret_cast<long>(const_cast<char *>(Start));
long LEnd = reinterpret_cast<long>(const_cast<char *>(End));
cacheflush(LStart, LEnd, BCACHE);
# else
cacheflush(const_cast<char *>(Start), Len, BCACHE);
# endif
# endif

#endif // end apple
Expand Down

0 comments on commit 2523346

Please sign in to comment.