Index: test/CodeGenCXX/mangle.cpp
===================================================================
--- test/CodeGenCXX/mangle.cpp	(revision 173951)
+++ test/CodeGenCXX/mangle.cpp	(working copy)
@@ -872,3 +872,6 @@
     func(foo().d);
   }
 }
+
+// CHECK: define void @_Z6ASfuncPU3AS3i
+void ASfunc(__attribute__((address_space(3))) int* x) {}
Index: test/CodeGenOpenCL/local.cl
===================================================================
--- test/CodeGenOpenCL/local.cl	(revision 173951)
+++ test/CodeGenOpenCL/local.cl	(working copy)
@@ -5,3 +5,8 @@
   __local int i;
   ++i;
 }
+
+// CHECK: define void @_Z3barPU3AS2i
+__kernel void __attribute__((__overloadable__)) bar(local int *x) {
+  *x = 5;
+}
Index: lib/AST/ItaniumMangle.cpp
===================================================================
--- lib/AST/ItaniumMangle.cpp	(revision 173951)
+++ lib/AST/ItaniumMangle.cpp	(working copy)
@@ -1668,7 +1668,8 @@
     // where <address-space-number> is a source name consisting of 'AS' 
     // followed by the address space <number>.
     SmallString<64> ASString;
-    ASString = "AS" + llvm::utostr_32(Quals.getAddressSpace());
+    ASString = "AS" + llvm::utostr_32(
+        Context.getASTContext().getTargetAddressSpace(Quals.getAddressSpace()));
     Out << 'U' << ASString.size() << ASString;
   }
   
