Skip to content

Commit 9e26f2f

Browse files
committed
xcoff jitlink
1 parent f798345 commit 9e26f2f

File tree

11 files changed

+736
-99
lines changed

11 files changed

+736
-99
lines changed

llvm/include/llvm/ExecutionEngine/Orc/Core.h

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,11 @@ class SymbolLookupSet {
308308
/// If Body returns true then the element just passed in is removed from the
309309
/// set. If Body returns false then the element is retained.
310310
template <typename BodyFn>
311-
auto forEachWithRemoval(BodyFn &&Body) -> std::enable_if_t<
312-
std::is_same<decltype(Body(std::declval<const SymbolStringPtr &>(),
313-
std::declval<SymbolLookupFlags>())),
314-
bool>::value> {
311+
auto forEachWithRemoval(BodyFn &&Body)
312+
-> std::enable_if_t<
313+
std::is_same<decltype(Body(std::declval<const SymbolStringPtr &>(),
314+
std::declval<SymbolLookupFlags>())),
315+
bool>::value> {
315316
UnderlyingVector::size_type I = 0;
316317
while (I != Symbols.size()) {
317318
const auto &Name = Symbols[I].first;
@@ -330,11 +331,12 @@ class SymbolLookupSet {
330331
/// returns true then the element just passed in is removed from the set. If
331332
/// Body returns false then the element is retained.
332333
template <typename BodyFn>
333-
auto forEachWithRemoval(BodyFn &&Body) -> std::enable_if_t<
334-
std::is_same<decltype(Body(std::declval<const SymbolStringPtr &>(),
335-
std::declval<SymbolLookupFlags>())),
336-
Expected<bool>>::value,
337-
Error> {
334+
auto forEachWithRemoval(BodyFn &&Body)
335+
-> std::enable_if_t<
336+
std::is_same<decltype(Body(std::declval<const SymbolStringPtr &>(),
337+
std::declval<SymbolLookupFlags>())),
338+
Expected<bool>>::value,
339+
Error> {
338340
UnderlyingVector::size_type I = 0;
339341
while (I != Symbols.size()) {
340342
const auto &Name = Symbols[I].first;
@@ -525,6 +527,7 @@ class MissingSymbolDefinitions : public ErrorInfo<MissingSymbolDefinitions> {
525527
std::shared_ptr<SymbolStringPool> getSymbolStringPool() { return SSP; }
526528
const std::string &getModuleName() const { return ModuleName; }
527529
const SymbolNameVector &getSymbols() const { return Symbols; }
530+
528531
private:
529532
std::shared_ptr<SymbolStringPool> SSP;
530533
std::string ModuleName;
@@ -535,7 +538,8 @@ class MissingSymbolDefinitions : public ErrorInfo<MissingSymbolDefinitions> {
535538
/// symbols that are not claimed by the module's associated
536539
/// MaterializationResponsibility. If this error is returned it is indicative of
537540
/// a broken transformation / compiler / object cache.
538-
class UnexpectedSymbolDefinitions : public ErrorInfo<UnexpectedSymbolDefinitions> {
541+
class UnexpectedSymbolDefinitions
542+
: public ErrorInfo<UnexpectedSymbolDefinitions> {
539543
public:
540544
static char ID;
541545

@@ -548,6 +552,7 @@ class UnexpectedSymbolDefinitions : public ErrorInfo<UnexpectedSymbolDefinitions
548552
std::shared_ptr<SymbolStringPool> getSymbolStringPool() { return SSP; }
549553
const std::string &getModuleName() const { return ModuleName; }
550554
const SymbolNameVector &getSymbols() const { return Symbols; }
555+
551556
private:
552557
std::shared_ptr<SymbolStringPool> SSP;
553558
std::string ModuleName;
@@ -693,6 +698,10 @@ class MaterializationResponsibility {
693698
: JD(RT->getJITDylib()), RT(std::move(RT)),
694699
SymbolFlags(std::move(SymbolFlags)), InitSymbol(std::move(InitSymbol)) {
695700
assert(!this->SymbolFlags.empty() && "Materializing nothing?");
701+
for (auto &KV : this->SymbolFlags) {
702+
dbgs() << "@@@ Init MR " << KV.first << " "
703+
<< format_hex(KV.second.getRawFlagsValue(), 8) << "\n";
704+
}
696705
}
697706

698707
JITDylib &JD;
@@ -800,7 +809,6 @@ class AsynchronousSymbolQuery {
800809
/// resolved.
801810
bool isComplete() const { return OutstandingSymbolsCount == 0; }
802811

803-
804812
private:
805813
void handleComplete(ExecutionSession &ES);
806814

@@ -899,8 +907,8 @@ class JITDylib : public ThreadSafeRefCountedBase<JITDylib>,
899907
friend class ExecutionSession;
900908
friend class Platform;
901909
friend class MaterializationResponsibility;
902-
public:
903910

911+
public:
904912
JITDylib(const JITDylib &) = delete;
905913
JITDylib &operator=(const JITDylib &) = delete;
906914
JITDylib(JITDylib &&) = delete;
@@ -1104,7 +1112,7 @@ class JITDylib : public ThreadSafeRefCountedBase<JITDylib>,
11041112

11051113
private:
11061114
using AsynchronousSymbolQuerySet =
1107-
std::set<std::shared_ptr<AsynchronousSymbolQuery>>;
1115+
std::set<std::shared_ptr<AsynchronousSymbolQuery>>;
11081116

11091117
using AsynchronousSymbolQueryList =
11101118
std::vector<std::shared_ptr<AsynchronousSymbolQuery>>;
@@ -1160,6 +1168,7 @@ class JITDylib : public ThreadSafeRefCountedBase<JITDylib>,
11601168
const AsynchronousSymbolQueryList &pendingQueries() const {
11611169
return PendingQueries;
11621170
}
1171+
11631172
private:
11641173
AsynchronousSymbolQueryList PendingQueries;
11651174
};
@@ -1355,13 +1364,13 @@ class ExecutionSession {
13551364
using ErrorReporter = unique_function<void(Error)>;
13561365

13571366
/// Send a result to the remote.
1358-
using SendResultFunction = unique_function<void(shared::WrapperFunctionResult)>;
1367+
using SendResultFunction =
1368+
unique_function<void(shared::WrapperFunctionResult)>;
13591369

13601370
/// An asynchronous wrapper-function callable from the executor via
13611371
/// jit-dispatch.
13621372
using JITDispatchHandlerFunction = unique_function<void(
1363-
SendResultFunction SendResult,
1364-
const char *ArgData, size_t ArgSize)>;
1373+
SendResultFunction SendResult, const char *ArgData, size_t ArgSize)>;
13651374

13661375
/// A map associating tag names with asynchronous wrapper function
13671376
/// implementations in the JIT.
@@ -1589,8 +1598,7 @@ class ExecutionSession {
15891598
/// \endcode{.cpp}
15901599
///
15911600
/// The given OnComplete function will be called to return the result.
1592-
template <typename... ArgTs>
1593-
void callWrapperAsync(ArgTs &&... Args) {
1601+
template <typename... ArgTs> void callWrapperAsync(ArgTs &&...Args) {
15941602
EPC->callWrapperAsync(std::forward<ArgTs>(Args)...);
15951603
}
15961604

@@ -1635,9 +1643,9 @@ class ExecutionSession {
16351643
/// (using registerJITDispatchHandler) and called from the executor.
16361644
template <typename SPSSignature, typename HandlerT>
16371645
static JITDispatchHandlerFunction wrapAsyncWithSPS(HandlerT &&H) {
1638-
return [H = std::forward<HandlerT>(H)](
1639-
SendResultFunction SendResult,
1640-
const char *ArgData, size_t ArgSize) mutable {
1646+
return [H = std::forward<HandlerT>(H)](SendResultFunction SendResult,
1647+
const char *ArgData,
1648+
size_t ArgSize) mutable {
16411649
shared::WrapperFunction<SPSSignature>::handleAsync(ArgData, ArgSize, H,
16421650
std::move(SendResult));
16431651
};
@@ -1742,8 +1750,8 @@ class ExecutionSession {
17421750
unique_function<void(Expected<SymbolFlagsMap>)> OnComplete);
17431751

17441752
// State machine functions for MaterializationResponsibility.
1745-
void OL_destroyMaterializationResponsibility(
1746-
MaterializationResponsibility &MR);
1753+
void
1754+
OL_destroyMaterializationResponsibility(MaterializationResponsibility &MR);
17471755
SymbolNameSet OL_getRequestedSymbols(const MaterializationResponsibility &MR);
17481756
Error OL_notifyResolved(MaterializationResponsibility &MR,
17491757
const SymbolMap &Symbols);
@@ -1965,12 +1973,13 @@ inline MaterializationResponsibility::~MaterializationResponsibility() {
19651973
getExecutionSession().OL_destroyMaterializationResponsibility(*this);
19661974
}
19671975

1968-
inline SymbolNameSet MaterializationResponsibility::getRequestedSymbols() const {
1976+
inline SymbolNameSet
1977+
MaterializationResponsibility::getRequestedSymbols() const {
19691978
return getExecutionSession().OL_getRequestedSymbols(*this);
19701979
}
19711980

1972-
inline Error MaterializationResponsibility::notifyResolved(
1973-
const SymbolMap &Symbols) {
1981+
inline Error
1982+
MaterializationResponsibility::notifyResolved(const SymbolMap &Symbols) {
19741983
return getExecutionSession().OL_notifyResolved(*this, Symbols);
19751984
}
19761985

@@ -1979,8 +1988,8 @@ inline Error MaterializationResponsibility::notifyEmitted(
19791988
return getExecutionSession().OL_notifyEmitted(*this, EmittedDeps);
19801989
}
19811990

1982-
inline Error MaterializationResponsibility::defineMaterializing(
1983-
SymbolFlagsMap SymbolFlags) {
1991+
inline Error
1992+
MaterializationResponsibility::defineMaterializing(SymbolFlagsMap SymbolFlags) {
19841993
return getExecutionSession().OL_defineMaterializing(*this,
19851994
std::move(SymbolFlags));
19861995
}

llvm/lib/ExecutionEngine/JITLink/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ add_llvm_component_library(LLVMJITLink
3838
# XCOFF
3939
XCOFF.cpp
4040
XCOFF_ppc64.cpp
41+
XCOFFLinkGraphBuilder.cpp
4142

4243
# Architectures:
4344
aarch32.cpp

llvm/lib/ExecutionEngine/JITLink/JITLink.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,8 @@ void link(std::unique_ptr<LinkGraph> G, std::unique_ptr<JITLinkContext> Ctx) {
535535
return link_ELF(std::move(G), std::move(Ctx));
536536
case Triple::COFF:
537537
return link_COFF(std::move(G), std::move(Ctx));
538+
case Triple::XCOFF:
539+
return link_XCOFF(std::move(G), std::move(Ctx));
538540
default:
539541
Ctx->notifyFailed(make_error<JITLinkError>("Unsupported object format"));
540542
};

llvm/lib/ExecutionEngine/JITLink/XCOFF.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ createLinkGraphFromXCOFFObject(MemoryBufferRef ObjectBuffer,
3636

3737
void link_XCOFF(std::unique_ptr<LinkGraph> G,
3838
std::unique_ptr<JITLinkContext> Ctx) {
39-
llvm_unreachable("Not implmeneted for XCOFF yet");
39+
link_XCOFF_ppc64(std::move(G), std::move(Ctx));
4040
}
4141

4242
} // namespace jitlink

0 commit comments

Comments
 (0)