Index: lib/Sema/SemaDeclAttr.cpp
===================================================================
--- lib/Sema/SemaDeclAttr.cpp	(revision 163328)
+++ lib/Sema/SemaDeclAttr.cpp	(working copy)
@@ -3640,6 +3640,17 @@
   default: llvm_unreachable("unexpected attribute kind");
   }
 
+  // If we're compiling for Windows x64 , we want to treat __stdcall as though
+  // the user did not specify any calling convention.  This is documented 
+  // behavior on MSDN:
+  // http://msdn.microsoft.com/en-us/library/zxk0tw93(v=vs.110).aspx and 
+  // matches how MSVC and mingw-w64-gcc behave semantically.
+  if (CC == CC_X86StdCall) {
+    llvm::Triple T = Context.getTargetInfo().getTriple();
+    if (T.isArch64Bit() && T.isOSWindows())
+      CC = CC_Default;
+  }
+
   return false;
 }
 
Index: test/CodeGen/microsoft-call-conv.c
===================================================================
--- test/CodeGen/microsoft-call-conv.c	(revision 163328)
+++ test/CodeGen/microsoft-call-conv.c	(working copy)
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -emit-llvm < %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-pc-win32 -fms-compatibility -emit-llvm < %s | FileCheck -check-prefix X64 %s
 
 void __fastcall f1(void);
 void __stdcall f2(void);
@@ -10,8 +11,10 @@
 }
 void __stdcall f5(void) {
 // CHECK: define x86_stdcallcc void @f5()
+// X64: define void @f5()
   f2();
 // CHECK: call x86_stdcallcc void @f2()
+// X64: call void @f2()
 }
 void __thiscall f6(void) {
 // CHECK: define x86_thiscallcc void @f6()
@@ -32,6 +35,7 @@
     // CHECK: call x86_fastcallcc void @f4()
     // CHECK: call x86_stdcallcc void @f5()
     // CHECK: call x86_thiscallcc void @f6()
+    // X64: call void @f5()
     pf1(); pf2(); pf3(); pf4(); pf5(); pf6();
     // CHECK: call x86_fastcallcc void %{{.*}}()
     // CHECK: call x86_stdcallcc void %{{.*}}()
Index: test/CodeGenCXX/mangle-ms.cpp
===================================================================
--- test/CodeGenCXX/mangle-ms.cpp	(revision 163328)
+++ test/CodeGenCXX/mangle-ms.cpp	(working copy)
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fms-extensions -fblocks -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s
+// RUN: %clang_cc1 -fms-compatibility -fblocks -emit-llvm %s -o - -cxx-abi microsoft -triple=x86_64-pc-win32 | FileCheck -check-prefix X64 %s
 
 // CHECK: @"\01?a@@3HA"
 // CHECK: @"\01?b@N@@3HA"
@@ -109,6 +110,7 @@
 }
 
 // CHECK: @"\01?alpha@@YGXMN@Z"
+// X64: @"\01?alpha@@YAXMN@Z"
 
 // Make sure tag-type mangling works.
 void gamma(class foo, struct bar, union baz, enum quux) {}
Index: test/Sema/MicrosoftCompatibility-x64.c
===================================================================
--- test/Sema/MicrosoftCompatibility-x64.c	(revision 0)
+++ test/Sema/MicrosoftCompatibility-x64.c	(working copy)
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-compatibility -triple x86_64-pc-win32
+int __stdcall f(void);
+
+/* This should compile without warning because __stdcall is treated
+as __cdecl in MS compatibility mode for x64 compiles*/
+int __cdecl f(void) {
+  return 0;
+}
Index: test/Sema/MicrosoftCompatibility.c
===================================================================
--- test/Sema/MicrosoftCompatibility.c	(revision 163328)
+++ test/Sema/MicrosoftCompatibility.c	(working copy)
@@ -18,4 +18,10 @@
 __declspec(align(32768)) struct S1 { int a; } s;	/* expected-error {{requested alignment must be 8192 bytes or smaller}} */
 struct __declspec(aligned) S2 {}; /* expected-warning {{unknown __declspec attribute 'aligned' ignored}} */
 
-struct __declspec(appdomain) S3 {}; /* expected-warning {{__declspec attribute 'appdomain' is not supported}} */
\ No newline at end of file
+struct __declspec(appdomain) S3 {}; /* expected-warning {{__declspec attribute 'appdomain' is not supported}} */
+
+int __stdcall f(void); /* expected-note {{previous declaration is here}} */
+
+int __cdecl f(void) { /* expected-error {{function declared 'cdecl' here was previously declared 'stdcall'}} */
+  return 0;
+}
