Skip to content

Commit 16dcbb5

Browse files
committed
[ORC] Return ExecutorAddrs rather than JITEvaluatedSymbols from LLJIT::lookup.
Clients don't care about linkage, and ExecutorAddr is much more ergonomic.
1 parent b226894 commit 16dcbb5

File tree

17 files changed

+48
-49
lines changed

17 files changed

+48
-49
lines changed

clang/lib/Interpreter/IncrementalExecutor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ IncrementalExecutor::getSymbolAddress(llvm::StringRef Name,
6868

6969
if (!Sym)
7070
return Sym.takeError();
71-
return Sym->getAddress();
71+
return Sym->getValue();
7272
}
7373

7474
} // end namespace clang

llvm/examples/HowToUseLLJIT/HowToUseLLJIT.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ int main(int argc, char *argv[]) {
9191
ExitOnErr(J->addIRModule(std::move(M)));
9292

9393
// Look up the JIT'd function, cast it to a function pointer, then call it.
94-
auto Add1Sym = ExitOnErr(J->lookup("add1"));
95-
int (*Add1)(int) = (int (*)(int))Add1Sym.getAddress();
94+
auto Add1Addr = ExitOnErr(J->lookup("add1"));
95+
int (*Add1)(int) = Add1Addr.toPtr<int(int)>();
9696

9797
int Result = Add1(42);
9898
outs() << "add1(42) = " << Result << "\n";

llvm/examples/OrcV2Examples/LLJITDumpObjects/LLJITDumpObjects.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ int main(int argc, char *argv[]) {
6161
ExitOnErr(J->addIRModule(std::move(M)));
6262

6363
// Look up the JIT'd function, cast it to a function pointer, then call it.
64-
auto Add1Sym = ExitOnErr(J->lookup("add1"));
65-
int (*Add1)(int) = (int (*)(int))Add1Sym.getAddress();
64+
auto Add1Addr = ExitOnErr(J->lookup("add1"));
65+
int (*Add1)(int) = Add1Addr.toPtr<int(int)>();
6666

6767
int Result = Add1(42);
6868
outs() << "add1(42) = " << Result << "\n";

llvm/examples/OrcV2Examples/LLJITRemovableCode/LLJITRemovableCode.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ int main(int argc, char *argv[]) {
9292
auto PrintSymbol = [&](StringRef Name) {
9393
dbgs() << Name << " = ";
9494
if (auto Sym = J->lookup(JD, Name))
95-
dbgs() << formatv("{0:x}\n", Sym->getAddress());
95+
dbgs() << *Sym;
9696
else
9797
dbgs() << "error: " << toString(Sym.takeError()) << "\n";
9898
};

llvm/examples/OrcV2Examples/LLJITWithCustomObjectLinkingLayer/LLJITWithCustomObjectLinkingLayer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ int main(int argc, char *argv[]) {
5656
ExitOnErr(J->addIRModule(std::move(M)));
5757

5858
// Look up the JIT'd function, cast it to a function pointer, then call it.
59-
auto Add1Sym = ExitOnErr(J->lookup("add1"));
60-
int (*Add1)(int) = (int (*)(int))Add1Sym.getAddress();
59+
auto Add1Addr = ExitOnErr(J->lookup("add1"));
60+
int (*Add1)(int) = Add1Addr.toPtr<int(int)>();
6161

6262
int Result = Add1(42);
6363
outs() << "add1(42) = " << Result << "\n";

llvm/examples/OrcV2Examples/LLJITWithExecutorProcessControl/LLJITWithExecutorProcessControl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ int main(int argc, char *argv[]) {
187187
// arguments passed.
188188

189189
// Look up the JIT'd function, cast it to a function pointer, then call it.
190-
auto EntrySym = ExitOnErr(J->lookup("entry"));
191-
auto *Entry = (int (*)(int))EntrySym.getAddress();
190+
auto EntryAddr = ExitOnErr(J->lookup("entry"));
191+
auto *Entry = EntryAddr.toPtr<int(int)>();
192192

193193
int Result = Entry(argc);
194194
outs() << "---Result---\n"

llvm/examples/OrcV2Examples/LLJITWithGDBRegistrationListener/LLJITWithGDBRegistrationListener.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,8 @@ int main(int argc, char *argv[]) {
108108

109109
// Look up the entry point, cast it to a C main function pointer, then use
110110
// runAsMain to call it.
111-
auto EntrySym = ExitOnErr(J->lookup(EntryPointName));
112-
auto EntryFn =
113-
jitTargetAddressToFunction<int (*)(int, char *[])>(EntrySym.getAddress());
111+
auto EntryAddr = ExitOnErr(J->lookup(EntryPointName));
112+
auto EntryFn = EntryAddr.toPtr<int(int, char *[])>();
114113

115114
return runAsMain(EntryFn, InputArgv, StringRef(InputFiles.front()));
116115
}

llvm/examples/OrcV2Examples/LLJITWithLazyReexports/LLJITWithLazyReexports.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ int main(int argc, char *argv[]) {
152152
// arguments passed.
153153

154154
// Look up the JIT'd function, cast it to a function pointer, then call it.
155-
auto EntrySym = ExitOnErr(J->lookup("entry"));
156-
auto *Entry = (int (*)(int))EntrySym.getAddress();
155+
auto EntryAddr = ExitOnErr(J->lookup("entry"));
156+
auto *Entry = EntryAddr.toPtr<int(int)>();
157157

158158
int Result = Entry(argc);
159159
outs() << "---Result---\n"

llvm/examples/OrcV2Examples/LLJITWithObjectCache/LLJITWithObjectCache.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ void runJITWithCache(ObjectCache &ObjCache) {
6969
ExitOnErr(J->addIRModule(std::move(M)));
7070

7171
// Look up the JIT'd function, cast it to a function pointer, then call it.
72-
auto Add1Sym = ExitOnErr(J->lookup("add1"));
73-
int (*Add1)(int) = (int (*)(int))Add1Sym.getAddress();
72+
auto Add1Addr = ExitOnErr(J->lookup("add1"));
73+
int (*Add1)(int) = Add1Addr.toPtr<int(int)>();
7474

7575
int Result = Add1(42);
7676
outs() << "add1(42) = " << Result << "\n";

llvm/examples/OrcV2Examples/LLJITWithObjectLinkingLayerPlugin/LLJITWithObjectLinkingLayerPlugin.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,8 @@ int main(int argc, char *argv[]) {
241241
}
242242

243243
// Look up the JIT'd function, cast it to a function pointer, then call it.
244-
auto EntrySym = ExitOnErr(J->lookup(EntryPointName));
245-
auto *Entry = (int (*)())EntrySym.getAddress();
244+
auto EntryAddr = ExitOnErr(J->lookup(EntryPointName));
245+
auto *Entry = EntryAddr.toPtr<int()>();
246246

247247
int Result = Entry();
248248
outs() << "---Result---\n"

0 commit comments

Comments
 (0)