This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGed5b42b74188: Fix address space for function pointers with 
qualifier (authored by eandrews).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D119045?vs=406124&id=406580#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119045/new/

https://reviews.llvm.org/D119045

Files:
  clang/lib/AST/ASTContext.cpp
  clang/test/CodeGen/address-space-ptr32.c


Index: clang/test/CodeGen/address-space-ptr32.c
===================================================================
--- /dev/null
+++ clang/test/CodeGen/address-space-ptr32.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -emit-llvm < %s 
| FileCheck %s
+
+int foo(void) {
+  int (*__ptr32 a)(int);
+  return sizeof(a);
+}
+
+// CHECK: define dso_local i32 @foo
+// CHECK: %a = alloca i32 (i32) addrspace(270)*, align 4
+// CHECK: ret i32 4
Index: clang/lib/AST/ASTContext.cpp
===================================================================
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -11959,8 +11959,13 @@
 }
 
 unsigned ASTContext::getTargetAddressSpace(QualType T) const {
-  return T->isFunctionType() ? getTargetInfo().getProgramAddressSpace()
-                             : getTargetAddressSpace(T.getQualifiers());
+  // Return the address space for the type. If the type is a
+  // function type without an address space qualifier, the
+  // program address space is used. Otherwise, the target picks
+  // the best address space based on the type information
+  return T->isFunctionType() && !T.hasAddressSpace()
+             ? getTargetInfo().getProgramAddressSpace()
+             : getTargetAddressSpace(T.getQualifiers());
 }
 
 unsigned ASTContext::getTargetAddressSpace(Qualifiers Q) const {


Index: clang/test/CodeGen/address-space-ptr32.c
===================================================================
--- /dev/null
+++ clang/test/CodeGen/address-space-ptr32.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-windows-msvc -fms-extensions -emit-llvm < %s | FileCheck %s
+
+int foo(void) {
+  int (*__ptr32 a)(int);
+  return sizeof(a);
+}
+
+// CHECK: define dso_local i32 @foo
+// CHECK: %a = alloca i32 (i32) addrspace(270)*, align 4
+// CHECK: ret i32 4
Index: clang/lib/AST/ASTContext.cpp
===================================================================
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -11959,8 +11959,13 @@
 }
 
 unsigned ASTContext::getTargetAddressSpace(QualType T) const {
-  return T->isFunctionType() ? getTargetInfo().getProgramAddressSpace()
-                             : getTargetAddressSpace(T.getQualifiers());
+  // Return the address space for the type. If the type is a
+  // function type without an address space qualifier, the
+  // program address space is used. Otherwise, the target picks
+  // the best address space based on the type information
+  return T->isFunctionType() && !T.hasAddressSpace()
+             ? getTargetInfo().getProgramAddressSpace()
+             : getTargetAddressSpace(T.getQualifiers());
 }
 
 unsigned ASTContext::getTargetAddressSpace(Qualifiers Q) const {
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to