[llvm] [JIT] Fix crash in unit tests (PR #113492)

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 24 09:30:56 PDT 2024


lhames wrote:

Thanks for answering those questions.

I think there's an even easier solution here: We can hoist the creator functions up into the named constructor and then pass them into the regular constructor, which would no longer be able to error out:

```c++
static Expected<std::unique_ptr<RedirectableSymbolManager>>
Create(ObjectLinkingLayer &ObjLinkingLayer, JITDylib &JD) {
  auto AnonymousPtrCreator(jitlink::getAnonymousPointerCreator(
    ObjLinkingLayer.getExecutionSession().getTargetTriple()));
  auto PtrJumpStubCreator(jitlink::getPointerJumpStubCreator(
    ObjLinkingLayer.getExecutionSession().getTargetTriple()));
  if (!AnonymousPtrCreator || !PtrJumpStubCreator)
    return make_error<StringError>("Architecture not supported",
                                    inconvertibleErrorCode());
  return std::unique_ptr<RedirectableSymbolManager>(
      new JITLinkRedirectableSymbolManager(ObjLinkingLayer, JD,
      AnonymousPtrCreator, PtrJumpStubCreator));
}
```

https://github.com/llvm/llvm-project/pull/113492


More information about the llvm-commits mailing list