[llvm] r336178 - [ADT] Disable the single callback optimization on Windows.
Chandler Carruth via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 3 01:19:11 PDT 2018
Author: chandlerc
Date: Tue Jul 3 01:19:10 2018
New Revision: 336178
URL: http://llvm.org/viewvc/llvm-project?rev=336178&view=rev
Log:
[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.
Modified:
llvm/trunk/include/llvm/ADT/FunctionExtras.h
Modified: llvm/trunk/include/llvm/ADT/FunctionExtras.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/FunctionExtras.h?rev=336178&r1=336177&r2=336178&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/FunctionExtras.h (original)
+++ llvm/trunk/include/llvm/ADT/FunctionExtras.h Tue Jul 3 01:19:10 2018
@@ -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
More information about the llvm-commits
mailing list