LLVM::AddressOfOp: properly take into account the address space
The AddressOf operation in the LLVM dialect return a pointer to a global variable. The latter may be in a non-default address space as indicated by the "addr_space" attribute. Check that the address space of the pointer returned by AddressOfOp matches that of the referenced GlobalOp. Update the AddressOfOp builder to respect this constraint. PiperOrigin-RevId: 284138860 Change-Id: I2ada419c22b4ba7ac0788cefff199123e4634344
This commit is contained in:
parent
f62a214c22
commit
acb8b516ee
@ -509,8 +509,9 @@ def LLVM_AddressOfOp
|
||||
|
||||
OpBuilder<"Builder *builder, OperationState &result, GlobalOp global, "
|
||||
"ArrayRef<NamedAttribute> attrs = {}", [{
|
||||
build(builder, result, global.getType().getPointerTo(), global.sym_name(),
|
||||
attrs);}]>
|
||||
build(builder, result,
|
||||
global.getType().getPointerTo(global.addr_space().getZExtValue()),
|
||||
global.sym_name(), attrs);}]>
|
||||
];
|
||||
|
||||
let extraClassDeclaration = [{
|
||||
|
@ -825,7 +825,8 @@ static LogicalResult verify(AddressOfOp op) {
|
||||
return op.emitOpError(
|
||||
"must reference a global defined by 'llvm.mlir.global'");
|
||||
|
||||
if (global.getType().getPointerTo() != op.getResult()->getType())
|
||||
if (global.getType().getPointerTo(global.addr_space().getZExtValue()) !=
|
||||
op.getResult()->getType())
|
||||
return op.emitOpError(
|
||||
"the type must be a pointer to the type of the referred global");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user