summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
diff options
context:
space:
mode:
authorDavide Italiano <davide@freebsd.org>2015-11-17 16:37:52 +0000
committerDavide Italiano <davide@freebsd.org>2015-11-17 16:37:52 +0000
commitaf08e1bdf053f0a4e385bd2889d06ce546f514de (patch)
treec1351aeb157f34b19e69630824b0e764d4b701e5 /llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
parent6689df85eed3d10d787d8c27a262a6123847a0bf (diff)
downloadbcm5719-llvm-af08e1bdf053f0a4e385bd2889d06ce546f514de.tar.gz
bcm5719-llvm-af08e1bdf053f0a4e385bd2889d06ce546f514de.zip
[llvm-rtdyld] Don't waste cycles invalidating instruction cache.
Now that setExecutable() changed to do all the ground work to make memory executable on the host, we can remove all (redundant) calls to invalidate instruction cache here. As an added bonus, this makes invalidateInstructionCache() dead code, so it can be removed. Differential Revision: http://reviews.llvm.org/D13631 llvm-svn: 253343
Diffstat (limited to 'llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp')
-rw-r--r--llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp24
1 files changed, 4 insertions, 20 deletions
diff --git a/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp b/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
index e55932fcea6..315c50fd9ef 100644
--- a/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
+++ b/llvm/tools/llvm-rtdyld/llvm-rtdyld.cpp
@@ -155,12 +155,6 @@ public:
bool finalizeMemory(std::string *ErrMsg) override { return false; }
- // Invalidate instruction cache for sections with execute permissions.
- // Some platforms with separate data cache and instruction cache require
- // explicit cache flush, otherwise JIT code manipulations (like resolved
- // relocations) will get to the data cache but not to the instruction cache.
- virtual void invalidateInstructionCache();
-
void addDummySymbol(const std::string &Name, uint64_t Addr) {
DummyExterns[Name] = Addr;
}
@@ -244,14 +238,6 @@ uint8_t *TrivialMemoryManager::allocateDataSection(uintptr_t Size,
return (uint8_t*)MB.base();
}
-void TrivialMemoryManager::invalidateInstructionCache() {
- for (auto &FM : FunctionMemory)
- sys::Memory::InvalidateInstructionCache(FM.base(), FM.size());
-
- for (auto &DM : DataMemory)
- sys::Memory::InvalidateInstructionCache(DM.base(), DM.size());
-}
-
static const char *ProgramName;
static void Message(const char *Type, const Twine &Msg) {
@@ -424,12 +410,9 @@ static int executeInput() {
}
}
- // Resolve all the relocations we can.
- Dyld.resolveRelocations();
- // Clear instruction cache before code will be executed.
- MemMgr.invalidateInstructionCache();
-
+ // Resove all the relocations we can.
// FIXME: Error out if there are unresolved relocations.
+ Dyld.resolveRelocations();
// Get the address of the entry point (_main by default).
void *MainAddress = Dyld.getSymbolLocalAddress(EntryPoint);
@@ -438,9 +421,10 @@ static int executeInput() {
// Invalidate the instruction cache for each loaded function.
for (auto &FM : MemMgr.FunctionMemory) {
+
// Make sure the memory is executable.
+ // setExecutable will call InvalidateInstructionCache.
std::string ErrorStr;
- sys::Memory::InvalidateInstructionCache(FM.base(), FM.size());
if (!sys::Memory::setExecutable(FM, &ErrorStr))
return Error("unable to mark function executable: '" + ErrorStr + "'");
}
OpenPOWER on IntegriCloud