Refactor lli-child-target to remove duplicated code

Eliminate the copies LLVM's System mmap and cache invalidation code. These were
slowly drifting away from the original version, and moreover the copied code
was a dead end in terms of portability.

We now statically link to Support but in practice with stripping this adds next
to no weight to the resultant binary.

Also avoid installing lli-child-target to the user's $PATH. It's not meant to
be run directly.

llvm-svn: 199881
diff --git a/llvm/tools/lli/RemoteTarget.h b/llvm/tools/lli/RemoteTarget.h
index a7d4e59..44e649e 100644
--- a/llvm/tools/lli/RemoteTarget.h
+++ b/llvm/tools/lli/RemoteTarget.h
@@ -27,7 +27,8 @@
 class RemoteTarget {
   bool IsRunning;
 
-  SmallVector<sys::MemoryBlock, 16> Allocations;
+  typedef SmallVector<sys::MemoryBlock, 16> AllocMapType;
+  AllocMapType Allocations;
 
 protected:
   std::string ErrorMsg;
@@ -47,6 +48,18 @@
                              unsigned Alignment,
                              uint64_t &Address);
 
+  bool isAllocatedMemory(uint64_t Address, uint32_t Size) {
+    uint64_t AddressEnd = Address + Size;
+    for (AllocMapType::const_iterator I = Allocations.begin(),
+                                      E = Allocations.end();
+         I != E; ++I) {
+      if (Address >= (uint64_t)I->base() &&
+          AddressEnd <= (uint64_t)I->base() + I->size())
+        return true;
+    }
+    return false;
+  }
+
   /// Load data into the target address space.
   ///
   /// @param      Address   Destination address in the target process.