[ADT] Disable the single callback optimization on Windows.

It appears that the function pointer we use there isn't reliably 4-byte
aligned. I have no idea why or how we could correct this, so for now we
just regress the Windows performance some.

Someone with access to Windows could try working on a fix. At the very
least we could use a double indirection rather than a table, but maybe
there is some way to fully restore this optimization. I don't want to
play too much with this when I don't have access to the platform and
this at least should restore the last bots.

llvm-svn: 336178
This commit is contained in:
Chandler Carruth 2018-07-03 08:19:10 +00:00
parent 3f0243fdaf
commit 7f3feec6bb
1 changed files with 17 additions and 1 deletions

View File

@ -243,8 +243,23 @@ public:
// Now move into the storage.
new (CallableAddr) CallableT(std::move(Callable));
#ifndef _MSC_VER
// See if we can create a trivial callback.
// FIXME: we should use constexpr if here and below to avoid instantiating
//
// This requires two things. First, we need to put a function pointer into
// a `PointerIntPair` and a `PointerUnion`. We assume that function
// pointers on almost every platform have at least 4-byte alignment which
// allows this to work, but on some platforms this appears to not hold, and
// so we need to disable this optimization on those platforms.
//
// FIXME: Currently, Windows appears to fail the asserts that check this.
// We should investigate why, and if fixed removed the #ifndef above.
//
// Second, we need the callable to be trivially moved and trivially
// destroyed so that we don't have to store type erased callbacks for those
// operations.
//
// FIXME: We should use constexpr if here and below to avoid instantiating
// the non-trivial static objects when unnecessary. While the linker should
// remove them, it is still wasteful.
if (llvm::is_trivially_move_constructible<CallableT>::value &&
@ -252,6 +267,7 @@ public:
CallbackAndInlineFlag = {&CallImpl<CallableT>, IsInlineStorage};
return;
}
#endif
// Otherwise, we need to point at an object with a vtable that contains all
// the different type erased behaviors needed. Create a static instance of