[PATCH] D119045: Fix address space for function types with AS qualifier
Elizabeth Andrews via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 7 12:54:35 PST 2022
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 {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119045.406580.patch
Type: text/x-patch
Size: 1371 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220207/5bb0d6c5/attachment.bin>
More information about the cfe-commits
mailing list