Hi all,
When you genetate code on PowerPC you need to explicitly invalidate
the instruction cache to force the processor to reread it. In LLVM
there is code to do this for function stubs on Macintosh, but not
for other platforms and not for JITted code generally.
The attached patch adds support for GNU platforms, but I can't figure
out a nice way to call it for all generated code. Can anyone help?
Cheers,
Gary
llvm-52213-icache.patch (809 Bytes)
Hi Gary,
Gary Benson wrote:
Hi all,
When you genetate code on PowerPC you need to explicitly invalidate
the instruction cache to force the processor to reread it. In LLVM
there is code to do this for function stubs on Macintosh, but not
for other platforms and not for JITted code generally.
Did you run into errors when not invalidating the cache? vmkit JITs and runs on powerpc/linux without invalidating it, so I'm curious about when the problem occurs.
Thanks,
Nicolas
When you genetate code on PowerPC you need to explicitly invalidate
the instruction cache to force the processor to reread it. In LLVM
there is code to do this for function stubs on Macintosh, but not
for other platforms and not for JITted code generally.
Applied, thanks!
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20080616/063715.html
I tweaked it to work on non-ppc systems too.
The attached patch adds support for GNU platforms, but I can't figure
out a nice way to call it for all generated code. Can anyone help?
Can you elaborate on what the problem is?
-Chris
Chris Lattner wrote:
> When you genetate code on PowerPC you need to explicitly
> invalidate the instruction cache to force the processor to reread
> it. In LLVM there is code to do this for function stubs on
> Macintosh, but not for other platforms and not for JITted code
> generally.
Applied, thanks!
Thanks 
I tweaked it to work on non-ppc systems too.
I had to revert the change you made there -- my system doesn't seem to
have any of __POWERPC__, __ppc__ or _POWER power defined...
> The attached patch adds support for GNU platforms, but I can't
> figure out a nice way to call it for all generated code. Can
> anyone help?
Can you elaborate on what the problem is?
The attached patch generalizes it (aKor helped me out). I don't know
if Intel needs some kind of cache invalidation too but if it does it
could use the same hooks.
Cheers,
Gary
llvm-52391-icache.patch (4.63 KB)
Nicolas Geoffray wrote:
Gary Benson wrote:
> When you genetate code on PowerPC you need to explicitly
> invalidate the instruction cache to force the processor to reread
> it. In LLVM there is code to do this for function stubs on
> Macintosh, but not for other platforms and not for JITted code
> generally.
Did you run into errors when not invalidating the cache? vmkit JITs
and runs on powerpc/linux without invalidating it, so I'm curious
about when the problem occurs.
Yeah, I started getting SIGILLs, and I've had them before with a
similar thing so that's why I started looking. Then I hacked it into
my app to check and the errors went away. They're intermittent, so
I guess it depends on the speed of your box, how close in memory it's
allocating the code, and whatever else it happens to be doing in the
meantime.
Cheers,
Gary
Itanium definitely needs it. I'm having, what looks like, I-cache
related problems on my Montecito-based mnachine. The McKinley and
Madison processors don't need it.
I don't know yet if my case relates to yours, because it's tblgen
that's dumping core (?). It could also be a FreeBSD bug...
FYI,
Hi Gary,
The attached patch generalizes it (aKor helped me out). I don't know
if Intel needs some kind of cache invalidation too but if it does it
could use the same hooks.
I've applied patch but with some changes in order not to break non-PPC
builds. Please check whether it will work for you or not.
I was pretty impressed, that there is no built-in defines for your
platform (e.g. __POWERPC__, etc) - how do JIT compilation callbacks work
then?
Anton Korobeynikov wrote:
> The attached patch generalizes it (aKor helped me out). I don't
> know if Intel needs some kind of cache invalidation too but if it
> does it could use the same hooks.
I've applied patch but with some changes in order not to break
non-PPC builds. Please check whether it will work for you or not.
It works for me, thank you 
I was pretty impressed, that there is no built-in defines for your
platform (e.g. __POWERPC__, etc) - how do JIT compilation callbacks
work then?
Well, I guess it must have one or the other as your latest commit
works out of the box. I must have been doing something stupid the
other day (it has been known!)
Cheers,
Gary