diff options
| author | Alex Zinenko <zinenko@google.com> | 2019-10-10 16:01:41 -0700 |
|---|---|---|
| committer | Jacques Pienaar <jpienaar@google.com> | 2019-10-10 17:19:57 -0700 |
| commit | 4dde19f02473fdec8e047de2488b6b770523077a (patch) | |
| tree | 8b510ba64e70bdef742b8aa46dbd98c2956d436b /mlir/lib/Target | |
| parent | 28d7f9c052c8cb524e016827e54314946cf0d037 (diff) | |
| download | bcm5719-llvm-4dde19f02473fdec8e047de2488b6b770523077a.tar.gz bcm5719-llvm-4dde19f02473fdec8e047de2488b6b770523077a.zip | |
Translation to LLVM: check the validity of module-level Ops
Translation to LLVM expects the entry module to have only specific types of ops
that correspond to LLVM IR entities allowed in a module. Currently those are
restricted to functions and globals. Introduce an additional check at the
module level. Inside individual functions, the check for supported Ops is
already performed, but it accepts all LLVM dialect Ops and wouldn't be
immediately applicable at the module level.
PiperOrigin-RevId: 274058651
Diffstat (limited to 'mlir/lib/Target')
| -rw-r--r-- | mlir/lib/Target/LLVMIR/ModuleTranslation.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp index 10e5a678bbd..9b020e6401f 100644 --- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp @@ -425,6 +425,14 @@ LogicalResult ModuleTranslation::convertOneFunction(LLVMFuncOp func) { return success(); } +LogicalResult ModuleTranslation::checkSupportedModuleOps(ModuleOp m) { + for (Operation &o : m.getBody()->getOperations()) + if (!isa<LLVM::LLVMFuncOp>(&o) && !isa<LLVM::GlobalOp>(&o) && + !isa<ModuleTerminatorOp>(&o)) + return o.emitOpError("unsupported module-level operation"); + return success(); +} + LogicalResult ModuleTranslation::convertFunctions() { // Declare all functions first because there may be function calls that form a // call graph with cycles. |

