[llvm] r338974 - [ORC] Change JITSymbolFlags debug output, add a function for getting a symbol
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 5 15:35:37 PDT 2018
Author: lhames
Date: Sun Aug 5 15:35:37 2018
New Revision: 338974
URL: http://llvm.org/viewvc/llvm-project?rev=338974&view=rev
Log:
[ORC] Change JITSymbolFlags debug output, add a function for getting a symbol
flags map from a buffer representing an object file.
Modified:
llvm/trunk/include/llvm/ExecutionEngine/Orc/Layer.h
llvm/trunk/lib/ExecutionEngine/Orc/Core.cpp
llvm/trunk/lib/ExecutionEngine/Orc/Layer.cpp
Modified: llvm/trunk/include/llvm/ExecutionEngine/Orc/Layer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/Layer.h?rev=338974&r1=338973&r2=338974&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/Orc/Layer.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/Orc/Layer.h Sun Aug 5 15:35:37 2018
@@ -16,6 +16,7 @@
#include "llvm/ExecutionEngine/Orc/Core.h"
#include "llvm/IR/Module.h"
+#include "llvm/Support/MemoryBuffer.h"
namespace llvm {
namespace orc {
@@ -109,10 +110,11 @@ public:
static Expected<std::unique_ptr<BasicObjectLayerMaterializationUnit>>
Create(ObjectLayer &L, VModuleKey K, std::unique_ptr<MemoryBuffer> O);
+ BasicObjectLayerMaterializationUnit(ObjectLayer &L, VModuleKey K,
+ std::unique_ptr<MemoryBuffer> O,
+ SymbolFlagsMap SymbolFlags);
+
private:
- BasicObjectLayerMaterializationUnit(SymbolFlagsMap SymbolFlags,
- ObjectLayer &L, VModuleKey K,
- std::unique_ptr<MemoryBuffer> O);
void materialize(MaterializationResponsibility R) override;
void discard(const VSO &V, SymbolStringPtr Name) override;
@@ -122,6 +124,12 @@ private:
std::unique_ptr<MemoryBuffer> O;
};
+/// Returns a SymbolFlagsMap for the object file represented by the given
+/// buffer, or an error if the buffer does not contain a valid object file.
+// FIXME: Maybe move to Core.h?
+Expected<SymbolFlagsMap> getObjectSymbolFlags(ExecutionSession &ES,
+ MemoryBufferRef ObjBuffer);
+
} // End namespace orc
} // End namespace llvm
Modified: llvm/trunk/lib/ExecutionEngine/Orc/Core.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/Core.cpp?rev=338974&r1=338973&r2=338974&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/Orc/Core.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/Orc/Core.cpp Sun Aug 5 15:35:37 2018
@@ -30,17 +30,17 @@ RegisterDependenciesFunction NoDependenc
void MaterializationUnit::anchor() {}
raw_ostream &operator<<(raw_ostream &OS, const JITSymbolFlags &Flags) {
+ if (Flags.isCallable())
+ OS << "[Callable]";
+ else
+ OS << "[Data]";
if (Flags.isWeak())
- OS << 'W';
+ OS << "[Weak]";
else if (Flags.isCommon())
- OS << 'C';
- else
- OS << 'S';
+ OS << "[Common]";
- if (Flags.isExported())
- OS << 'E';
- else
- OS << 'H';
+ if (!Flags.isExported())
+ OS << "[Hidden]";
return OS;
}
Modified: llvm/trunk/lib/ExecutionEngine/Orc/Layer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/Layer.cpp?rev=338974&r1=338973&r2=338974&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/Orc/Layer.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/Orc/Layer.cpp Sun Aug 5 15:35:37 2018
@@ -9,7 +9,6 @@
#include "llvm/ExecutionEngine/Orc/Layer.h"
#include "llvm/Object/ObjectFile.h"
-#include "llvm/Support/MemoryBuffer.h"
namespace llvm {
namespace orc {
@@ -78,33 +77,20 @@ Error ObjectLayer::add(VSO &V, VModuleKe
Expected<std::unique_ptr<BasicObjectLayerMaterializationUnit>>
BasicObjectLayerMaterializationUnit::Create(ObjectLayer &L, VModuleKey K,
std::unique_ptr<MemoryBuffer> O) {
- auto &ES = L.getExecutionSession();
- auto Obj = object::ObjectFile::createObjectFile(O->getMemBufferRef());
+ auto SymbolFlags =
+ getObjectSymbolFlags(L.getExecutionSession(), O->getMemBufferRef());
- if (!Obj)
- return Obj.takeError();
-
- SymbolFlagsMap SymbolFlags;
- for (auto &Sym : (*Obj)->symbols()) {
- if (!(Sym.getFlags() & object::BasicSymbolRef::SF_Undefined) &&
- (Sym.getFlags() & object::BasicSymbolRef::SF_Exported)) {
- auto InternedName =
- ES.getSymbolStringPool().intern(cantFail(Sym.getName()));
- auto SymFlags = JITSymbolFlags::fromObjectSymbol(Sym);
- if (!SymFlags)
- return SymFlags.takeError();
- SymbolFlags[InternedName] = std::move(*SymFlags);
- }
- }
+ if (!SymbolFlags)
+ return SymbolFlags.takeError();
return std::unique_ptr<BasicObjectLayerMaterializationUnit>(
- new BasicObjectLayerMaterializationUnit(std::move(SymbolFlags), L, K,
- std::move(O)));
+ new BasicObjectLayerMaterializationUnit(L, K, std::move(O),
+ std::move(*SymbolFlags)));
}
BasicObjectLayerMaterializationUnit::BasicObjectLayerMaterializationUnit(
- SymbolFlagsMap SymbolFlags, ObjectLayer &L, VModuleKey K,
- std::unique_ptr<MemoryBuffer> O)
+ ObjectLayer &L, VModuleKey K, std::unique_ptr<MemoryBuffer> O,
+ SymbolFlagsMap SymbolFlags)
: MaterializationUnit(std::move(SymbolFlags)), L(L), K(std::move(K)),
O(std::move(O)) {}
@@ -119,5 +105,28 @@ void BasicObjectLayerMaterializationUnit
// filter to pass to the object layer along with the object itself.
}
+Expected<SymbolFlagsMap> getObjectSymbolFlags(ExecutionSession &ES,
+ MemoryBufferRef ObjBuffer) {
+ auto Obj = object::ObjectFile::createObjectFile(ObjBuffer);
+
+ if (!Obj)
+ return Obj.takeError();
+
+ SymbolFlagsMap SymbolFlags;
+ for (auto &Sym : (*Obj)->symbols()) {
+ if (!(Sym.getFlags() & object::BasicSymbolRef::SF_Undefined) &&
+ (Sym.getFlags() & object::BasicSymbolRef::SF_Exported)) {
+ auto InternedName =
+ ES.getSymbolStringPool().intern(cantFail(Sym.getName()));
+ auto SymFlags = JITSymbolFlags::fromObjectSymbol(Sym);
+ if (!SymFlags)
+ return SymFlags.takeError();
+ SymbolFlags[InternedName] = std::move(*SymFlags);
+ }
+ }
+
+ return SymbolFlags;
+}
+
} // End namespace orc.
} // End namespace llvm.
More information about the llvm-commits
mailing list