[llvm] r218741 - [MCJIT] Turn the getSymbolAddress free function created in r218626 into a static

Lang Hames lhames at gmail.com
Tue Sep 30 21:11:13 PDT 2014


Author: lhames
Date: Tue Sep 30 23:11:13 2014
New Revision: 218741

URL: http://llvm.org/viewvc/llvm-project?rev=218741&view=rev
Log:
[MCJIT] Turn the getSymbolAddress free function created in r218626 into a static
member of RTDyldMemoryManager (and rename to getSymbolAddressInProcess).

The functionality this provides is very specific to RTDyldMemoryManager, so it
makes sense to keep it in that class to avoid accidental re-use.

No functional change.

Modified:
    llvm/trunk/include/llvm/ExecutionEngine/RTDyldMemoryManager.h
    llvm/trunk/lib/ExecutionEngine/RTDyldMemoryManager.cpp
    llvm/trunk/unittests/ExecutionEngine/ExecutionEngineTest.cpp

Modified: llvm/trunk/include/llvm/ExecutionEngine/RTDyldMemoryManager.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/RTDyldMemoryManager.h?rev=218741&r1=218740&r2=218741&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/RTDyldMemoryManager.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/RTDyldMemoryManager.h Tue Sep 30 23:11:13 2014
@@ -24,8 +24,6 @@ namespace llvm {
 class ExecutionEngine;
 class ObjectImage;
 
-uint64_t getSymbolAddress(const std::string &Name);
-
 // RuntimeDyld clients often want to handle the memory management of
 // what gets placed where. For JIT clients, this is the subset of
 // JITMemoryManager required for dynamic loading of binaries.
@@ -78,10 +76,14 @@ public:
 
   virtual void deregisterEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size);
 
+  /// This method returns the address of the specified function or variable in
+  /// the current process.
+  static uint64_t getSymbolAddressInProcess(const std::string &Name);
+
   /// This method returns the address of the specified function or variable.
   /// It is used to resolve symbols during module linking.
   virtual uint64_t getSymbolAddress(const std::string &Name) {
-    return llvm::getSymbolAddress(Name);
+    return getSymbolAddressInProcess(Name);
   }
 
   /// This method returns the address of the specified function. As such it is

Modified: llvm/trunk/lib/ExecutionEngine/RTDyldMemoryManager.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RTDyldMemoryManager.cpp?rev=218741&r1=218740&r2=218741&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RTDyldMemoryManager.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/RTDyldMemoryManager.cpp Tue Sep 30 23:11:13 2014
@@ -210,7 +210,8 @@ ARM_MATH_IMPORTS(ARM_MATH_DECL)
 #undef ARM_MATH_DECL
 #endif
 
-uint64_t getSymbolAddress(const std::string &Name) {
+uint64_t
+RTDyldMemoryManager::getSymbolAddressInProcess(const std::string &Name) {
   // This implementation assumes that the host program is the target.
   // Clients generating code for a remote target should implement their own
   // memory manager.

Modified: llvm/trunk/unittests/ExecutionEngine/ExecutionEngineTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/ExecutionEngineTest.cpp?rev=218741&r1=218740&r2=218741&view=diff
==============================================================================
--- llvm/trunk/unittests/ExecutionEngine/ExecutionEngineTest.cpp (original)
+++ llvm/trunk/unittests/ExecutionEngine/ExecutionEngineTest.cpp Tue Sep 30 23:11:13 2014
@@ -140,7 +140,8 @@ TEST_F(ExecutionEngineTest, LookupWithMa
 
   // Demonstrate that getSymbolAddress accepts mangled names and always strips
   // the leading underscore.
-  EXPECT_EQ(reinterpret_cast<uint64_t>(&x), getSymbolAddress("_x"));
+  EXPECT_EQ(reinterpret_cast<uint64_t>(&x),
+            RTDyldMemoryManager::getSymbolAddressInProcess("_x"));
 }
 
 TEST_F(ExecutionEngineTest, LookupWithMangledAndDemangledSymbol) {
@@ -151,7 +152,8 @@ TEST_F(ExecutionEngineTest, LookupWithMa
 
   // Lookup the demangled name first, even if there's a demangled symbol that
   // matches the input already.
-  EXPECT_EQ(reinterpret_cast<uint64_t>(&x), getSymbolAddress("_x"));
+  EXPECT_EQ(reinterpret_cast<uint64_t>(&x),
+            RTDyldMemoryManager::getSymbolAddressInProcess("_x"));
 }
 
 TEST_F(ExecutionEngineTest, LookupwithDemangledName) {
@@ -159,7 +161,8 @@ TEST_F(ExecutionEngineTest, LookupwithDe
   llvm::sys::DynamicLibrary::AddSymbol("_x", &_x);
 
   // But do fallback to looking up a demangled name if there's no ambiguity
-  EXPECT_EQ(reinterpret_cast<uint64_t>(&_x), getSymbolAddress("_x"));
+  EXPECT_EQ(reinterpret_cast<uint64_t>(&_x),
+            RTDyldMemoryManager::getSymbolAddressInProcess("_x"));
 }
 
 }





More information about the llvm-commits mailing list