[Mlir-commits] [llvm] [mlir] [OpenMP][CodeExtractor]Add align metadata to load instructions (PR #131131)
Dominik Adamski
llvmlistbot at llvm.org
Tue Apr 8 05:29:53 PDT 2025
================
@@ -4437,9 +4442,21 @@ createDeviceArgumentAccessor(MapInfoData &mapData, llvm::Argument &arg,
break;
}
case omp::VariableCaptureKind::ByRef: {
- retVal = builder.CreateAlignedLoad(
+ llvm::LoadInst *loadInst = builder.CreateAlignedLoad(
v->getType(), v,
ompBuilder.M.getDataLayout().getPrefTypeAlign(v->getType()));
+ // Add information about alignment of objects that are mapped by reference
+ if (v->getType()->isPointerTy() && alignmentValue) {
+ llvm::MDBuilder MDB(builder.getContext());
+ loadInst->setMetadata(
+ llvm::LLVMContext::MD_align,
+ llvm::MDNode::get(builder.getContext(),
+ MDB.createConstant(llvm::ConstantInt::get(
+ llvm::Type::getInt64Ty(builder.getContext()),
+ alignmentValue))));
----------------
DominikAdamski wrote:
I added comment which explains the difference between `!align` metadata and `align` parameter of load instruction.
`align` parameter denotes alignment of input memory address
`!align` metadata is valid only for loaded pointers, and it describes the alignment of the object pointed by the loaded pointer.
https://github.com/llvm/llvm-project/pull/131131
More information about the Mlir-commits
mailing list