aboutsummaryrefslogtreecommitdiff
path: root/mlir/lib/Target/LLVMIR/ModuleImport.cpp
diff options
context:
space:
mode:
authorChristian Ulmann <christianulmann@gmail.com>2025-05-16 08:43:06 +0200
committerGitHub <noreply@github.com>2025-05-16 08:43:06 +0200
commit1001d6a6cdfcfc3c045afd24e8b4db814384bf4f (patch)
tree28153b99d077e12738cfc28ff6b9c2bd9ecc537c /mlir/lib/Target/LLVMIR/ModuleImport.cpp
parenta83668c3dd68bfab02ba8a109a6e09b4127f49e9 (diff)
downloadllvm-1001d6a6cdfcfc3c045afd24e8b4db814384bf4f.zip
llvm-1001d6a6cdfcfc3c045afd24e8b4db814384bf4f.tar.gz
llvm-1001d6a6cdfcfc3c045afd24e8b4db814384bf4f.tar.bz2
[MLIR][LLVM] Add import-structs-as-literals flag to the IR import (#140098)
This commit introduces the `import-structs-as-literals` option to the MLIR import. This ensures that all struct types are imported as literal structs, even when they are named in LLVM IR.
Diffstat (limited to 'mlir/lib/Target/LLVMIR/ModuleImport.cpp')
-rw-r--r--mlir/lib/Target/LLVMIR/ModuleImport.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/mlir/lib/Target/LLVMIR/ModuleImport.cpp b/mlir/lib/Target/LLVMIR/ModuleImport.cpp
index 3f1884d..8945ae9 100644
--- a/mlir/lib/Target/LLVMIR/ModuleImport.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleImport.cpp
@@ -164,11 +164,12 @@ ModuleImport::ModuleImport(ModuleOp mlirModule,
std::unique_ptr<llvm::Module> llvmModule,
bool emitExpensiveWarnings,
bool importEmptyDICompositeTypes,
- bool preferUnregisteredIntrinsics)
+ bool preferUnregisteredIntrinsics,
+ bool importStructsAsLiterals)
: builder(mlirModule->getContext()), context(mlirModule->getContext()),
mlirModule(mlirModule), llvmModule(std::move(llvmModule)),
iface(mlirModule->getContext()),
- typeTranslator(*mlirModule->getContext()),
+ typeTranslator(*mlirModule->getContext(), importStructsAsLiterals),
debugImporter(std::make_unique<DebugImporter>(
mlirModule, importEmptyDICompositeTypes)),
loopAnnotationImporter(
@@ -3118,7 +3119,8 @@ ModuleImport::translateDereferenceableAttr(const llvm::MDNode *node,
OwningOpRef<ModuleOp> mlir::translateLLVMIRToModule(
std::unique_ptr<llvm::Module> llvmModule, MLIRContext *context,
bool emitExpensiveWarnings, bool dropDICompositeTypeElements,
- bool loadAllDialects, bool preferUnregisteredIntrinsics) {
+ bool loadAllDialects, bool preferUnregisteredIntrinsics,
+ bool importStructsAsLiterals) {
// Preload all registered dialects to allow the import to iterate the
// registered LLVMImportDialectInterface implementations and query the
// supported LLVM IR constructs before starting the translation. Assumes the
@@ -3136,7 +3138,8 @@ OwningOpRef<ModuleOp> mlir::translateLLVMIRToModule(
ModuleImport moduleImport(module.get(), std::move(llvmModule),
emitExpensiveWarnings, dropDICompositeTypeElements,
- preferUnregisteredIntrinsics);
+ preferUnregisteredIntrinsics,
+ importStructsAsLiterals);
if (failed(moduleImport.initializeImportInterface()))
return {};
if (failed(moduleImport.convertDataLayout()))