[Windows] Abstract pure virtual method calls in the ABI. Fix the Windows ABI to forward to the correct function.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160373 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGCXXABI.h b/lib/CodeGen/CGCXXABI.h
index 4767205..a0dcdfd 100644
--- a/lib/CodeGen/CGCXXABI.h
+++ b/lib/CodeGen/CGCXXABI.h
@@ -193,6 +193,9 @@
   virtual void EmitReturnFromThunk(CodeGenFunction &CGF,
                                    RValue RV, QualType ResultType);
 
+  /// Gets the pure virtual member call function.
+  virtual StringRef GetPureVirtualCallName() = 0;
+
   /**************************** Array cookies ******************************/
 
   /// Returns the extra size required in order to store the array
diff --git a/lib/CodeGen/CGVTables.cpp b/lib/CodeGen/CGVTables.cpp
index 0d3d023..c2c42f6 100644
--- a/lib/CodeGen/CGVTables.cpp
+++ b/lib/CodeGen/CGVTables.cpp
@@ -569,15 +569,15 @@
 
       if (cast<CXXMethodDecl>(GD.getDecl())->isPure()) {
         // We have a pure virtual member function.
-        if (!PureVirtualFn) {
-          llvm::FunctionType *Ty = 
-            llvm::FunctionType::get(CGM.VoidTy, /*isVarArg=*/false);
-          PureVirtualFn = 
-            CGM.CreateRuntimeFunction(Ty, "__cxa_pure_virtual");
-          PureVirtualFn = llvm::ConstantExpr::getBitCast(PureVirtualFn, 
-                                                         Int8PtrTy);
+        if (!PureVirtualFn ) {
+            llvm::FunctionType *Ty = 

+                llvm::FunctionType::get(CGM.VoidTy, /*isVarArg=*/false);

+            StringRef PureCallName = CGM.getCXXABI().GetPureVirtualCallName();

+            PureVirtualFn = CGM.CreateRuntimeFunction(Ty, PureCallName);

+            PureVirtualFn = llvm::ConstantExpr::getBitCast(PureVirtualFn,

+                                                        CGM.Int8PtrTy);
         }
-        
+
         Init = PureVirtualFn;
       } else {
         // Check if we should use a thunk.
diff --git a/lib/CodeGen/ItaniumCXXABI.cpp b/lib/CodeGen/ItaniumCXXABI.cpp
index 8800e68..0b7ce36 100644
--- a/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/lib/CodeGen/ItaniumCXXABI.cpp
@@ -108,6 +108,8 @@
 
   void EmitInstanceFunctionProlog(CodeGenFunction &CGF);
 
+  StringRef GetPureVirtualCallName() { return "__cxa_pure_virtual"; }
+
   CharUnits getArrayCookieSizeImpl(QualType elementType);
   llvm::Value *InitializeArrayCookie(CodeGenFunction &CGF,
                                      llvm::Value *NewPtr,
diff --git a/lib/CodeGen/MicrosoftCXXABI.cpp b/lib/CodeGen/MicrosoftCXXABI.cpp
index 026f2a5..6a2925b 100644
--- a/lib/CodeGen/MicrosoftCXXABI.cpp
+++ b/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -28,6 +28,8 @@
 public:
   MicrosoftCXXABI(CodeGenModule &CGM) : CGCXXABI(CGM) {}
 
+  StringRef GetPureVirtualCallName() { return "_purecall"; }
+
   void BuildConstructorSignature(const CXXConstructorDecl *Ctor,
                                  CXXCtorType Type,
                                  CanQualType &ResTy,