diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp --- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp @@ -946,6 +946,9 @@ if (auto dataLayoutAttr = m->getAttr(LLVM::LLVMDialect::getDataLayoutAttrName())) llvmModule->setDataLayout(dataLayoutAttr.cast().getValue()); + if (auto targetTripleAttr = + m->getAttr(LLVM::LLVMDialect::getTargetTripleAttrName())) + llvmModule->setTargetTriple(targetTripleAttr.cast().getValue()); // Inject declarations for `malloc` and `free` functions that can be used in // memref allocation/deallocation coming from standard ops lowering. diff --git a/mlir/test/Target/llvmir.mlir b/mlir/test/Target/llvmir.mlir --- a/mlir/test/Target/llvmir.mlir +++ b/mlir/test/Target/llvmir.mlir @@ -1314,11 +1314,13 @@ // ----- // CHECK: "CodeView", i32 1 +// CHECK: x86_64-pc-windows-msvc module attributes {llvm.target_triple = "x86_64-pc-windows-msvc"} {} // ----- // CHECK-NOT: "CodeView", i32 1 +// CHECK: aarch64-linux-android module attributes {llvm.target_triple = "aarch64-linux-android"} {} // -----