Skip to content

Commit cd12ffb

Browse files
abidhgysit
andauthored
[mlir][debug] Allow multiple DIGlobalVariableExpression on globals. (#111981)
Currently, we allow only one DIGlobalVariableExpressionAttr per global. It is especially evident in import where we pick the first from the list and ignore the rest. 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. Changes are mostly mechanical. One thing on which I went a bit back and forth was the representation inside GlobalOp. I would be happy to change if there are better ways to do this. --------- Co-authored-by: Tobias Gysi <[email protected]>
1 parent 77f8297 commit cd12ffb

File tree

12 files changed

+144
-75
lines changed

12 files changed

+144
-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/LLVMAttrDefs.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,10 @@ def LLVM_DIGlobalVariableExpressionAttr
471471
let constBuilderCall = "$0";
472472
}
473473

474+
def DIGlobalVariableExpressionArrayAttr :
475+
TypedArrayAttrBase<LLVM_DIGlobalVariableExpressionAttr,
476+
"an array of variable expressions">;
477+
474478
//===----------------------------------------------------------------------===//
475479
// DIGlobalVariableAttr
476480
//===----------------------------------------------------------------------===//

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,7 @@ def LLVM_GlobalOp : LLVM_Op<"mlir.global",
11681168
OptionalAttr<UnnamedAddr>:$unnamed_addr,
11691169
OptionalAttr<StrAttr>:$section,
11701170
OptionalAttr<SymbolRefAttr>:$comdat,
1171-
DefaultValuedAttr<LLVM_DIGlobalVariableExpressionAttr, "{}">:$dbg_expr,
1171+
OptionalAttr<DIGlobalVariableExpressionArrayAttr>:$dbg_exprs,
11721172
DefaultValuedAttr<Visibility, "mlir::LLVM::Visibility::Default">:$visibility_
11731173
);
11741174
let summary = "LLVM dialect global.";
@@ -1279,7 +1279,7 @@ def LLVM_GlobalOp : LLVM_Op<"mlir.global",
12791279
CArg<"bool", "false">:$thread_local_,
12801280
CArg<"SymbolRefAttr", "{}">:$comdat,
12811281
CArg<"ArrayRef<NamedAttribute>", "{}">:$attrs,
1282-
CArg<"DIGlobalVariableExpressionAttr", "{}">:$dbgExpr)>
1282+
CArg<"ArrayRef<Attribute>", "{}">:$dbgExprs)>
12831283
];
12841284

12851285
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 & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -914,14 +914,15 @@ 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

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

926927
// Workaround to support LLVM's nameless globals. MLIR, in contrast to LLVM,
927928
// always requires a symbol name.
@@ -935,7 +936,7 @@ LogicalResult ModuleImport::convertGlobal(llvm::GlobalVariable *globalVar) {
935936
valueAttr, alignment, /*addr_space=*/globalVar->getAddressSpace(),
936937
/*dso_local=*/globalVar->isDSOLocal(),
937938
/*thread_local=*/globalVar->isThreadLocal(), /*comdat=*/SymbolRefAttr(),
938-
/*attrs=*/ArrayRef<NamedAttribute>(), /*dbgExpr=*/globalExpressionAttr);
939+
/*attrs=*/ArrayRef<NamedAttribute>(), /*dbgExprs=*/globalExpressionAttrs);
939940
globalInsertionOp = globalOp;
940941

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

mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

Lines changed: 41 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,44 +1056,48 @@ LogicalResult ModuleTranslation::convertGlobals() {
10561056
globalsMapping.try_emplace(op, var);
10571057

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

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)