Skip to content

Commit 5cd93ef

Browse files
committed
add xfail and assertion
1 parent bc2f05a commit 5cd93ef

File tree

4 files changed

+11
-16
lines changed

4 files changed

+11
-16
lines changed

clang/include/clang/CIR/Dialect/IR/CIRAttrs.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,9 @@ def AddressSpaceAttr : CIR_Attr<"AddressSpace", "addrspace"> {
729729

730730
std::optional<int32_t>
731731
$cppClass::getValueFromLangAS(clang::LangAS langAS) {
732+
assert((langAS == clang::LangAS::Default ||
733+
clang::isTargetAddressSpace(langAS)) &&
734+
"Language-specific address spaces are not supported");
732735
switch (langAS) {
733736
}]
734737
#

clang/lib/CIR/CodeGen/CIRGenTypes.cpp

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -605,14 +605,7 @@ mlir::Type CIRGenTypes::ConvertType(QualType T) {
605605
const ReferenceType *RTy = cast<ReferenceType>(Ty);
606606
QualType ETy = RTy->getPointeeType();
607607
auto PointeeType = convertTypeForMem(ETy);
608-
// TODO(cir): when address space mapping in CIR lowering is implemented,
609-
// passthrough these non-target address spaces like `opencl_global`
610-
assert(!MissingFeatures::targetLoweringInfoAddressSpaceMap());
611-
// Here we convert them to target AS ahead of time
612-
LangAS langAS = ETy.getAddressSpace();
613-
if (langAS != LangAS::Default)
614-
langAS = getLangASFromTargetAS(Context.getTargetAddressSpace(langAS));
615-
ResultType = Builder.getPointerTo(PointeeType, langAS);
608+
ResultType = Builder.getPointerTo(PointeeType, ETy.getAddressSpace());
616609
assert(ResultType && "Cannot get pointer type?");
617610
break;
618611
}
@@ -627,14 +620,7 @@ mlir::Type CIRGenTypes::ConvertType(QualType T) {
627620
// if (PointeeType->isVoidTy())
628621
// PointeeType = Builder.getI8Type();
629622

630-
// TODO(cir): when address space mapping in CIR lowering is implemented,
631-
// passthrough these non-target address spaces like `opencl_global`
632-
assert(!MissingFeatures::targetLoweringInfoAddressSpaceMap());
633-
// Here we convert them to target AS ahead of time
634-
LangAS langAS = ETy.getAddressSpace();
635-
if (langAS != LangAS::Default)
636-
langAS = getLangASFromTargetAS(Context.getTargetAddressSpace(langAS));
637-
ResultType = Builder.getPointerTo(PointeeType, langAS);
623+
ResultType = Builder.getPointerTo(PointeeType, ETy.getAddressSpace());
638624
assert(ResultType && "Cannot get pointer type?");
639625
break;
640626
}

clang/test/CIR/CodeGen/OpenCL/addrspace-alloca.cl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
// RUN: %clang_cc1 -cl-std=CL3.0 -O0 -fclangir -emit-llvm -triple spirv64-unknown-unknown %s -o %t.ll
44
// RUN: FileCheck --input-file=%t.ll %s --check-prefix=LLVM
55

6+
// Lowering of language-specific AS not supported
7+
// XFAIL: *
8+
69
// CIR: cir.func @func(%arg0: !cir.ptr<!s32i, addrspace(target<3>)>
710
// LLVM: @func(ptr addrspace(3)
811
kernel void func(local int *p) {

clang/test/CIR/CodeGen/OpenCL/spirv-target.cl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
// RUN: %clang_cc1 -cl-std=CL3.0 -fclangir -emit-llvm -triple spirv64-unknown-unknown %s -o %t_64.ll
55
// RUN: FileCheck --input-file=%t_64.ll %s --check-prefix=LLVM-SPIRV64
66

7+
// Lowering of language-specific AS not supported
8+
// XFAIL: *
9+
710
// CIR-SPIRV64: cir.triple = "spirv64-unknown-unknown"
811
// LLVM-SPIRV64: target triple = "spirv64-unknown-unknown"
912

0 commit comments

Comments
 (0)