Skip to content

Commit fb36658

Browse files
authored
[Memory] Call __clear_cache in InvalidateInstructionCache on LoongArch (#67285)
As the comments of `InvalidateInstructionCache`: Before the JIT can run a block of code that has been emitted it must invalidate the instruction cache on some platforms. I think it applies to LoongArch as LoongArch has a weak memory-model. But I'm not able to write a test to demonstrate this issue. Perhaps self-modifing code should be wrote?
1 parent 74b0465 commit fb36658

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

llvm/lib/Support/Unix/Memory.inc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ void Memory::InvalidateInstructionCache(const void *Addr, size_t Len) {
237237
for (intptr_t Line = StartLine; Line < EndLine; Line += LineSize)
238238
asm volatile("icbi 0, %0" : : "r"(Line));
239239
asm volatile("isync");
240-
#elif (defined(__arm__) || defined(__aarch64__) || defined(__mips__)) && \
240+
#elif (defined(__arm__) || defined(__aarch64__) || defined(__loongarch__) || \
241+
defined(__mips__)) && \
241242
defined(__GNUC__)
242243
// FIXME: Can we safely always call this for __GNUC__ everywhere?
243244
const char *Start = static_cast<const char *>(Addr);

0 commit comments

Comments
 (0)