diff options
author | Jeffrey Yasskin <jyasskin@google.com> | 2010-03-15 04:57:55 +0000 |
---|---|---|
committer | Jeffrey Yasskin <jyasskin@google.com> | 2010-03-15 04:57:55 +0000 |
commit | 3ddd88f523defacb922ea53e64fec2bdf25f2896 (patch) | |
tree | 43f392ae6c226b2617c1079b397ee7e5ef58dbaa /llvm/lib/Target | |
parent | 022a9fb269ab09ade827abdcc228d8dd5e500d6a (diff) | |
download | bcm5719-llvm-3ddd88f523defacb922ea53e64fec2bdf25f2896.tar.gz bcm5719-llvm-3ddd88f523defacb922ea53e64fec2bdf25f2896.zip |
Tell Valgrind when we modify already-executed machine code so it knows
to re-instrument the code. We depend on the system valgrind.h to
avoid adding a new license.
llvm-svn: 98529
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r-- | llvm/lib/Target/X86/X86JITInfo.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Target/X86/X86JITInfo.cpp b/llvm/lib/Target/X86/X86JITInfo.cpp index d297d24e22b..6f0a8d91cb5 100644 --- a/llvm/lib/Target/X86/X86JITInfo.cpp +++ b/llvm/lib/Target/X86/X86JITInfo.cpp @@ -19,6 +19,7 @@ #include "llvm/Function.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/System/Valgrind.h" #include <cstdlib> #include <cstring> using namespace llvm; @@ -37,6 +38,10 @@ void X86JITInfo::replaceMachineCodeForFunction(void *Old, void *New) { unsigned NewAddr = (intptr_t)New; unsigned OldAddr = (intptr_t)OldWord; *OldWord = NewAddr - OldAddr - 4; // Emit PC-relative addr of New code. + + // X86 doesn't need to invalidate the processor cache, so just invalidate + // Valgrind's cache directly. + sys::ValgrindDiscardTranslations(Old, 5); } @@ -393,8 +398,10 @@ X86CompilationCallback2(intptr_t *StackPtr, intptr_t RetAddr) { *(intptr_t *)(RetAddr - 0xa) = NewVal; ((unsigned char*)RetAddr)[0] = (2 | (4 << 3) | (3 << 6)); } + sys::ValgrindDiscardTranslations((void*)(RetAddr-0xc), 0xd); #else ((unsigned char*)RetAddr)[-1] = 0xE9; + sys::ValgrindDiscardTranslations((void*)(RetAddr-1), 5); #endif } |