From 88c5b9640a0f6cd6f7b84952bf499e5313170727 Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Tue, 13 Dec 2022 08:48:32 +0000 Subject: [PATCH] Add LLVMDialect as dependent for "llvm-legalize-for-export" pass Fixes #59462 --- .../mlir/Dialect/LLVMIR/Transforms/Passes.td | 1 + mlir/test/Dialect/LLVMIR/legalize-for-export.mlir | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.td b/mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.td index a22efd392d5e6..604865e59956e 100644 --- a/mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.td +++ b/mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.td @@ -14,6 +14,7 @@ include "mlir/Pass/PassBase.td" def LLVMLegalizeForExport : Pass<"llvm-legalize-for-export"> { let summary = "Legalize LLVM dialect to be convertible to LLVM IR"; let constructor = "::mlir::LLVM::createLegalizeForExportPass()"; + let dependentDialects = ["LLVM::LLVMDialect"]; } def LLVMRequestCWrappers diff --git a/mlir/test/Dialect/LLVMIR/legalize-for-export.mlir b/mlir/test/Dialect/LLVMIR/legalize-for-export.mlir index ac8ed6d0441a8..37720e98d92a9 100644 --- a/mlir/test/Dialect/LLVMIR/legalize-for-export.mlir +++ b/mlir/test/Dialect/LLVMIR/legalize-for-export.mlir @@ -1,4 +1,4 @@ -// RUN: mlir-opt -llvm-legalize-for-export %s | FileCheck %s +// RUN: mlir-opt -llvm-legalize-for-export --split-input-file %s | FileCheck %s // Verifies that duplicate successor with different arguments are deduplicated // by introducing a new block that forwards its arguments to the original @@ -43,3 +43,15 @@ llvm.func @repeated_successor_openmp(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: } llvm.return } + +// ----- + +// This module won't have any LLVM dialect entities as input. +// Check that we don't crash when building LLVM entities. +// CHECK-LABEL:func @func1 +func.func @func1(%arg0: i1, %arg1 : i1) { +// CHECK: llvm.br + cf.cond_br %arg0, ^bb40(%arg0 : i1), ^bb40(%arg1 : i1) +^bb40(%47: i1): + return +}