Skip to content

Commit 823151f

Browse files
committed
Revert "[MLIR] Move builtin.module LLVM IR translation to before nested operations"
This reverts commit 0b8c636.
1 parent 7678a32 commit 823151f

File tree

5 files changed

+6
-174
lines changed

5 files changed

+6
-174
lines changed

mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,15 +1377,6 @@ mlir::translateModuleToLLVMIR(Operation *module, llvm::LLVMContext &llvmContext,
13771377
LLVM::ensureDistinctSuccessors(module);
13781378

13791379
ModuleTranslation translator(module, std::move(llvmModule));
1380-
llvm::IRBuilder<> llvmBuilder(llvmContext);
1381-
1382-
// Convert module before functions and operations inside, so dialect
1383-
// attributes can be used to change dialect-specific global configurations via
1384-
// `amendOperation()`. These configurations can then influence the translation
1385-
// of operations afterwards.
1386-
if (failed(translator.convertOperation(*module, llvmBuilder)))
1387-
return nullptr;
1388-
13891380
if (failed(translator.convertComdats()))
13901381
return nullptr;
13911382
if (failed(translator.convertFunctionSignatures()))
@@ -1396,6 +1387,7 @@ mlir::translateModuleToLLVMIR(Operation *module, llvm::LLVMContext &llvmContext,
13961387
return nullptr;
13971388

13981389
// Convert other top-level operations if possible.
1390+
llvm::IRBuilder<> llvmBuilder(llvmContext);
13991391
for (Operation &o : getModuleBody(module).getOperations()) {
14001392
if (!isa<LLVM::LLVMFuncOp, LLVM::GlobalOp, LLVM::GlobalCtorsOp,
14011393
LLVM::GlobalDtorsOp, LLVM::ComdatOp>(&o) &&
@@ -1411,6 +1403,10 @@ mlir::translateModuleToLLVMIR(Operation *module, llvm::LLVMContext &llvmContext,
14111403
if (failed(translator.convertFunctions()))
14121404
return nullptr;
14131405

1406+
// Convert module itself.
1407+
if (failed(translator.convertOperation(*module, llvmBuilder)))
1408+
return nullptr;
1409+
14141410
if (llvm::verifyModule(*translator.llvmModule, &llvm::errs()))
14151411
return nullptr;
14161412

mlir/test/Target/LLVMIR/test.mlir

Lines changed: 0 additions & 18 deletions
This file was deleted.

mlir/test/lib/Dialect/Test/CMakeLists.txt

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ set(LLVM_OPTIONAL_SOURCES
22
TestDialect.cpp
33
TestPatterns.cpp
44
TestTraits.cpp
5-
TestToLLVMIRTranslation.cpp
65
)
76

87
set(LLVM_TARGET_DEFINITIONS TestInterfaces.td)
@@ -84,19 +83,4 @@ add_mlir_library(MLIRTestDialect
8483
MLIRTensorDialect
8584
MLIRTransformUtils
8685
MLIRTransforms
87-
)
88-
89-
add_mlir_translation_library(MLIRTestToLLVMIRTranslation
90-
TestToLLVMIRTranslation.cpp
91-
92-
LINK_COMPONENTS
93-
Core
94-
95-
LINK_LIBS PUBLIC
96-
MLIRIR
97-
MLIRLLVMDialect
98-
MLIRTestDialect
99-
MLIRSupport
100-
MLIRBuiltinToLLVMIRTranslation
101-
MLIRLLVMToLLVMIRTranslation
102-
)
86+
)

mlir/test/lib/Dialect/Test/TestToLLVMIRTranslation.cpp

Lines changed: 0 additions & 124 deletions
This file was deleted.

mlir/tools/mlir-translate/mlir-translate.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,11 @@ namespace mlir {
2121
// Defined in the test directory, no public header.
2222
void registerTestRoundtripSPIRV();
2323
void registerTestRoundtripDebugSPIRV();
24-
#ifdef MLIR_INCLUDE_TESTS
25-
void registerTestToLLVMIR();
26-
#endif
2724
} // namespace mlir
2825

2926
static void registerTestTranslations() {
3027
registerTestRoundtripSPIRV();
3128
registerTestRoundtripDebugSPIRV();
32-
#ifdef MLIR_INCLUDE_TESTS
33-
registerTestToLLVMIR();
34-
#endif
3529
}
3630

3731
int main(int argc, char **argv) {

0 commit comments

Comments
 (0)