Skip to content

Commit 768a741

Browse files
committed
Verify bitcast does not contain address space conversion
1 parent baaea0b commit 768a741

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

clang/lib/CIR/Dialect/IR/CIRDialect.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,10 @@ LogicalResult cir::CastOp::verify() {
423423
auto resPtrTy = mlir::dyn_cast<cir::PointerType>(resType);
424424

425425
if (srcPtrTy && resPtrTy) {
426-
return success();
426+
if (srcPtrTy.getAddrSpace() != resPtrTy.getAddrSpace()) {
427+
return emitOpError() << "result type address space does not match the "
428+
"address space of the operand";
429+
}
427430
}
428431

429432
return success();

clang/test/CIR/IR/invalid-addrspace.cir

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,3 @@ cir.func @address_space2(%p : !cir.ptr<!u64i, target_address_space>) {
2424
cir.func @address_space3(%p : !cir.ptr<!u64i, target_address_space()>) {
2525
cir.return
2626
}
27-

0 commit comments

Comments
 (0)