Skip to content

Commit ba441f9

Browse files
committed
fix bad change in GEP update
1 parent 9b897fd commit ba441f9

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

flang/lib/Optimizer/CodeGen/CodeGen.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2473,7 +2473,9 @@ struct XArrayCoorOpConversion
24732473
// The array was not boxed, so it must be contiguous. offset is therefore an
24742474
// element offset and the base type is kept in the GEP unless the element
24752475
// type size is itself dynamic.
2476-
mlir::Type gepObjectType;
2476+
mlir::Type objectTy = fir::unwrapRefType(coor.getMemref().getType());
2477+
mlir::Type eleType = fir::unwrapSequenceType(objectTy);
2478+
mlir::Type gepObjectType = convertType(eleType);
24772479
llvm::SmallVector<mlir::LLVM::GEPArg> args;
24782480
;
24792481
if (coor.getSubcomponent().empty()) {
@@ -2492,17 +2494,10 @@ struct XArrayCoorOpConversion
24922494
TODO(loc, "compute size of derived type with type parameters");
24932495
}
24942496
}
2495-
gepObjectType =
2496-
convertType(fir::unwrapRefType(coor.getMemref().getType()));
24972497
args.push_back(offset);
24982498
} else {
24992499
// There are subcomponents.
25002500
args.push_back(offset);
2501-
// Operand #0 must have a pointer type. For subcomponent slicing, we
2502-
// want to cast away the array type and have a plain struct type.
2503-
mlir::Type objectTy = fir::unwrapRefType(coor.getMemref().getType());
2504-
mlir::Type eleType = fir::unwrapSequenceType(objectTy);
2505-
gepObjectType = convertType(eleType);
25062501
llvm::SmallVector<mlir::Value> indices = convertSubcomponentIndices(
25072502
loc, gepObjectType,
25082503
operands.slice(coor.subcomponentOffset(),

flang/test/Fir/convert-to-llvm.fir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2121,7 +2121,7 @@ func.func @ext_array_coor4(%arg0: !fir.ref<!fir.array<100xi32>>) {
21212121
// CHECK: %[[DIFF1:.*]] = llvm.add %[[DIFF0]], %[[ADJ]] : i64
21222122
// CHECK: %[[STRIDE:.*]] = llvm.mul %[[DIFF1]], %[[C1_1]] : i64
21232123
// CHECK: %[[OFFSET:.*]] = llvm.add %[[STRIDE]], %[[C0_1]] : i64
2124-
// CHECK: %{{.*}} = llvm.getelementptr %[[ARG0]][%[[OFFSET]]] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.array<100 x i32>
2124+
// CHECK: %{{.*}} = llvm.getelementptr %[[ARG0]][%[[OFFSET]]] : (!llvm.ptr, i64) -> !llvm.ptr, i32
21252125

21262126
// Conversion with index type shape and slice
21272127

0 commit comments

Comments
 (0)