Files
clang-p2996/mlir/test/Conversion/ControlFlowToLLVM/assert.mlir
Markus Böck cbd7aaaceb [mlir][cf] Add support for opaque pointers to ControlFlowToLLVM lowering
Part of https://discourse.llvm.org/t/rfc-switching-the-llvm-dialect-and-dialect-lowerings-to-opaque-pointers/68179

This is a very simple patch since there is only one use of pointers types in `cf.assert` that has to be changed. Pointer types are conditionally created with element types and the GEP had to be adjusted to use the array type as base type.

Differential Revision: https://reviews.llvm.org/D143583
2023-02-08 21:23:23 +01:00

18 lines
586 B
MLIR

// RUN: mlir-opt %s -convert-cf-to-llvm='use-opaque-pointers=1' | FileCheck %s
func.func @main() {
%a = arith.constant 0 : i1
cf.assert %a, "assertion foo"
return
}
// CHECK: llvm.func @puts(!llvm.ptr)
// CHECK-LABEL: @main
// CHECK: llvm.cond_br %{{.*}}, ^{{.*}}, ^[[FALSE_BRANCH:[[:alnum:]]+]]
// CHECK: ^[[FALSE_BRANCH]]:
// CHECK: %[[ADDRESS_OF:.*]] = llvm.mlir.addressof @{{.*}} : !llvm.ptr{{$}}
// CHECK: %[[GEP:.*]] = llvm.getelementptr %[[ADDRESS_OF]][0] : (!llvm.ptr) -> !llvm.ptr, !llvm.array<{{[0-9]+}} x i8>
// CHECK: llvm.call @puts(%[[GEP]]) : (!llvm.ptr) -> ()