This is an archive of the discontinued LLVM Phabricator instance.

[LTO] Fix error reporting from lto_module_create_in_local_context()
ClosedPublic

Authored by petpav01 on Feb 29 2016, 5:44 AM.

Details

Summary

Function lto_module_create_in_local_context() would previously rely on the default LLVMContext being created for it by LTOModule::makeLTOModule(). This context exits the program on error and is not arranged to update sLastStringError in tools/lto/lto.cpp.

Function lto_module_create_in_local_context() now creates an LLVMContext by itself, sets it up correctly to its needs and then passes it to LTOModule::createInLocalContext() which takes ownership of the context and keeps it present for the lifetime of the returned LTOModule.

Function LTOModule::makeLTOModule() is modified to take a reference to LLVMContext (instead of a pointer) and no longer creates a default context when nullptr is passed to it. Method LTOModule::createInContext() that takes a pointer to LLVMContext is removed because it allows to pass a nullptr to it. Instead LTOModule::createFromBuffer() (that takes a reference to LLVMContext) should be used.

Diff Detail

Event Timeline

petpav01 updated this revision to Diff 49361.Feb 29 2016, 5:44 AM
petpav01 retitled this revision from to [LTO] Fix error reporting from lto_module_create_in_local_context().
petpav01 updated this object.
petpav01 added a subscriber: llvm-commits.
rafael added a subscriber: rafael.

I really like it, thanks!

I will leave the final LGTM to Duncan or some other Apple to make sure it works for them.

dexonsmith edited edge metadata.Feb 29 2016, 9:07 AM
dexonsmith added a subscriber: dexonsmith.

LGTM. Thanks for the fix!

This revision was automatically updated to reflect the committed changes.