[PATCH] D115260: KaleidoscopeJIT example code dangling std::unique_ptr issue
7mile via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 7 09:16:00 PST 2021
7mile created this revision.
7mile added a reviewer: lhames.
7mile requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
In the example code for Chapter 4, we found:
cpp
// EPC: Expected<std::unique_ptr<...>>
auto EPC = SelfExecutorProcessControl::Create();
// ...
auto ES = std::make_unique<ExecutionSession>(std::move(*EPC)); // EPC is moved here
// ...
JITTargetMachineBuilder JTMB((*EPC)->getTargetTriple()); // invalid access
But in KaleidoscopeJIT Chapter 1,2,3 and the include file outside the chapter, this part is
cpp
JITTargetMachineBuilder JTMB(
ES->getExecutorProcessControl().getTargetTriple()); // access from the owner
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D115260
Files:
llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h
Index: llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h
===================================================================
--- llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h
+++ llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h
@@ -186,7 +186,8 @@
if (auto Err = setUpInProcessLCTMReentryViaEPCIU(**EPCIU))
return std::move(Err);
- JITTargetMachineBuilder JTMB((*EPC)->getTargetTriple());
+ JITTargetMachineBuilder JTMB(
+ ES->getExecutorProcessControl().getTargetTriple());
auto DL = JTMB.getDefaultDataLayoutForTarget();
if (!DL)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115260.392433.patch
Type: text/x-patch
Size: 627 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211207/91b10277/attachment.bin>
More information about the llvm-commits
mailing list