[all-commits] [llvm/llvm-project] ed07c9: [MLIR] Fix offload map metadata order (#195346)
Abid Qadeer via All-commits
all-commits at lists.llvm.org
Tue May 5 02:12:37 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: ed07c92c9629cc64e2b17e82eff841dd238c5218
https://github.com/llvm/llvm-project/commit/ed07c92c9629cc64e2b17e82eff841dd238c5218
Author: Abid Qadeer <haqadeer at amd.com>
Date: 2026-05-05 (Tue, 05 May 2026)
Changed paths:
M mlir/include/mlir/Target/LLVMIR/Dialect/OpenMPCommon.h
M mlir/lib/Target/LLVMIR/Dialect/OpenMPCommon.cpp
M mlir/test/Target/LLVMIR/openacc-llvm.mlir
Log Message:
-----------
[MLIR] Fix offload map metadata order (#195346)
This fixes one part of
https://github.com/llvm/llvm-project/issues/195333.
There are two different semicolon-field orders in
offload/include/Shared/SourceInfo.h:
1. Per-map strings (`map_var_info_t`): first field is the mapped name,
second
is the file path:
```
/// Type alias for source location information for variable mappings with
/// data layout ";name;filename;row;col;;\0" from clang.
using map_var_info_t = void *;
```
2. `ident_t` region strings: first field is the file path, second is the
function name:
```
/// The ident structure that describes a source location from kmp.h. with
/// source location string data as ";filename;function;line;column;;\0".
struct ident_t {
```
`SourceInfo` reflects that with two constructors: `SourceInfo(const
ident_t *)`
parses `getSubstring(0)` as the filename field and `getSubstring(1)` as
the
name (function); `SourceInfo(const map_var_info_t)` uses
`getSubstring(0)` for
the map name and `getSubstring(1)` for the filename path.
`OpenMPIRBuilder::getOrCreateSrcLocStr(FunctionName, FileName, line,
col)`
always builds the same wire shape: the second parameter is emitted
first,
then the first i.e. ;FileName;FunctionName;line;col;.
Clang passes arguments accordingly in two places:
1. per-map metadata (`emitMappingInformation`):
Calls `getOrCreateSrcLocStr(FileName, ExprName, ...)`
so the buffer is ";expr;path;…", matching `map_var_info_t` and
`getNameFromMapping`.
2. ident / update location (`emitUpdateLocation`):
Calls `getOrCreateSrcLocStr(FunctionName, FileName, ...)` so the buffer
is
";file;function;…", matching ident_t.
MLIR previously called the same helper in only the ident-like way for
both
uses which is why we see file paths in the map name slot.
I would have preferred if we can keep the same order in both cases. But
I am not
aware of the history of why it was done like this. I have instead fixed
it by adding
`ForOffloadMap` to `createSourceLocStrFromLocation` so mapping uses the
same
argument order as Clang's `emitMappingInformation`, while ident-style
callers
keep the existing order.
Adjusted a test accordingly.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list