[llvm] r279225 - [PM] Try to work-around what appears to be an MSVC SFINAE issue with

Chandler Carruth via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 19 02:26:00 PDT 2016


Author: chandlerc
Date: Fri Aug 19 04:26:00 2016
New Revision: 279225

URL: http://llvm.org/viewvc/llvm-project?rev=279225&view=rev
Log:
[PM] Try to work-around what appears to be an MSVC SFINAE issue with
r279217 where it fails to select the path that other compilers select.

The workaround won't be as careful to produce an error when an analysis
result is incorrect, but we can rely on non-MSVC builds to catch such
errors it seems and MSVC doesn't seem to support the alternative
techniques.

Hoping this brings the windows bots back to life. If not, will have to
revert all of this.

Modified:
    llvm/trunk/include/llvm/IR/PassManagerInternal.h

Modified: llvm/trunk/include/llvm/IR/PassManagerInternal.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/PassManagerInternal.h?rev=279225&r1=279224&r2=279225&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/PassManagerInternal.h (original)
+++ llvm/trunk/include/llvm/IR/PassManagerInternal.h Fri Aug 19 04:26:00 2016
@@ -99,6 +99,15 @@ template <typename IRUnitT, typename Res
     char a, b;
   };
 
+  // Purely to help out MSVC which fails to disable the below specialization,
+  // explicitly enable using the result type's invalidate routine if we can
+  // successfully call that routine.
+  template <typename T> struct Nonce { typedef EnabledType Type; };
+  template <typename T>
+  static typename Nonce<decltype(std::declval<T>().invalidate(
+      std::declval<IRUnitT &>(), std::declval<PreservedAnalyses>()))>::Type
+      check(rank<2>);
+
   // First we define an overload that can only be taken if there is no
   // invalidate member. We do this by taking the address of an invalidate
   // member in an adjacent base class of a derived class. This would be
@@ -115,7 +124,7 @@ template <typename IRUnitT, typename Res
   static EnabledType check(rank<0>);
 
 public:
-  enum { Value = sizeof(check<ResultT>(rank<1>())) == sizeof(EnabledType) };
+  enum { Value = sizeof(check<ResultT>(rank<2>())) == sizeof(EnabledType) };
 };
 
 /// \brief Wrapper to model the analysis result concept.




More information about the llvm-commits mailing list