This is an archive of the discontinued LLVM Phabricator instance.

Fix ordering of PassExtension registry and LibraryHandles registry construction
AbandonedPublic

Authored by serge-sans-paille on Jan 10 2020, 1:18 AM.

Details

Summary

Fix ordering of PassExtension registry and LibraryHandles registry construction

Because PassExtension registry (may) hold reference to function obtained through
dlsym, it must be constructed *after* the libraryHandles. To enforce that order, the ManagedStatic holding the library handles is dereferenced (hence constructed) before each call ro the PassExtension registry.

This effectively fixes llvm/test/Feature/load_extension.ll that exhibit the
problem when Polly is linked statically within LLVM.

Diff Detail

Event Timeline

With this patch applied, I've validated on OSX and Linux that load_extension.ll passes the validation with Polly linked both statically and dynamically.

lebedev.ri added a subscriber: lebedev.ri.

Not really the code i know.
Can you spell out in the description *why* void DynamicLibrary::ensureConstructed() { (void)*OpenedHandles; } solves the issue?
Adding some more potential reviewers.

serge-sans-paille edited the summary of this revision. (Show Details)Jan 14 2020, 1:41 AM

I suspect D71959 tries to solve the same problem