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 | f28411f732960981f8920195ad8f7e6792396961 (patch) | |
tree | 92cc2bde87b08aba5eb01639b253601ac6d30fd8 /lib/Target/X86/X86JITInfo.cpp | |
parent | 0cec9c85ee0cf2a2eea34792424bf9b6874a0b63 (diff) | |
download | llvm-f28411f732960981f8920195ad8f7e6792396961.tar.gz llvm-f28411f732960981f8920195ad8f7e6792396961.tar.bz2 llvm-f28411f732960981f8920195ad8f7e6792396961.tar.xz |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98529 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/X86JITInfo.cpp')
-rw-r--r-- | lib/Target/X86/X86JITInfo.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Target/X86/X86JITInfo.cpp b/lib/Target/X86/X86JITInfo.cpp index d297d24e22..6f0a8d91cb 100644 --- a/lib/Target/X86/X86JITInfo.cpp +++ b/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 } |