diff --git a/mlir/lib/Target/LLVMIR/Dialect/OpenACC/OpenACCToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/OpenACC/OpenACCToLLVMIRTranslation.cpp --- a/mlir/lib/Target/LLVMIR/Dialect/OpenACC/OpenACCToLLVMIRTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/Dialect/OpenACC/OpenACCToLLVMIRTranslation.cpp @@ -40,6 +40,8 @@ static constexpr uint64_t kCopyFlag = kDeviceCopyinFlag | kHostCopyoutFlag; static constexpr uint64_t kPresentFlag = 0x1000; static constexpr uint64_t kDeleteFlag = 0x008; +// Runtime extension to implement the OpenACC second reference counter. +static constexpr uint64_t kHoldFlag = 0x2000; /// Default value for the device id static constexpr int64_t kDefaultDevice = -1; @@ -307,51 +309,54 @@ // TODO handle no_create, deviceptr and attach operands. if (failed(processOperands(builder, moduleTranslation, op, op.copyOperands(), - totalNbOperand, kCopyFlag, flags, names, index, - mapperAllocas))) + totalNbOperand, kCopyFlag | kHoldFlag, flags, + names, index, mapperAllocas))) return failure(); if (failed(processOperands( builder, moduleTranslation, op, op.copyinOperands(), totalNbOperand, - kDeviceCopyinFlag, flags, names, index, mapperAllocas))) + kDeviceCopyinFlag | kHoldFlag, flags, names, index, mapperAllocas))) return failure(); // TODO copyin readonly currenlty handled as copyin. Update when extension // available. if (failed(processOperands(builder, moduleTranslation, op, op.copyinReadonlyOperands(), totalNbOperand, - kDeviceCopyinFlag, flags, names, index, + kDeviceCopyinFlag | kHoldFlag, flags, names, index, mapperAllocas))) return failure(); if (failed(processOperands( builder, moduleTranslation, op, op.copyoutOperands(), totalNbOperand, - kHostCopyoutFlag, flags, names, index, mapperAllocas))) + kHostCopyoutFlag | kHoldFlag, flags, names, index, mapperAllocas))) return failure(); // TODO copyout zero currenlty handled as copyout. Update when extension // available. if (failed(processOperands(builder, moduleTranslation, op, op.copyoutZeroOperands(), totalNbOperand, - kHostCopyoutFlag, flags, names, index, + kHostCopyoutFlag | kHoldFlag, flags, names, index, mapperAllocas))) return failure(); if (failed(processOperands(builder, moduleTranslation, op, - op.createOperands(), totalNbOperand, kCreateFlag, - flags, names, index, mapperAllocas))) + op.createOperands(), totalNbOperand, + kCreateFlag | kHoldFlag, flags, names, index, + mapperAllocas))) return failure(); // TODO create zero currenlty handled as create. Update when extension // available. if (failed(processOperands(builder, moduleTranslation, op, op.createZeroOperands(), totalNbOperand, - kCreateFlag, flags, names, index, mapperAllocas))) + kCreateFlag | kHoldFlag, flags, names, index, + mapperAllocas))) return failure(); if (failed(processOperands(builder, moduleTranslation, op, - op.presentOperands(), totalNbOperand, kPresentFlag, - flags, names, index, mapperAllocas))) + op.presentOperands(), totalNbOperand, + kPresentFlag | kHoldFlag, flags, names, index, + mapperAllocas))) return failure(); llvm::GlobalVariable *maptypes = diff --git a/mlir/test/Target/LLVMIR/openacc-llvm.mlir b/mlir/test/Target/LLVMIR/openacc-llvm.mlir --- a/mlir/test/Target/LLVMIR/openacc-llvm.mlir +++ b/mlir/test/Target/LLVMIR/openacc-llvm.mlir @@ -208,7 +208,7 @@ // CHECK: [[LOCGLOBAL:@.*]] = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([{{[0-9]*}} x i8], [{{[0-9]*}} x i8]* [[LOCSTR]], i32 0, i32 0) }, align 8 // CHECK: [[MAPNAME1:@.*]] = private unnamed_addr constant [{{[0-9]*}} x i8] c";{{.*}};unknown;{{[0-9]*}};{{[0-9]*}};;\00", align 1 // CHECK: [[MAPNAME2:@.*]] = private unnamed_addr constant [{{[0-9]*}} x i8] c";{{.*}};unknown;{{[0-9]*}};{{[0-9]*}};;\00", align 1 -// CHECK: [[MAPTYPES:@.*]] = private unnamed_addr constant [{{[0-9]*}} x i64] [i64 3, i64 2] +// CHECK: [[MAPTYPES:@.*]] = private unnamed_addr constant [{{[0-9]*}} x i64] [i64 8195, i64 8194] // CHECK: [[MAPNAMES:@.*]] = private constant [{{[0-9]*}} x i8*] [i8* getelementptr inbounds ([{{[0-9]*}} x i8], [{{[0-9]*}} x i8]* [[MAPNAME1]], i32 0, i32 0), i8* getelementptr inbounds ([{{[0-9]*}} x i8], [{{[0-9]*}} x i8]* [[MAPNAME2]], i32 0, i32 0)] // CHECK: define void @testdataop({ float*, float*, i64, [1 x i64], [1 x i64] } %{{.*}}, float* [[SIMPLEPTR:%.*]], i32* %{{.*}})