Skip to content

Commit 6afd64e

Browse files
committed
[mlir][debug] Allow multiple DIGlobalVariableExpression on globals.
Currently, we allow only one DIGlobalVariableExpressionAttr per global. Also when we are importing, we just pick the first one. In contrast, LLVM allows multiple DIGlobalVariableExpression to be attached to the global. They are needed for correct working of things like DICommonBlock. This PR removes this restriction in mlir. The changes are mostly mechanical. The testcases have been adjusted accordingly.
1 parent 453d373 commit 6afd64e

File tree

11 files changed

+147
-75
lines changed

11 files changed

+147
-75
lines changed

flang/lib/Optimizer/CodeGen/CodeGen.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2808,14 +2808,14 @@ struct GlobalOpConversion : public fir::FIROpConversion<fir::GlobalOp> {
28082808
matchAndRewrite(fir::GlobalOp global, OpAdaptor adaptor,
28092809
mlir::ConversionPatternRewriter &rewriter) const override {
28102810

2811-
mlir::LLVM::DIGlobalVariableExpressionAttr dbgExpr;
2811+
llvm::SmallVector<mlir::Attribute> dbgExprs;
28122812

28132813
if (auto fusedLoc = mlir::dyn_cast<mlir::FusedLoc>(global.getLoc())) {
28142814
if (auto gvAttr =
28152815
mlir::dyn_cast_or_null<mlir::LLVM::DIGlobalVariableAttr>(
28162816
fusedLoc.getMetadata())) {
2817-
dbgExpr = mlir::LLVM::DIGlobalVariableExpressionAttr::get(
2818-
global.getContext(), gvAttr, mlir::LLVM::DIExpressionAttr());
2817+
dbgExprs.push_back(mlir::LLVM::DIGlobalVariableExpressionAttr::get(
2818+
global.getContext(), gvAttr, mlir::LLVM::DIExpressionAttr()));
28192819
}
28202820
}
28212821

@@ -2831,7 +2831,7 @@ struct GlobalOpConversion : public fir::FIROpConversion<fir::GlobalOp> {
28312831
llvm::ArrayRef<mlir::NamedAttribute> attrs;
28322832
auto g = rewriter.create<mlir::LLVM::GlobalOp>(
28332833
loc, tyAttr, isConst, linkage, global.getSymName(), initAttr, 0, 0,
2834-
false, false, comdat, attrs, dbgExpr);
2834+
false, false, comdat, attrs, dbgExprs);
28352835

28362836
if (global.getAlignment() && *global.getAlignment() > 0)
28372837
g.setAlignment(*global.getAlignment());

flang/test/Transforms/debug-module-2.fir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ module {
3131
// CHECK-DAG: #[[GLR:.*]] = #llvm.di_global_variable<{{.*}}name = "glr", linkageName = "_QMhelperEglr"{{.*}}>
3232
// CHECK-DAG: #[[GLIE:.*]] = #llvm.di_global_variable_expression<var = #[[GLI]]>
3333
// CHECK-DAG: #[[GLRE:.*]] = #llvm.di_global_variable_expression<var = #[[GLR]]>
34-
// CHECK-DAG: llvm.mlir.global{{.*}}@_QMhelperEgli() {{{.*}}dbg_expr = #[[GLIE]]}
35-
// CHECK-DAG: llvm.mlir.global{{.*}}@_QMhelperEglr() {{{.*}}dbg_expr = #[[GLRE]]}
34+
// CHECK-DAG: llvm.mlir.global{{.*}}@_QMhelperEgli() {{{.*}}dbg_exprs = [#[[GLIE]]]}
35+
// CHECK-DAG: llvm.mlir.global{{.*}}@_QMhelperEglr() {{{.*}}dbg_exprs = [#[[GLRE]]]}

mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
include "mlir/Dialect/LLVMIR/LLVMAttrDefs.td"
1717
include "mlir/Dialect/LLVMIR/LLVMEnums.td"
1818
include "mlir/Dialect/LLVMIR/LLVMOpBase.td"
19+
include "mlir/IR/AttrTypeBase.td"
1920
include "mlir/IR/EnumAttr.td"
2021
include "mlir/Interfaces/FunctionInterfaces.td"
2122
include "mlir/IR/SymbolInterfaces.td"
@@ -1152,6 +1153,9 @@ def LLVM_AddressOfOp : LLVM_Op<"mlir.addressof",
11521153
let hasFolder = 1;
11531154
}
11541155

1156+
def DIGlobalVariableExpressionArrayAttr :
1157+
TypedArrayAttrBase<LLVM_DIGlobalVariableExpressionAttr, "an array of variable expressions">;
1158+
11551159
def LLVM_GlobalOp : LLVM_Op<"mlir.global",
11561160
[IsolatedFromAbove, SingleBlockImplicitTerminator<"ReturnOp">, Symbol]> {
11571161
let arguments = (ins
@@ -1168,7 +1172,7 @@ def LLVM_GlobalOp : LLVM_Op<"mlir.global",
11681172
OptionalAttr<UnnamedAddr>:$unnamed_addr,
11691173
OptionalAttr<StrAttr>:$section,
11701174
OptionalAttr<SymbolRefAttr>:$comdat,
1171-
DefaultValuedAttr<LLVM_DIGlobalVariableExpressionAttr, "{}">:$dbg_expr,
1175+
OptionalAttr<DIGlobalVariableExpressionArrayAttr>:$dbg_exprs,
11721176
DefaultValuedAttr<Visibility, "mlir::LLVM::Visibility::Default">:$visibility_
11731177
);
11741178
let summary = "LLVM dialect global.";
@@ -1279,7 +1283,7 @@ def LLVM_GlobalOp : LLVM_Op<"mlir.global",
12791283
CArg<"bool", "false">:$thread_local_,
12801284
CArg<"SymbolRefAttr", "{}">:$comdat,
12811285
CArg<"ArrayRef<NamedAttribute>", "{}">:$attrs,
1282-
CArg<"DIGlobalVariableExpressionAttr", "{}">:$dbgExpr)>
1286+
CArg<"ArrayRef<Attribute>", "{}">:$dbgExprs)>
12831287
];
12841288

12851289
let extraClassDeclaration = [{

mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2089,7 +2089,7 @@ void GlobalOp::build(OpBuilder &builder, OperationState &result, Type type,
20892089
Attribute value, uint64_t alignment, unsigned addrSpace,
20902090
bool dsoLocal, bool threadLocal, SymbolRefAttr comdat,
20912091
ArrayRef<NamedAttribute> attrs,
2092-
DIGlobalVariableExpressionAttr dbgExpr) {
2092+
ArrayRef<Attribute> dbgExprs) {
20932093
result.addAttribute(getSymNameAttrName(result.name),
20942094
builder.getStringAttr(name));
20952095
result.addAttribute(getGlobalTypeAttrName(result.name), TypeAttr::get(type));
@@ -2121,8 +2121,9 @@ void GlobalOp::build(OpBuilder &builder, OperationState &result, Type type,
21212121
builder.getI32IntegerAttr(addrSpace));
21222122
result.attributes.append(attrs.begin(), attrs.end());
21232123

2124-
if (dbgExpr)
2125-
result.addAttribute(getDbgExprAttrName(result.name), dbgExpr);
2124+
if (!dbgExprs.empty())
2125+
result.addAttribute(getDbgExprsAttrName(result.name),
2126+
ArrayAttr::get(builder.getContext(), dbgExprs));
21262127

21272128
result.addRegion();
21282129
}

mlir/lib/Target/LLVMIR/ModuleImport.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -914,14 +914,16 @@ LogicalResult ModuleImport::convertGlobal(llvm::GlobalVariable *globalVar) {
914914

915915
// Get the global expression associated with this global variable and convert
916916
// it.
917-
DIGlobalVariableExpressionAttr globalExpressionAttr;
917+
SmallVector<Attribute> globalExpressionAttrs;
918918
SmallVector<llvm::DIGlobalVariableExpression *> globalExpressions;
919919
globalVar->getDebugInfo(globalExpressions);
920920

921921
// There should only be a single global expression.
922-
if (!globalExpressions.empty())
923-
globalExpressionAttr =
924-
debugImporter->translateGlobalVariableExpression(globalExpressions[0]);
922+
for (auto expr : globalExpressions) {
923+
DIGlobalVariableExpressionAttr globalExpressionAttr =
924+
debugImporter->translateGlobalVariableExpression(expr);
925+
globalExpressionAttrs.push_back(globalExpressionAttr);
926+
}
925927

926928
// Workaround to support LLVM's nameless globals. MLIR, in contrast to LLVM,
927929
// always requires a symbol name.
@@ -935,7 +937,7 @@ LogicalResult ModuleImport::convertGlobal(llvm::GlobalVariable *globalVar) {
935937
valueAttr, alignment, /*addr_space=*/globalVar->getAddressSpace(),
936938
/*dso_local=*/globalVar->isDSOLocal(),
937939
/*thread_local=*/globalVar->isThreadLocal(), /*comdat=*/SymbolRefAttr(),
938-
/*attrs=*/ArrayRef<NamedAttribute>(), /*dbgExpr=*/globalExpressionAttr);
940+
/*attrs=*/ArrayRef<NamedAttribute>(), /*dbgExprs=*/globalExpressionAttrs);
939941
globalInsertionOp = globalOp;
940942

941943
if (globalVar->hasInitializer() && !valueAttr) {

mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,44 +1055,50 @@ LogicalResult ModuleTranslation::convertGlobals() {
10551055
globalsMapping.try_emplace(op, var);
10561056

10571057
// Add debug information if present.
1058-
if (op.getDbgExpr()) {
1059-
llvm::DIGlobalVariableExpression *diGlobalExpr =
1060-
debugTranslation->translateGlobalVariableExpression(op.getDbgExpr());
1061-
llvm::DIGlobalVariable *diGlobalVar = diGlobalExpr->getVariable();
1062-
var->addDebugInfo(diGlobalExpr);
1063-
1064-
// There is no `globals` field in DICompileUnitAttr which can be directly
1065-
// assigned to DICompileUnit. We have to build the list by looking at the
1066-
// dbgExpr of all the GlobalOps. The scope of the variable is used to get
1067-
// the DICompileUnit in which to add it.
1068-
// But there are cases where the scope of a global does not
1069-
// directly point to the DICompileUnit and we have to do a bit more work
1070-
// to get to it. Some of those cases are:
1071-
//
1072-
// 1. For the languages that support modules, the scope hierarchy can be
1073-
// variable -> DIModule -> DICompileUnit
1074-
//
1075-
// 2. For the Fortran common block variable, the scope hierarchy can be
1076-
// variable -> DICommonBlock -> DISubprogram -> DICompileUnit
1077-
//
1078-
// 3. For entities like static local variables in C or variable with
1079-
// SAVE attribute in Fortran, the scope hierarchy can be
1080-
// variable -> DISubprogram -> DICompileUnit
1081-
llvm::DIScope *scope = diGlobalVar->getScope();
1082-
if (auto *mod = dyn_cast_if_present<llvm::DIModule>(scope))
1083-
scope = mod->getScope();
1084-
else if (auto *cb = dyn_cast_if_present<llvm::DICommonBlock>(scope)) {
1085-
if (auto *sp = dyn_cast_if_present<llvm::DISubprogram>(cb->getScope()))
1086-
scope = sp->getUnit();
1087-
} else if (auto *sp = dyn_cast_if_present<llvm::DISubprogram>(scope))
1088-
scope = sp->getUnit();
1089-
1090-
// Get the compile unit (scope) of the the global variable.
1091-
if (llvm::DICompileUnit *compileUnit =
1092-
dyn_cast_if_present<llvm::DICompileUnit>(scope)) {
1093-
// Update the compile unit with this incoming global variable expression
1094-
// during the finalizing step later.
1095-
allGVars[compileUnit].push_back(diGlobalExpr);
1058+
if (op.getDbgExprs()) {
1059+
for (auto attr : *op.getDbgExprs()) {
1060+
if (auto exprAttr =
1061+
dyn_cast_if_present<DIGlobalVariableExpressionAttr>(attr)) {
1062+
llvm::DIGlobalVariableExpression *diGlobalExpr =
1063+
debugTranslation->translateGlobalVariableExpression(exprAttr);
1064+
llvm::DIGlobalVariable *diGlobalVar = diGlobalExpr->getVariable();
1065+
var->addDebugInfo(diGlobalExpr);
1066+
1067+
// There is no `globals` field in DICompileUnitAttr which can be
1068+
// directly assigned to DICompileUnit. We have to build the list by
1069+
// looking at the dbgExpr of all the GlobalOps. The scope of the
1070+
// variable is used to get the DICompileUnit in which to add it. But
1071+
// there are cases where the scope of a global does not directly point
1072+
// to the DICompileUnit and we have to do a bit more work to get to
1073+
// it. Some of those cases are:
1074+
//
1075+
// 1. For the languages that support modules, the scope hierarchy can
1076+
// be variable -> DIModule -> DICompileUnit
1077+
//
1078+
// 2. For the Fortran common block variable, the scope hierarchy can
1079+
// be variable -> DICommonBlock -> DISubprogram -> DICompileUnit
1080+
//
1081+
// 3. For entities like static local variables in C or variable with
1082+
// SAVE attribute in Fortran, the scope hierarchy can be
1083+
// variable -> DISubprogram -> DICompileUnit
1084+
llvm::DIScope *scope = diGlobalVar->getScope();
1085+
if (auto *mod = dyn_cast_if_present<llvm::DIModule>(scope))
1086+
scope = mod->getScope();
1087+
else if (auto *cb = dyn_cast_if_present<llvm::DICommonBlock>(scope)) {
1088+
if (auto *sp =
1089+
dyn_cast_if_present<llvm::DISubprogram>(cb->getScope()))
1090+
scope = sp->getUnit();
1091+
} else if (auto *sp = dyn_cast_if_present<llvm::DISubprogram>(scope))
1092+
scope = sp->getUnit();
1093+
1094+
// Get the compile unit (scope) of the the global variable.
1095+
if (llvm::DICompileUnit *compileUnit =
1096+
dyn_cast_if_present<llvm::DICompileUnit>(scope)) {
1097+
// Update the compile unit with this incoming global variable
1098+
// expression during the finalizing step later.
1099+
allGVars[compileUnit].push_back(diGlobalExpr);
1100+
}
1101+
}
10961102
}
10971103
}
10981104
}

mlir/test/Dialect/LLVMIR/debuginfo.mlir

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,18 @@
162162
file = #file, line = 2, type = #int0>
163163
#var_expression = #llvm.di_global_variable_expression<var = #global_var,
164164
expr = <>>
165-
llvm.mlir.global common @block_() {dbg_expr = #var_expression} : i64
165+
#global_var1 = #llvm.di_global_variable<scope = #di_common_block, name = "b",
166+
file = #file, line = 3, type = #int0>
167+
#var_expression1 = #llvm.di_global_variable_expression<var = #global_var1,
168+
expr = <>>
169+
llvm.mlir.global @data() {dbg_exprs = [#var_expression, #var_expression1]} : i64
170+
171+
// CHECK-DAG: llvm.mlir.global external @data() {{{.*}}dbg_exprs = [#[[EXP1:.*]], #[[EXP2:.*]]]} : i64
172+
// CHECK-DAG: #[[EXP1]] = #llvm.di_global_variable_expression<var = #[[GV1:.*]], expr = <>>
173+
// CHECK-DAG: #[[EXP2]] = #llvm.di_global_variable_expression<var = #[[GV2:.*]], expr = <>>
174+
// CHECK-DAG: #[[GV1]] = #llvm.di_global_variable<{{.*}}name = "a"{{.*}}>
175+
// CHECK-DAG: #[[GV2]] = #llvm.di_global_variable<{{.*}}name = "b"{{.*}}>
176+
166177

167178
// CHECK: llvm.func @addr(%[[ARG:.*]]: i64)
168179
llvm.func @addr(%arg: i64) {

mlir/test/Dialect/LLVMIR/global.mlir

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -272,15 +272,15 @@ llvm.mlir.global @target_fail(0 : i64) : !llvm.target<"spirv.Image", i32, 0>
272272
// CHECK-DAG: #[[EXPR1:.*]] = #llvm.di_global_variable_expression<var = #[[GVAR1]], expr = <[DW_OP_push_object_address, DW_OP_deref]>>
273273
// CHECK-DAG: #[[EXPR2:.*]] = #llvm.di_global_variable_expression<var = #[[GVAR2]], expr = <[DW_OP_LLVM_arg(0), DW_OP_LLVM_arg(1), DW_OP_plus]>>
274274
// CHECK-DAG: #[[EXPR3:.*]] = #llvm.di_global_variable_expression<var = #[[GVAR3]], expr = <[DW_OP_LLVM_convert(16, DW_ATE_signed)]>>
275-
// CHECK-DAG: llvm.mlir.global external @global_with_expr1() {addr_space = 0 : i32, dbg_expr = #[[EXPR0]]} : i64
276-
// CHECK-DAG: llvm.mlir.global external @global_with_expr2() {addr_space = 0 : i32, dbg_expr = #[[EXPR1]]} : i64
277-
// CHECK-DAG: llvm.mlir.global external @global_with_expr3() {addr_space = 0 : i32, dbg_expr = #[[EXPR2]]} : i64
278-
// CHECK-DAG: llvm.mlir.global external @global_with_expr4() {addr_space = 0 : i32, dbg_expr = #[[EXPR3]]} : i64
275+
// CHECK-DAG: llvm.mlir.global external @global_with_expr1() {addr_space = 0 : i32, dbg_expr = [#[[EXPR0]]]} : i64
276+
// CHECK-DAG: llvm.mlir.global external @global_with_expr2() {addr_space = 0 : i32, dbg_expr = [#[[EXPR1]]]} : i64
277+
// CHECK-DAG: llvm.mlir.global external @global_with_expr3() {addr_space = 0 : i32, dbg_expr = [#[[EXPR2]]]} : i64
278+
// CHECK-DAG: llvm.mlir.global external @global_with_expr4() {addr_space = 0 : i32, dbg_expr = [#[[EXPR3]]]} : i64
279279

280280
#di_file = #llvm.di_file<"not" in "existence">
281281
#di_compile_unit = #llvm.di_compile_unit<id = distinct[0]<>, sourceLanguage = DW_LANG_C, file = #di_file, producer = "MLIR", isOptimized = true, emissionKind = Full>
282282
#di_basic_type = #llvm.di_basic_type<tag = DW_TAG_base_type, name = "uint64_t", sizeInBits = 64, encoding = DW_ATE_unsigned>
283-
llvm.mlir.global external @global_with_expr1() {addr_space = 0 : i32, dbg_expr = #llvm.di_global_variable_expression<var = <scope = #di_compile_unit, name = "global_with_expr_1", linkageName = "global_with_expr_1", file = #di_file, line = 370, type = #di_basic_type, isLocalToUnit = true, isDefined = true, alignInBits = 8>, expr = <>>} : i64
284-
llvm.mlir.global external @global_with_expr2() {addr_space = 0 : i32, dbg_expr = #llvm.di_global_variable_expression<var = <scope = #di_compile_unit, name = "global_with_expr_2", linkageName = "global_with_expr_2", file = #di_file, line = 371, type = #di_basic_type, isLocalToUnit = true, isDefined = true, alignInBits = 8>, expr = <[DW_OP_push_object_address, DW_OP_deref]>>} : i64
285-
llvm.mlir.global external @global_with_expr3() {addr_space = 0 : i32, dbg_expr = #llvm.di_global_variable_expression<var = <scope = #di_compile_unit, name = "global_with_expr_3", linkageName = "global_with_expr_3", file = #di_file, line = 372, type = #di_basic_type, isLocalToUnit = true, isDefined = true, alignInBits = 8>, expr = <[DW_OP_LLVM_arg(0), DW_OP_LLVM_arg(1), DW_OP_plus]>>} : i64
286-
llvm.mlir.global external @global_with_expr4() {addr_space = 0 : i32, dbg_expr = #llvm.di_global_variable_expression<var = <scope = #di_compile_unit, name = "global_with_expr_4", linkageName = "global_with_expr_4", file = #di_file, line = 373, type = #di_basic_type, isLocalToUnit = true, isDefined = true, alignInBits = 8>, expr = <[DW_OP_LLVM_convert(16, DW_ATE_signed)]>>} : i64
283+
llvm.mlir.global external @global_with_expr1() {addr_space = 0 : i32, dbg_expr = [#llvm.di_global_variable_expression<var = <scope = #di_compile_unit, name = "global_with_expr_1", linkageName = "global_with_expr_1", file = #di_file, line = 370, type = #di_basic_type, isLocalToUnit = true, isDefined = true, alignInBits = 8>, expr = <>>]} : i64
284+
llvm.mlir.global external @global_with_expr2() {addr_space = 0 : i32, dbg_expr = [#llvm.di_global_variable_expression<var = <scope = #di_compile_unit, name = "global_with_expr_2", linkageName = "global_with_expr_2", file = #di_file, line = 371, type = #di_basic_type, isLocalToUnit = true, isDefined = true, alignInBits = 8>, expr = <[DW_OP_push_object_address, DW_OP_deref]>>]} : i64
285+
llvm.mlir.global external @global_with_expr3() {addr_space = 0 : i32, dbg_expr = [#llvm.di_global_variable_expression<var = <scope = #di_compile_unit, name = "global_with_expr_3", linkageName = "global_with_expr_3", file = #di_file, line = 372, type = #di_basic_type, isLocalToUnit = true, isDefined = true, alignInBits = 8>, expr = <[DW_OP_LLVM_arg(0), DW_OP_LLVM_arg(1), DW_OP_plus]>>]} : i64
286+
llvm.mlir.global external @global_with_expr4() {addr_space = 0 : i32, dbg_expr = [#llvm.di_global_variable_expression<var = <scope = #di_compile_unit, name = "global_with_expr_4", linkageName = "global_with_expr_4", file = #di_file, line = 373, type = #di_basic_type, isLocalToUnit = true, isDefined = true, alignInBits = 8>, expr = <[DW_OP_LLVM_convert(16, DW_ATE_signed)]>>]} : i64

mlir/test/Target/LLVMIR/Import/debug-info.ll

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,3 +867,27 @@ define void @test() !dbg !3 {
867867
; CHECK: #[[FILE:.+]] = #llvm.di_file<"test.f90" in "">
868868
; CHECK: #[[SP:.+]] = #llvm.di_subprogram<{{.*}}name = "test"{{.*}}>
869869
; CHECK: #llvm.di_common_block<scope = #[[SP]], name = "block", file = #[[FILE]], line = 3>
870+
871+
; // -----
872+
873+
@data = external global i64, !dbg !0, !dbg !5
874+
875+
!llvm.module.flags = !{!8}
876+
!llvm.dbg.cu = !{!2}
877+
878+
!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
879+
!1 = distinct !DIGlobalVariable(name: "a", scope: !2, file: !3, line: 2, type: !7)
880+
!2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, globals: !4)
881+
!3 = !DIFile(filename: "test.c", directory: "")
882+
!4 = !{!0, !5}
883+
!5 = !DIGlobalVariableExpression(var: !6, expr: !DIExpression())
884+
!6 = distinct !DIGlobalVariable(name: "b", scope: !2, file: !3, line: 3, type: !7)
885+
!7 = !DIBasicType(name: "int", size: 32)
886+
!8 = !{i32 2, !"Debug Info Version", i32 3}
887+
888+
889+
; CHECK: #[[VAR1:.+]] = #llvm.di_global_variable<{{.*}}name = "a"{{.*}}>
890+
; CHECK: #[[VAR2:.+]] = #llvm.di_global_variable<{{.*}}name = "b"{{.*}}>
891+
; CHECK: #[[EXP1:.+]] = #llvm.di_global_variable_expression<var = #[[VAR1]], expr = <>>
892+
; CHECK: #[[EXP2:.+]] = #llvm.di_global_variable_expression<var = #[[VAR2]], expr = <>>
893+
; CHECK: llvm.mlir.global external @data() {{{.*}}dbg_exprs = [#[[EXP1]], #[[EXP2]]]} : i64

mlir/test/Target/LLVMIR/Import/global-variables.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,8 @@ define void @bar() {
274274
; CHECK-DAG: #[[GVAR1:.*]] = #llvm.di_global_variable<scope = #[[SPROG]], name = "bar", linkageName = "bar", file = #[[FILE]], line = 8, type = #[[TYPE]], isLocalToUnit = true>
275275
; CHECK-DAG: #[[EXPR0:.*]] = #llvm.di_global_variable_expression<var = #[[GVAR0]], expr = <[DW_OP_LLVM_fragment(0, 16)]>>
276276
; CHECK-DAG: #[[EXPR1:.*]] = #llvm.di_global_variable_expression<var = #[[GVAR1]], expr = <[DW_OP_constu(3), DW_OP_plus]>>
277-
; CHECK-DAG: llvm.mlir.global external @foo() {addr_space = 0 : i32, alignment = 8 : i64, dbg_expr = #[[EXPR0]]} : i32
278-
; CHECK-DAG: llvm.mlir.global external @bar() {addr_space = 0 : i32, alignment = 8 : i64, dbg_expr = #[[EXPR1]]} : i32
277+
; CHECK-DAG: llvm.mlir.global external @foo() {addr_space = 0 : i32, alignment = 8 : i64, dbg_exprs = [#[[EXPR0]]]} : i32
278+
; CHECK-DAG: llvm.mlir.global external @bar() {addr_space = 0 : i32, alignment = 8 : i64, dbg_exprs = [#[[EXPR1]]]} : i32
279279

280280
@foo = external global i32, align 8, !dbg !5
281281
@bar = external global i32, align 8, !dbg !7
@@ -308,7 +308,7 @@ define void @bar() {
308308
; CHECK: llvm.mlir.global internal constant @one() {addr_space = 0 : i32, dso_local} : !llvm.ptr {
309309
; CHECK: llvm.mlir.addressof @mlir.llvm.nameless_global_3 : !llvm.ptr
310310

311-
; CHECK: llvm.mlir.global external constant @".str.1"() {addr_space = 0 : i32, dbg_expr = #[[GLOBAL_VAR_EXPR]]}
311+
; CHECK: llvm.mlir.global external constant @".str.1"() {addr_space = 0 : i32, dbg_exprs = [#[[GLOBAL_VAR_EXPR]]]}
312312

313313
@0 = private unnamed_addr constant [2 x i8] c"0\00"
314314
@1 = private unnamed_addr constant [2 x i8] c"1\00"

0 commit comments

Comments
 (0)