Skip to content

Commit 9aae3dd

Browse files
committed
[mlir][llvm] Update insertion point handling in LLVM import.
Insert constants and globals in order by maintaining the position of the constant and global inserted last. Update the tests to reflect the updated insertion order. Also make sure functions are always inserted at the end of the module instead of at the second last position and delete a spurious function in the intrinsic.ll that seems to exist to avoid the first function under test ends up at the end of the module. Reviewed By: ftynse Differential Revision: https://reviews.llvm.org/D136679
1 parent 767999f commit 9aae3dd

File tree

8 files changed

+160
-142
lines changed

8 files changed

+160
-142
lines changed

mlir/lib/Target/LLVMIR/ConvertFromLLVMIR.cpp

Lines changed: 82 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -412,35 +412,35 @@ class Importer {
412412
/// Returns the builtin type equivalent to be used in attributes for the given
413413
/// LLVM IR dialect type.
414414
Type getStdTypeForAttr(Type type);
415-
/// Return `value` as an attribute to attach to a GlobalOp.
415+
/// Returns `value` as an attribute to attach to a GlobalOp.
416416
Attribute getConstantAsAttr(llvm::Constant *value);
417-
/// Return `constant` as an MLIR Value. This could either be a ConstantOp, or
418-
/// an expanded sequence of ops in the current function's entry block (for
417+
/// Converts the LLVM constant to an MLIR value produced by a ConstantOp,
418+
/// AddressOfOp, NullOp, or to an expanded sequence of operations (for
419419
/// ConstantExprs or ConstantGEPs).
420-
Value processConstant(llvm::Constant *constant);
420+
Value convertConstantInPlace(llvm::Constant *constant);
421+
/// Converts the LLVM constant to an MLIR value using the
422+
/// `convertConstantInPlace` method and inserts the constant at the start of
423+
/// the function entry block.
424+
Value convertConstant(llvm::Constant *constant);
425+
426+
/// Set the constant insertion point to the start of the given block.
427+
void setConstantInsertionPointToStart(Block *block) {
428+
constantInsertionBlock = block;
429+
constantInsertionOp = nullptr;
430+
}
421431

422-
/// Builder pointing at where the next Instruction should be generated.
432+
/// Builder pointing at where the next instruction should be generated.
423433
OpBuilder builder;
434+
/// Block to insert the next constant into.
435+
Block *constantInsertionBlock = nullptr;
436+
/// Operation to insert the next constant after.
437+
Operation *constantInsertionOp = nullptr;
438+
/// Operation to insert the next global after.
439+
Operation *globalInsertionOp = nullptr;
424440
/// The current context.
425441
MLIRContext *context;
426442
/// The current module being created.
427443
ModuleOp module;
428-
/// The entry block of the current function being processed.
429-
Block *currentEntryBlock = nullptr;
430-
431-
/// Globals are inserted before the first function, if any.
432-
Block::iterator getGlobalInsertPt() {
433-
Block::iterator it = module.getBody()->begin();
434-
Block::iterator endIt = module.getBody()->end();
435-
while (it != endIt && !isa<LLVMFuncOp>(it))
436-
++it;
437-
return it;
438-
}
439-
440-
/// Functions are always inserted before the module terminator.
441-
Block::iterator getFuncInsertPt() {
442-
return std::prev(module.getBody()->end());
443-
}
444444

445445
/// Function-local mapping between original and imported block.
446446
DenseMap<llvm::BasicBlock *, Block *> blockMapping;
@@ -642,7 +642,14 @@ GlobalOp Importer::processGlobal(llvm::GlobalVariable *gv) {
642642
if (it != globals.end())
643643
return it->second;
644644

645-
OpBuilder b(module.getBody(), getGlobalInsertPt());
645+
// Insert the global after the last one or at the start of the module.
646+
OpBuilder::InsertionGuard guard(builder);
647+
if (!globalInsertionOp) {
648+
builder.setInsertionPointToStart(module.getBody());
649+
} else {
650+
builder.setInsertionPointAfter(globalInsertionOp);
651+
}
652+
646653
Attribute valueAttr;
647654
if (gv->hasInitializer())
648655
valueAttr = getConstantAsAttr(gv->getInitializer());
@@ -655,20 +662,18 @@ GlobalOp Importer::processGlobal(llvm::GlobalVariable *gv) {
655662
alignment = align.value();
656663
}
657664

658-
GlobalOp op = b.create<GlobalOp>(
665+
GlobalOp op = builder.create<GlobalOp>(
659666
UnknownLoc::get(context), type, gv->isConstant(),
660667
convertLinkageFromLLVM(gv->getLinkage()), gv->getName(), valueAttr,
661668
alignment, /*addr_space=*/gv->getAddressSpace(),
662669
/*dso_local=*/gv->isDSOLocal(), /*thread_local=*/gv->isThreadLocal());
670+
globalInsertionOp = op;
663671

664672
if (gv->hasInitializer() && !valueAttr) {
665-
Region &r = op.getInitializerRegion();
666-
currentEntryBlock = b.createBlock(&r);
667-
b.setInsertionPoint(currentEntryBlock, currentEntryBlock->begin());
668-
Value v = processConstant(gv->getInitializer());
669-
if (!v)
670-
return nullptr;
671-
b.create<ReturnOp>(op.getLoc(), ArrayRef<Value>({v}));
673+
Block *block = builder.createBlock(&op.getInitializerRegion());
674+
setConstantInsertionPointToStart(block);
675+
Value value = convertConstant(gv->getInitializer());
676+
builder.create<ReturnOp>(op.getLoc(), ArrayRef<Value>({value}));
672677
}
673678
if (gv->hasAtLeastLocalUnnamedAddr())
674679
op.setUnnamedAddr(convertUnnamedAddrFromLLVM(gv->getUnnamedAddr()));
@@ -678,29 +683,25 @@ GlobalOp Importer::processGlobal(llvm::GlobalVariable *gv) {
678683
return globals[gv] = op;
679684
}
680685

681-
Value Importer::processConstant(llvm::Constant *constant) {
682-
OpBuilder bEntry(currentEntryBlock, currentEntryBlock->begin());
686+
Value Importer::convertConstantInPlace(llvm::Constant *constant) {
683687
if (Attribute attr = getConstantAsAttr(constant)) {
684688
// These constants can be represented as attributes.
685-
OpBuilder b(currentEntryBlock, currentEntryBlock->begin());
686689
Type type = convertType(constant->getType());
687690
if (auto symbolRef = attr.dyn_cast<FlatSymbolRefAttr>())
688-
return bEntry.create<AddressOfOp>(UnknownLoc::get(context), type,
689-
symbolRef.getValue());
690-
return bEntry.create<ConstantOp>(UnknownLoc::get(context), type, attr);
691+
return builder.create<AddressOfOp>(UnknownLoc::get(context), type,
692+
symbolRef.getValue());
693+
return builder.create<ConstantOp>(UnknownLoc::get(context), type, attr);
691694
}
692695
if (auto *cn = dyn_cast<llvm::ConstantPointerNull>(constant)) {
693696
Type type = convertType(cn->getType());
694-
return bEntry.create<NullOp>(UnknownLoc::get(context), type);
697+
return builder.create<NullOp>(UnknownLoc::get(context), type);
695698
}
696699
if (auto *gv = dyn_cast<llvm::GlobalVariable>(constant))
697-
return bEntry.create<AddressOfOp>(UnknownLoc::get(context),
698-
processGlobal(gv));
700+
return builder.create<AddressOfOp>(UnknownLoc::get(context),
701+
processGlobal(gv));
699702

700703
if (auto *ce = dyn_cast<llvm::ConstantExpr>(constant)) {
701704
llvm::Instruction *i = ce->getAsInstruction();
702-
OpBuilder::InsertionGuard guard(builder);
703-
builder.setInsertionPoint(currentEntryBlock, currentEntryBlock->begin());
704705
if (failed(processInstruction(i)))
705706
return nullptr;
706707
assert(valueMapping.count(i));
@@ -720,7 +721,7 @@ Value Importer::processConstant(llvm::Constant *constant) {
720721
}
721722
if (auto *ue = dyn_cast<llvm::UndefValue>(constant)) {
722723
Type type = convertType(ue->getType());
723-
return bEntry.create<UndefOp>(UnknownLoc::get(context), type);
724+
return builder.create<UndefOp>(UnknownLoc::get(context), type);
724725
}
725726

726727
if (isa<llvm::ConstantAggregate>(constant) ||
@@ -747,41 +748,62 @@ Value Importer::processConstant(llvm::Constant *constant) {
747748
bool useInsertValue = rootType.isa<LLVMArrayType, LLVMStructType>();
748749
assert((useInsertValue || LLVM::isCompatibleVectorType(rootType)) &&
749750
"unrecognized aggregate type");
750-
Value root = bEntry.create<UndefOp>(UnknownLoc::get(context), rootType);
751+
Value root = builder.create<UndefOp>(UnknownLoc::get(context), rootType);
751752
for (unsigned i = 0; i < numElements; ++i) {
752753
llvm::Constant *element = getElement(i);
753-
Value elementValue = processConstant(element);
754+
Value elementValue = convertConstantInPlace(element);
754755
if (!elementValue)
755756
return nullptr;
756757
if (useInsertValue) {
757-
root = bEntry.create<InsertValueOp>(UnknownLoc::get(context), root,
758-
elementValue, i);
758+
root = builder.create<InsertValueOp>(UnknownLoc::get(context), root,
759+
elementValue, i);
759760
} else {
760-
Attribute indexAttr = bEntry.getI32IntegerAttr(static_cast<int32_t>(i));
761-
Value indexValue = bEntry.create<ConstantOp>(
762-
UnknownLoc::get(context), bEntry.getI32Type(), indexAttr);
761+
Attribute indexAttr =
762+
builder.getI32IntegerAttr(static_cast<int32_t>(i));
763+
Value indexValue = builder.create<ConstantOp>(
764+
UnknownLoc::get(context), builder.getI32Type(), indexAttr);
763765
if (!indexValue)
764766
return nullptr;
765-
root = bEntry.create<InsertElementOp>(
767+
root = builder.create<InsertElementOp>(
766768
UnknownLoc::get(context), rootType, root, elementValue, indexValue);
767769
}
768770
}
769771
return root;
770772
}
771773

772-
emitError(UnknownLoc::get(context))
773-
<< "unhandled constant: " << diag(*constant);
774774
return nullptr;
775775
}
776776

777+
Value Importer::convertConstant(llvm::Constant *constant) {
778+
assert(constantInsertionBlock &&
779+
"expected the constant insertion block to be non-null");
780+
781+
// Insert the constant after the last one or at the start or the entry block.
782+
OpBuilder::InsertionGuard guard(builder);
783+
if (!constantInsertionOp) {
784+
builder.setInsertionPointToStart(constantInsertionBlock);
785+
} else {
786+
builder.setInsertionPointAfter(constantInsertionOp);
787+
}
788+
789+
// Convert the constant in-place and update the insertion point if successful.
790+
if (Value result = convertConstantInPlace(constant)) {
791+
constantInsertionOp = result.getDefiningOp();
792+
return result;
793+
}
794+
795+
llvm::errs() << diag(*constant) << "\n";
796+
llvm_unreachable("unhandled constant");
797+
}
798+
777799
Value Importer::processValue(llvm::Value *value) {
778800
auto it = valueMapping.find(value);
779801
if (it != valueMapping.end())
780802
return it->second;
781803

782-
// Process constants such as immediate arguments that have no mapping.
804+
// Convert constants such as immediate arguments that have no mapping.
783805
if (auto *c = dyn_cast<llvm::Constant>(value))
784-
return processConstant(c);
806+
return convertConstant(c);
785807

786808
llvm::errs() << diag(*value) << "\n";
787809
llvm_unreachable("unhandled value");
@@ -927,7 +949,7 @@ LogicalResult Importer::processInstruction(llvm::Instruction *inst) {
927949
SmallVector<Value, 4> ops;
928950

929951
for (unsigned i = 0, ie = lpi->getNumClauses(); i < ie; i++)
930-
ops.push_back(processConstant(lpi->getClause(i)));
952+
ops.push_back(convertConstant(lpi->getClause(i)));
931953

932954
Type ty = convertType(lpi->getType());
933955
Value res = builder.create<LandingpadOp>(loc, ty, lpi->isCleanup(), ops);
@@ -1034,7 +1056,10 @@ LogicalResult Importer::processFunction(llvm::Function *func) {
10341056
bool dsoLocal = func->hasLocalLinkage();
10351057
CConv cconv = convertCConvFromLLVM(func->getCallingConv());
10361058

1037-
builder.setInsertionPoint(module.getBody(), getFuncInsertPt());
1059+
// Insert the function at the end of the module.
1060+
OpBuilder::InsertionGuard guard(builder);
1061+
builder.setInsertionPoint(module.getBody(), module.getBody()->end());
1062+
10381063
LLVMFuncOp funcOp = builder.create<LLVMFuncOp>(
10391064
UnknownLoc::get(context), func->getName(), functionType,
10401065
convertLinkageFromLLVM(func->getLinkage()), dsoLocal, cconv);
@@ -1090,7 +1115,6 @@ LogicalResult Importer::processFunction(llvm::Function *func) {
10901115
builder.createBlock(&funcOp.getBody(), funcOp.getBody().end());
10911116
mapBlock(&bb, block);
10921117
}
1093-
currentEntryBlock = &funcOp.getFunctionBody().getBlocks().front();
10941118

10951119
// Add function arguments to the entry block.
10961120
for (const auto &it : llvm::enumerate(func->args())) {
@@ -1103,6 +1127,7 @@ LogicalResult Importer::processFunction(llvm::Function *func) {
11031127
// operands defined in a dominating block have a valid mapping to an MLIR
11041128
// value once a block is translated.
11051129
SetVector<llvm::BasicBlock *> blocks = getTopologicallySortedBlocks(func);
1130+
setConstantInsertionPointToStart(lookupBlock(blocks.front()));
11061131
for (llvm::BasicBlock *bb : blocks) {
11071132
if (failed(processBasicBlock(bb, lookupBlock(bb))))
11081133
return failure();

mlir/test/Target/LLVMIR/Import/basic.ll

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424

2525
@g4 = external global i32, align 8
2626
; CHECK: llvm.mlir.global internal constant @int_gep() {addr_space = 0 : i32, dso_local} : !llvm.ptr<i32> {
27-
; CHECK-DAG: %[[addr:[0-9]+]] = llvm.mlir.addressof @g4 : !llvm.ptr<i32>
28-
; CHECK-DAG: %[[c2:[0-9]+]] = llvm.mlir.constant(2 : i32) : i32
27+
; CHECK: %[[addr:[0-9]+]] = llvm.mlir.addressof @g4 : !llvm.ptr<i32>
28+
; CHECK: %[[c2:[0-9]+]] = llvm.mlir.constant(2 : i32) : i32
2929
; CHECK-NEXT: %[[gepinit:[0-9]+]] = llvm.getelementptr %[[addr]][%[[c2]]] : (!llvm.ptr<i32>, i32) -> !llvm.ptr<i32>
3030
; CHECK-NEXT: llvm.return %[[gepinit]] : !llvm.ptr<i32>
3131
; CHECK-NEXT: }
@@ -133,10 +133,10 @@ define internal spir_func void @spir_func_internal() {
133133
; FIXME: function attributes.
134134
; CHECK-LABEL: llvm.func internal @f1(%arg0: i64) -> i32 attributes {dso_local} {
135135
; CHECK-DBG: llvm.func internal @f1(%arg0: i64 loc(unknown)) -> i32 attributes {dso_local} {
136-
; CHECK-DAG: %[[c2:[0-9]+]] = llvm.mlir.constant(2 : i32) : i32
137-
; CHECK-DAG: %[[c42:[0-9]+]] = llvm.mlir.constant(42 : i32) : i32
138-
; CHECK-DAG: %[[c1:[0-9]+]] = llvm.mlir.constant(true) : i1
139-
; CHECK-DAG: %[[c43:[0-9]+]] = llvm.mlir.constant(43 : i32) : i32
136+
; CHECK: %[[c2:[0-9]+]] = llvm.mlir.constant(2 : i32) : i32
137+
; CHECK: %[[c1:[0-9]+]] = llvm.mlir.constant(true) : i1
138+
; CHECK: %[[c43:[0-9]+]] = llvm.mlir.constant(43 : i32) : i32
139+
; CHECK: %[[c42:[0-9]+]] = llvm.mlir.constant(42 : i32) : i32
140140
define internal dso_local i32 @f1(i64 %a) norecurse {
141141
entry:
142142
; CHECK: %{{[0-9]+}} = llvm.inttoptr %arg0 : i64 to !llvm.ptr<i64>
@@ -148,7 +148,7 @@ entry:
148148
; %{{[0-9]+}} = llvm.ptrtoint %[[addrof2]] : !llvm.ptr<f64> to i64
149149
; %{{[0-9]+}} = llvm.getelementptr %[[addrof]][%3] : (!llvm.ptr<f64>, i32) -> !llvm.ptr<f64>
150150
%bb = ptrtoint double* @g2 to i64
151-
%cc = getelementptr double, double* @g2, i32 2
151+
%cc = getelementptr double, double* @g2, i32 3
152152
; CHECK: %[[b:[0-9]+]] = llvm.trunc %arg0 : i64 to i32
153153
; CHECK-DBG: llvm.trunc %arg0 : i64 to i32 loc(#[[UNKNOWNLOC]])
154154
%b = trunc i64 %a to i32
@@ -195,18 +195,18 @@ define void @f6(void (i16) *%fn) {
195195
; Testing rest of the floating point constant kinds.
196196
; CHECK-LABEL: llvm.func @FPConstant(%arg0: f16, %arg1: bf16, %arg2: f128, %arg3: f80)
197197
define void @FPConstant(half %a, bfloat %b, fp128 %c, x86_fp80 %d) {
198-
; CHECK-DAG: %[[C0:.+]] = llvm.mlir.constant(7.000000e+00 : f80) : f80
199-
; CHECK-DAG: %[[C1:.+]] = llvm.mlir.constant(0.000000e+00 : f128) : f128
200-
; CHECK-DAG: %[[C2:.+]] = llvm.mlir.constant(1.000000e+00 : bf16) : bf16
201-
; CHECK-DAG: %[[C3:.+]] = llvm.mlir.constant(1.000000e+00 : f16) : f16
198+
; CHECK: %[[C0:.+]] = llvm.mlir.constant(1.000000e+00 : f16) : f16
199+
; CHECK: %[[C1:.+]] = llvm.mlir.constant(1.000000e+00 : bf16) : bf16
200+
; CHECK: %[[C2:.+]] = llvm.mlir.constant(0.000000e+00 : f128) : f128
201+
; CHECK: %[[C3:.+]] = llvm.mlir.constant(7.000000e+00 : f80) : f80
202202

203-
; CHECK: llvm.fadd %[[C3]], %arg0 : f16
203+
; CHECK: llvm.fadd %[[C0]], %arg0 : f16
204204
%1 = fadd half 1.0, %a
205-
; CHECK: llvm.fadd %[[C2]], %arg1 : bf16
205+
; CHECK: llvm.fadd %[[C1]], %arg1 : bf16
206206
%2 = fadd bfloat 1.0, %b
207-
; CHECK: llvm.fadd %[[C1]], %arg2 : f128
207+
; CHECK: llvm.fadd %[[C2]], %arg2 : f128
208208
%3 = fadd fp128 0xL00000000000000000000000000000000, %c
209-
; CHECK: llvm.fadd %[[C0]], %arg3 : f80
209+
; CHECK: llvm.fadd %[[C3]], %arg3 : f80
210210
%4 = fadd x86_fp80 0xK4001E000000000000000, %d
211211
ret void
212212
}
Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,40 @@
11
; RUN: mlir-translate --import-llvm %s | FileCheck %s
2-
3-
; CHECK-DAG: %[[C0:.+]] = llvm.mlir.constant(7 : i32) : i32
4-
; CHECK-DAG: %[[C1:.+]] = llvm.mlir.constant(8 : i16) : i16
5-
; CHECK-DAG: %[[C2:.+]] = llvm.mlir.constant(4 : i8) : i8
6-
; CHECK-DAG: %[[C3:.+]] = llvm.mlir.constant(9 : i32) : i32
72
; CHECK: %[[ROOT:.+]] = llvm.mlir.undef : !llvm.struct<"SimpleAggType", (i32, i8, i16, i32)>
8-
; CHECK: %[[CHAIN0:.+]] = llvm.insertvalue %[[C3]], %[[ROOT]][0]
9-
; CHECK: %[[CHAIN1:.+]] = llvm.insertvalue %[[C2]], %[[CHAIN0]][1]
10-
; CHECK: %[[CHAIN2:.+]] = llvm.insertvalue %[[C1]], %[[CHAIN1]][2]
11-
; CHECK: %[[CHAIN3:.+]] = llvm.insertvalue %[[C0]], %[[CHAIN2]][3]
3+
; CHECK: %[[C0:.+]] = llvm.mlir.constant(9 : i32) : i32
4+
; CHECK: %[[CHAIN0:.+]] = llvm.insertvalue %[[C0]], %[[ROOT]][0]
5+
; CHECK: %[[C1:.+]] = llvm.mlir.constant(4 : i8) : i8
6+
; CHECK: %[[CHAIN1:.+]] = llvm.insertvalue %[[C1]], %[[CHAIN0]][1]
7+
; CHECK: %[[C2:.+]] = llvm.mlir.constant(8 : i16) : i16
8+
; CHECK: %[[CHAIN2:.+]] = llvm.insertvalue %[[C2]], %[[CHAIN1]][2]
9+
; CHECK: %[[C3:.+]] = llvm.mlir.constant(7 : i32) : i32
10+
; CHECK: %[[CHAIN3:.+]] = llvm.insertvalue %[[C3]], %[[CHAIN2]][3]
1211
; CHECK: llvm.return %[[CHAIN3]]
1312
%SimpleAggType = type {i32, i8, i16, i32}
1413
@simpleAgg = global %SimpleAggType {i32 9, i8 4, i16 8, i32 7}
1514

16-
; CHECK: %[[NP:.+]] = llvm.mlir.null : !llvm.ptr<struct<"SimpleAggType", (i32, i8, i16, i32)>>
17-
; CHECK-DAG: %[[C0:.+]] = llvm.mlir.constant(4 : i32) : i32
18-
; CHECK-DAG: %[[C1:.+]] = llvm.mlir.constant(3 : i16) : i16
19-
; CHECK-DAG: %[[C2:.+]] = llvm.mlir.constant(2 : i8) : i8
20-
; CHECK-DAG: %[[C3:.+]] = llvm.mlir.constant(1 : i32) : i32
21-
; CHECK: %[[ROOT:.+]] = llvm.mlir.undef : !llvm.struct<"SimpleAggType", (i32, i8, i16, i32)>
22-
; CHECK: %[[CHAIN0:.+]] = llvm.insertvalue %[[C3]], %[[ROOT]][0]
15+
; CHECK: %[[ROOT:.+]] = llvm.mlir.undef : !llvm.struct<"NestedAggType", (struct<"SimpleAggType", (i32, i8, i16, i32)>, ptr<struct<"SimpleAggType", (i32, i8, i16, i32)>>)>
16+
; CHECK: %[[NESTED:.+]] = llvm.mlir.undef : !llvm.struct<"SimpleAggType", (i32, i8, i16, i32)>
17+
; CHECK: %[[C1:.+]] = llvm.mlir.constant(1 : i32) : i32
18+
; CHECK: %[[CHAIN0:.+]] = llvm.insertvalue %[[C1]], %[[NESTED]][0]
19+
; CHECK: %[[C2:.+]] = llvm.mlir.constant(2 : i8) : i8
2320
; CHECK: %[[CHAIN1:.+]] = llvm.insertvalue %[[C2]], %[[CHAIN0]][1]
24-
; CHECK: %[[CHAIN2:.+]] = llvm.insertvalue %[[C1]], %[[CHAIN1]][2]
25-
; CHECK: %[[CHAIN3:.+]] = llvm.insertvalue %[[C0]], %[[CHAIN2]][3]
26-
; CHECK: %[[ROOT2:.+]] = llvm.mlir.undef : !llvm.struct<"NestedAggType", (struct<"SimpleAggType", (i32, i8, i16, i32)>, ptr<struct<"SimpleAggType", (i32, i8, i16, i32)>>)>
27-
; CHECK: %[[CHAIN4:.+]] = llvm.insertvalue %[[CHAIN3]], %[[ROOT2]][0]
21+
; CHECK: %[[C3:.+]] = llvm.mlir.constant(3 : i16) : i16
22+
; CHECK: %[[CHAIN2:.+]] = llvm.insertvalue %[[C3]], %[[CHAIN1]][2]
23+
; CHECK: %[[C4:.+]] = llvm.mlir.constant(4 : i32) : i32
24+
; CHECK: %[[CHAIN3:.+]] = llvm.insertvalue %[[C4]], %[[CHAIN2]][3]
25+
; CHECK: %[[CHAIN4:.+]] = llvm.insertvalue %[[CHAIN3]], %[[ROOT]][0]
26+
; CHECK: %[[NP:.+]] = llvm.mlir.null : !llvm.ptr<struct<"SimpleAggType", (i32, i8, i16, i32)>>
2827
; CHECK: %[[CHAIN5:.+]] = llvm.insertvalue %[[NP]], %[[CHAIN4]][1]
2928
; CHECK: llvm.return %[[CHAIN5]]
3029
%NestedAggType = type {%SimpleAggType, %SimpleAggType*}
3130
@nestedAgg = global %NestedAggType { %SimpleAggType{i32 1, i8 2, i16 3, i32 4}, %SimpleAggType* null }
3231

33-
; CHECK: %[[C0:.+]] = llvm.mlir.null : !llvm.ptr<struct<"SimpleAggType", (i32, i8, i16, i32)>>
34-
; CHECK: %[[C1:.+]] = llvm.mlir.null : !llvm.ptr<struct<"SimpleAggType", (i32, i8, i16, i32)>>
3532
; CHECK: %[[ROOT:.+]] = llvm.mlir.undef : !llvm.vec<2 x ptr<struct<"SimpleAggType", (i32, i8, i16, i32)>>>
33+
; CHECK: %[[C0:.+]] = llvm.mlir.null : !llvm.ptr<struct<"SimpleAggType", (i32, i8, i16, i32)>>
3634
; CHECK: %[[P0:.+]] = llvm.mlir.constant(0 : i32) : i32
37-
; CHECK: %[[CHAIN0:.+]] = llvm.insertelement %[[C1]], %[[ROOT]][%[[P0]] : i32] : !llvm.vec<2 x ptr<struct<"SimpleAggType", (i32, i8, i16, i32)>>>
35+
; CHECK: %[[CHAIN0:.+]] = llvm.insertelement %[[C0]], %[[ROOT]][%[[P0]] : i32] : !llvm.vec<2 x ptr<struct<"SimpleAggType", (i32, i8, i16, i32)>>>
36+
; CHECK: %[[C1:.+]] = llvm.mlir.null : !llvm.ptr<struct<"SimpleAggType", (i32, i8, i16, i32)>>
3837
; CHECK: %[[P1:.+]] = llvm.mlir.constant(1 : i32) : i32
39-
; CHECK: %[[CHAIN1:.+]] = llvm.insertelement %[[C0]], %[[CHAIN0]][%[[P1]] : i32] : !llvm.vec<2 x ptr<struct<"SimpleAggType", (i32, i8, i16, i32)>>>
38+
; CHECK: %[[CHAIN1:.+]] = llvm.insertelement %[[C1]], %[[CHAIN0]][%[[P1]] : i32] : !llvm.vec<2 x ptr<struct<"SimpleAggType", (i32, i8, i16, i32)>>>
4039
; CHECK: llvm.return %[[CHAIN1]] : !llvm.vec<2 x ptr<struct<"SimpleAggType", (i32, i8, i16, i32)>>>
4140
@vectorAgg = global <2 x %SimpleAggType*> <%SimpleAggType* null, %SimpleAggType* null>

0 commit comments

Comments
 (0)