forked from OSchip/llvm-project
Fix address space for function pointers with qualifier
This patch fixes a bug introduced in commit4eaf5846d0
. Commit4eaf5846d0
sets address space of function type as program address space unconditionally. This breaks types which have address space qualifiers. E.g. __ptr32. This patch fixes the bug by using address space qualifiers if present. Differential Revision: https://reviews.llvm.org/D119045
This commit is contained in:
parent
fc6bee1c11
commit
ed5b42b741
|
@ -11959,8 +11959,13 @@ uint64_t ASTContext::getTargetNullPointerValue(QualType QT) const {
|
|||
}
|
||||
|
||||
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 {
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue