================
@@ -1079,7 +1082,15 @@
CIRAttrToValue::getAddressOfSymbol(mlir::FlatSymbolRefAttr symbol) {
mlir::Operation *sourceSymbol =
symbolTables.lookupSymbolIn(parentModule, symbol);
if (auto llvmSymbol = dyn_cast<mlir::LLVM::GlobalOp>(sourceSymbol)) {
- sourceType = llvmSymbol.getType();
+ // Prefer the pre-conversion type: the LLVM global's type may have been
+ // adjusted (split rows, flexible array).
+ if (mlir::Type preType =
+ preConversionTypes.lookup(llvmSymbol.getSymName())) {
+ originalType = preType;
+ sourceType = convertTypeForMemory(*converter, dataLayout, originalType);
----------------
bcardosolopes wrote:
They're cached. TypeConverter::convertType consults cachedDirectConversions
first, so after the first conversion of a type every lookup is a hash lookup
plus the dyn_cast checks in convertTypeForMemory. Storing converted types in
the map would duplicate that cache and convert types for symbols that are never
looked up, so the map keeps CIR types and converts lazily.
https://github.com/llvm/llvm-project/pull/238698
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits