Polygeist icon indicating copy to clipboard operation
Polygeist copied to clipboard

'arith.divsi' operand type mismatch when emitting std::to_string

Open yar-sh opened this issue 2 years ago • 0 comments

Hi!

I am using this commit: https://github.com/llvm/Polygeist/commit/a27def31a2b0742308e7c8db4c0f40a37727269a to transform C++ code to MLIR.

With this simple C++ code (test.cpp):

#include <string>
std::string test(int x)
{
    return std::to_string(x);
}

I am executing the command cgeist test.cpp --resource-dir="$(clang++ -print-resource-dir)" --function=* -S. It results in the following output:

full output

CXXBindTemporaryExpr 0x5608b2b879f8 'string':'class std::basic_string<char>' (CXXTemporary 0x5608b2b879f8)
`-CallExpr 0x5608b2b879b0 'string':'class std::basic_string<char>'
  |-ImplicitCastExpr 0x5608b2b87998 'string (*)(int)' <FunctionToPointerDecay>
  | `-DeclRefExpr 0x5608b2b87910 'string (int)' lvalue Function 0x5608b29b31d8 'to_string' 'string (int)'
  `-ImplicitCastExpr 0x5608b2b879d8 'int' <LValueToRValue>
    `-DeclRefExpr 0x5608b2b878f0 'int' lvalue ParmVar 0x5608b2b876c8 'x' 'int'
cleanup not handled
cleanup of materialized not handledCXXConstructExpr 0x5608b29c3868 'string':'class std::basic_string<char>' 'void (size_type, char, const class std::allocator<char> &)'
|-ImplicitCastExpr 0x5608b29c36f0 'size_type':'unsigned long' <IntegralCast>
| `-BinaryOperator 0x5608b29b9dd0 'unsigned int':'unsigned int' '+'
|   |-ImplicitCastExpr 0x5608b29b9da0 'unsigned int':'unsigned int' <IntegralCast>
|   | `-ImplicitCastExpr 0x5608b29b9d88 '_Bool' <LValueToRValue>
|   |   `-DeclRefExpr 0x5608b29b9d48 'const _Bool' lvalue Var 0x5608b29b3298 '__neg' 'const _Bool'
|   `-ImplicitCastExpr 0x5608b29b9db8 'unsigned int':'unsigned int' <LValueToRValue>
|     `-DeclRefExpr 0x5608b29b9d68 'const unsigned int':'const unsigned int' lvalue Var 0x5608b29b36b8 '__len' 'const unsigned int':'const unsigned int'
|-CharacterLiteral 0x5608b29b9df0 'char' 45
`-CXXDefaultArgExpr 0x5608b29c3818 'const class std::allocator<char>':'const class std::allocator<char>' lvalue
cleanup not handled
cleanup of materialized not handledCallExpr 0x5608b2bb41b0 'void'
|-ImplicitCastExpr 0x5608b2bb4198 'void (*)(char_type &, const char_type &) noexcept' <FunctionToPointerDecay>
| `-DeclRefExpr 0x5608b2bb4110 'void (char_type &, const char_type &) noexcept' lvalue CXXMethod 0x5608b2517530 'assign' 'void (char_type &, const char_type &) noexcept'
|-ArraySubscriptExpr 0x5608b2bb40c8 'char':'char' lvalue
| |-CXXMemberCallExpr 0x5608b2bb4058 'pointer':'char *'
| | `-MemberExpr 0x5608b2bb4028 '<bound member function type>' ->_M_data 0x5608b29747a8
| |   `-ImplicitCastExpr 0x5608b2bb4078 'const class std::basic_string<char> *' <NoOp>
| |     `-CXXThisExpr 0x5608b2bb4018 'class std::basic_string<char> *' implicit this
| `-ImplicitCastExpr 0x5608b2bb40b0 'size_type':'unsigned long' <LValueToRValue>
|   `-DeclRefExpr 0x5608b2bb4090 'size_type':'unsigned long' lvalue ParmVar 0x5608b2974c20 '__n' 'size_type':'unsigned long'
`-MaterializeTemporaryExpr 0x5608b2bb41f8 'const char':'const char' lvalue
  `-ImplicitCastExpr 0x5608b2bb41e0 'const char':'const char' <NoOp>
    `-CXXScalarValueInitExpr 0x5608b2bb40f8 'char':'char'
cleanup not handled
loc("/usr/lib/gcc/x86_64-linux-gnu/10.3.1/../../../../include/c++/10.3.1/bits/charconv.h":62:12): error: 'arith.divsi' op requires the same type for all operands and results
"builtin.module"() ({
  "memref.global"() {initial_value = dense<true> : tensor<1xi1>, sym_name = "_ZNSt8__detail18__to_chars_10_implIjEEvPcjT_@static@_ZZNSt8__detail18__to_chars_10_implIjEEvPcjT_E8__digits@init", sym_visibility = "private", type = memref<1xi1>} : () -> ()
  "memref.global"() {initial_value, sym_name = "_ZNSt8__detail18__to_chars_10_implIjEEvPcjT_@static@_ZZNSt8__detail18__to_chars_10_implIjEEvPcjT_E8__digits", type = memref<201xi8>} : () -> ()
  "llvm.mlir.global"() ({
  }) {addr_space = 0 : i32, constant, global_type = !llvm.array<201 x i8>, linkage = #llvm.linkage<internal>, sym_name = "str0", value = "00010203040506070809101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899\00"} : () -> ()
  "func.func"() ({
  ^bb0(%arg0: i32):
    %0 = "func.call"(%arg0) {callee = @_ZNSt7__cxx119to_stringEi} : (i32) -> !llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>
    "func.return"(%0) : (!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>) -> ()
  }) {function_type = (i32) -> !llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>, llvm.linkage = #llvm.linkage<external>, sym_name = "_Z4testB5cxx11i"} : () -> ()
  "func.func"() ({
  ^bb0(%arg0: i32):
    %0 = "arith.constant"() {value = 45 : i8} : () -> i8
    %1 = "arith.constant"() {value = 10 : i32} : () -> i32
    %2 = "arith.constant"() {value = 1 : i32} : () -> i32
    %3 = "arith.constant"() {value = -1 : i32} : () -> i32
    %4 = "arith.constant"() {value = 0 : i32} : () -> i32
    %5 = "memref.alloca"() {operand_segment_sizes = array<i32: 0, 0>} : () -> memref<1x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>
    %6 = "memref.cast"(%5) : (memref<1x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>
    %7 = "memref.alloca"() {operand_segment_sizes = array<i32: 0, 0>} : () -> memref<1x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>
    %8 = "memref.cast"(%7) : (memref<1x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>
    %9 = "memref.alloca"() {operand_segment_sizes = array<i32: 0, 0>} : () -> memref<1x!llvm.struct<(struct<(i8)>)>>
    %10 = "memref.cast"(%9) : (memref<1x!llvm.struct<(struct<(i8)>)>>) -> memref<?x!llvm.struct<(struct<(i8)>)>>
    %11 = "memref.alloca"() {operand_segment_sizes = array<i32: 0, 0>} : () -> memref<1x!llvm.struct<(struct<(i8)>)>>
    %12 = "memref.cast"(%11) : (memref<1x!llvm.struct<(struct<(i8)>)>>) -> memref<?x!llvm.struct<(struct<(i8)>)>>
    %13 = "memref.alloca"() {operand_segment_sizes = array<i32: 0, 0>} : () -> memref<1x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>
    %14 = "memref.cast"(%13) : (memref<1x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>
    %15 = "arith.cmpi"(%arg0, %4) {predicate = 2 : i64} : (i32, i32) -> i1
    %16 = "scf.if"(%15) ({
      %26 = "arith.xori"(%arg0, %3) : (i32, i32) -> i32
      %27 = "arith.addi"(%26, %2) : (i32, i32) -> i32
      "scf.yield"(%27) : (i32) -> ()
    }, {
      "scf.yield"(%arg0) : (i32) -> ()
    }) : (i1) -> i32
    %17 = "func.call"(%16, %1) {callee = @_ZNSt8__detail14__to_chars_lenIjEEjT_i} : (i32, i32) -> i32
    %18 = "arith.extui"(%15) : (i1) -> i32
    %19 = "arith.addi"(%18, %17) : (i32, i32) -> i32
    %20 = "arith.extsi"(%19) : (i32) -> i64
    "func.call"(%12) {callee = @_ZNSaIcEC1Ev} : (memref<?x!llvm.struct<(struct<(i8)>)>>) -> ()
    %21 = "affine.load"(%11) {map = affine_map<() -> (0)>} : (memref<1x!llvm.struct<(struct<(i8)>)>>) -> !llvm.struct<(struct<(i8)>)>
    "affine.store"(%21, %9) {map = affine_map<() -> (0)>} : (!llvm.struct<(struct<(i8)>)>, memref<1x!llvm.struct<(struct<(i8)>)>>) -> ()
    "func.call"(%14, %20, %0, %10) {callee = @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEmcRKS3_} : (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>, i64, i8, memref<?x!llvm.struct<(struct<(i8)>)>>) -> ()
    %22 = "affine.load"(%13) {map = affine_map<() -> (0)>} : (memref<1x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> !llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>
    "affine.store"(%22, %7) {map = affine_map<() -> (0)>} : (!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>, memref<1x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> ()
    %23 = "arith.extui"(%15) : (i1) -> i64
    %24 = "func.call"(%8, %23) {callee = @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm} : (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>, i64) -> memref<?xi8>
    "func.call"(%24, %17, %16) {callee = @_ZNSt8__detail18__to_chars_10_implIjEEvPcjT_} : (memref<?xi8>, i32, i32) -> ()
    "func.call"(%6, %8) {callee = @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1EOS4_} : (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>, memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> ()
    %25 = "affine.load"(%5) {map = affine_map<() -> (0)>} : (memref<1x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> !llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>
    "func.return"(%25) : (!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>) -> ()
  }) {function_type = (i32) -> !llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>, llvm.linkage = #llvm.linkage<linkonce_odr>, sym_name = "_ZNSt7__cxx119to_stringEi"} : () -> ()
  "func.func"() ({
  ^bb0(%arg0: i32, %arg1: i32):
    %0 = "arith.constant"() {value = true} : () -> i1
    %1 = "arith.constant"() {value = 4 : i32} : () -> i32
    %2 = "arith.constant"() {value = 3 : i32} : () -> i32
    %3 = "arith.constant"() {value = 2 : i32} : () -> i32
    %4 = "arith.constant"() {value = 1 : i32} : () -> i32
    %5 = "llvm.mlir.undef"() : () -> i32
    %6 = "arith.muli"(%arg1, %arg1) : (i32, i32) -> i32
    %7 = "arith.muli"(%6, %arg1) : (i32, i32) -> i32
    %8 = "arith.muli"(%7, %arg1) : (i32, i32) -> i32
    %9 = "arith.extui"(%8) : (i32) -> i64
    %10:3 = "scf.while"(%4, %arg0, %5, %0) ({
    ^bb0(%arg2: i32, %arg3: i32, %arg4: i32, %arg5: i1):
      "scf.condition"(%arg5, %arg4, %arg2, %arg3) : (i1, i32, i32, i32) -> ()
    }, {
    ^bb0(%arg2: i32, %arg3: i32, %arg4: i32):
      %11 = "arith.cmpi"(%arg4, %arg1) {predicate = 2 : i64} : (i32, i32) -> i1
      %12 = "arith.select"(%11, %arg3, %arg2) : (i1, i32, i32) -> i32
      %13 = "arith.cmpi"(%arg4, %arg1) {predicate = 5 : i64} : (i32, i32) -> i1
      %14 = "arith.cmpi"(%arg4, %6) {predicate = 2 : i64} : (i32, i32) -> i1
      %15 = "arith.andi"(%13, %14) : (i1, i1) -> i1
      %16 = "arith.andi"(%15, %13) : (i1, i1) -> i1
      %17 = "arith.xori"(%16, %0) : (i1, i1) -> i1
      %18 = "arith.andi"(%17, %13) : (i1, i1) -> i1
      %19 = "scf.if"(%16) ({
        %34 = "arith.addi"(%arg3, %4) : (i32, i32) -> i32
        "scf.yield"(%34) : (i32) -> ()
      }, {
        "scf.yield"(%12) : (i32) -> ()
      }) : (i1) -> i32
      %20 = "arith.cmpi"(%arg4, %7) {predicate = 2 : i64} : (i32, i32) -> i1
      %21 = "arith.andi"(%18, %20) : (i1, i1) -> i1
      %22 = "arith.andi"(%21, %18) : (i1, i1) -> i1
      %23 = "arith.xori"(%22, %0) : (i1, i1) -> i1
      %24 = "arith.andi"(%23, %18) : (i1, i1) -> i1
      %25 = "scf.if"(%22) ({
        %34 = "arith.addi"(%arg3, %3) : (i32, i32) -> i32
        "scf.yield"(%34) : (i32) -> ()
      }, {
        "scf.yield"(%19) : (i32) -> ()
      }) : (i1) -> i32
      %26 = "arith.extsi"(%arg4) : (i32) -> i64
      %27 = "arith.cmpi"(%26, %9) {predicate = 6 : i64} : (i64, i64) -> i1
      %28 = "arith.andi"(%24, %27) : (i1, i1) -> i1
      %29 = "arith.andi"(%28, %24) : (i1, i1) -> i1
      %30 = "arith.xori"(%29, %0) : (i1, i1) -> i1
      %31 = "arith.andi"(%30, %24) : (i1, i1) -> i1
      %32 = "scf.if"(%29) ({
        %34 = "arith.addi"(%arg3, %2) : (i32, i32) -> i32
        "scf.yield"(%34) : (i32) -> ()
      }, {
        "scf.yield"(%25) : (i32) -> ()
      }) : (i1) -> i32
      %33:2 = "scf.if"(%31) ({
        %34 = "arith.divsi"(%arg4, %9) : (i32, i64) -> i32
        %35 = "arith.addi"(%arg3, %1) : (i32, i32) -> i32
        "scf.yield"(%34, %35) : (i32, i32) -> ()
      }, {
        "scf.yield"(%arg4, %arg3) : (i32, i32) -> ()
      }) : (i1) -> (i32, i32)
      "scf.yield"(%33#1, %33#0, %32, %31) : (i32, i32, i32, i1) -> ()
    }) : (i32, i32, i32, i1) -> (i32, i32, i32)
    "func.return"(%10#0) : (i32) -> ()
  }) {function_type = (i32, i32) -> i32, llvm.linkage = #llvm.linkage<linkonce_odr>, sym_name = "_ZNSt8__detail14__to_chars_lenIjEEjT_i"} : () -> ()
  "func.func"() ({
  ^bb0(%arg0: memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>, %arg1: i64, %arg2: i8, %arg3: memref<?x!llvm.struct<(struct<(i8)>)>>):
    %0 = "polygeist.memref2pointer"(%arg0) : (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> !llvm.ptr<!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>
    %1 = "polygeist.pointer2memref"(%0) : (!llvm.ptr<!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> memref<?x!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>>
    %2 = "func.call"(%arg0) {callee = @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE13_M_local_dataEv} : (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> memref<?xi8>
    "func.call"(%1, %2, %arg3) {callee = @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderC1EPcRKS3_} : (memref<?x!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>>, memref<?xi8>, memref<?x!llvm.struct<(struct<(i8)>)>>) -> ()
    "func.call"(%arg0, %arg1, %arg2) {callee = @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructEmc} : (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>, i64, i8) -> ()
    "func.return"() : () -> ()
  }) {function_type = (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>, i64, i8, memref<?x!llvm.struct<(struct<(i8)>)>>) -> (), llvm.linkage = #llvm.linkage<linkonce_odr>, sym_name = "_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1IS3_EEmcRKS3_"} : () -> ()
  "func.func"() ({
  ^bb0(%arg0: memref<?x!llvm.struct<(struct<(i8)>)>>):
    %0 = "polygeist.memref2pointer"(%arg0) : (memref<?x!llvm.struct<(struct<(i8)>)>>) -> !llvm.ptr<struct<(struct<(i8)>)>>
    %1 = "polygeist.pointer2memref"(%0) : (!llvm.ptr<struct<(struct<(i8)>)>>) -> memref<?x!llvm.struct<(i8)>>
    "func.call"(%1) {callee = @_ZN9__gnu_cxx13new_allocatorIcEC1Ev} : (memref<?x!llvm.struct<(i8)>>) -> ()
    "func.return"() : () -> ()
  }) {function_type = (memref<?x!llvm.struct<(struct<(i8)>)>>) -> (), llvm.linkage = #llvm.linkage<available_externally>, sym_name = "_ZNSaIcEC1Ev"} : () -> ()
  "func.func"() ({
  ^bb0(%arg0: memref<?xi8>, %arg1: i32, %arg2: i32):
    %0 = "arith.constant"() {value = -1 : i32} : () -> i32
    %1 = "arith.constant"() {value = -2 : i32} : () -> i32
    %2 = "arith.constant"() {value = 48 : i32} : () -> i32
    %3 = "arith.constant"() {value = 10 : i32} : () -> i32
    %4 = "arith.constant"() {value = 2 : i32} : () -> i32
    %5 = "arith.constant"() {value = 100 : i32} : () -> i32
    %6 = "arith.constant"() {value = 1 : i32} : () -> i32
    %7 = "arith.constant"() {value = false} : () -> i1
    %8 = "memref.get_global"() {name = @"_ZNSt8__detail18__to_chars_10_implIjEEvPcjT_@static@_ZZNSt8__detail18__to_chars_10_implIjEEvPcjT_E8__digits"} : () -> memref<201xi8>
    %9 = "memref.get_global"() {name = @"_ZNSt8__detail18__to_chars_10_implIjEEvPcjT_@static@_ZZNSt8__detail18__to_chars_10_implIjEEvPcjT_E8__digits@init"} : () -> memref<1xi1>
    %10 = "affine.load"(%9) {map = affine_map<() -> (0)>} : (memref<1xi1>) -> i1
    "scf.if"(%10) ({
      "affine.store"(%7, %9) {map = affine_map<() -> (0)>} : (i1, memref<1xi1>) -> ()
      "scf.yield"() : () -> ()
    }, {
    }) : (i1) -> ()
    %11 = "arith.addi"(%arg1, %0) : (i32, i32) -> i32
    %12:2 = "scf.while"(%11, %arg2) ({
    ^bb0(%arg3: i32, %arg4: i32):
      %16 = "arith.cmpi"(%arg4, %5) {predicate = 5 : i64} : (i32, i32) -> i1
      "scf.condition"(%16, %arg4, %arg3) : (i1, i32, i32) -> ()
    }, {
    ^bb0(%arg3: i32, %arg4: i32):
      %16 = "arith.remsi"(%arg3, %5) : (i32, i32) -> i32
      %17 = "arith.muli"(%16, %4) : (i32, i32) -> i32
      %18 = "arith.divsi"(%arg3, %5) : (i32, i32) -> i32
      %19 = "arith.index_cast"(%arg4) : (i32) -> index
      %20 = "arith.addi"(%17, %6) : (i32, i32) -> i32
      %21 = "arith.index_cast"(%20) : (i32) -> index
      %22 = "memref.load"(%8, %21) : (memref<201xi8>, index) -> i8
      "memref.store"(%22, %arg0, %19) : (i8, memref<?xi8>, index) -> ()
      %23 = "arith.addi"(%arg4, %0) : (i32, i32) -> i32
      %24 = "arith.index_cast"(%23) : (i32) -> index
      %25 = "arith.index_cast"(%17) : (i32) -> index
      %26 = "memref.load"(%8, %25) : (memref<201xi8>, index) -> i8
      "memref.store"(%26, %arg0, %24) : (i8, memref<?xi8>, index) -> ()
      %27 = "arith.addi"(%arg4, %1) : (i32, i32) -> i32
      "scf.yield"(%27, %18) : (i32, i32) -> ()
    }) : (i32, i32) -> (i32, i32)
    %13 = "arith.index_cast"(%12#0) : (i32) -> index
    %14 = "arith.index_cast"(%12#0) : (i32) -> index
    %15 = "arith.cmpi"(%12#0, %3) {predicate = 5 : i64} : (i32, i32) -> i1
    "scf.if"(%15) ({
      %16 = "affine.load"(%8, %13) {map = affine_map<()[s0] -> (s0 * 2 + 1)>} : (memref<201xi8>, index) -> i8
      "affine.store"(%16, %arg0) {map = affine_map<() -> (1)>} : (i8, memref<?xi8>) -> ()
      %17 = "affine.load"(%8, %14) {map = affine_map<()[s0] -> (s0 * 2)>} : (memref<201xi8>, index) -> i8
      "affine.store"(%17, %arg0) {map = affine_map<() -> (0)>} : (i8, memref<?xi8>) -> ()
      "scf.yield"() : () -> ()
    }, {
      %16 = "arith.addi"(%12#0, %2) : (i32, i32) -> i32
      %17 = "arith.trunci"(%16) : (i32) -> i8
      "affine.store"(%17, %arg0) {map = affine_map<() -> (0)>} : (i8, memref<?xi8>) -> ()
      "scf.yield"() : () -> ()
    }) : (i1) -> ()
    "func.return"() : () -> ()
  }) {function_type = (memref<?xi8>, i32, i32) -> (), llvm.linkage = #llvm.linkage<linkonce_odr>, sym_name = "_ZNSt8__detail18__to_chars_10_implIjEEvPcjT_"} : () -> ()
  "func.func"() ({
  ^bb0(%arg0: memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>, %arg1: i64):
    %0 = "func.call"(%arg0) {callee = @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7_M_dataEv} : (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> memref<?xi8>
    %1 = "arith.index_cast"(%arg1) : (i64) -> index
    %2 = "polygeist.subindex"(%0, %1) : (memref<?xi8>, index) -> memref<?xi8>
    "func.return"(%2) : (memref<?xi8>) -> ()
  }) {function_type = (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>, i64) -> memref<?xi8>, llvm.linkage = #llvm.linkage<available_externally>, sym_name = "_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEixEm"} : () -> ()
  "func.func"() ({
  ^bb0(%arg0: memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>, %arg1: memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>):
    %0 = "arith.constant"() {value = 0 : i64} : () -> i64
    %1 = "arith.constant"() {value = 16 : i64} : () -> i64
    %2 = "arith.constant"() {value = 0 : i8} : () -> i8
    %3 = "polygeist.memref2pointer"(%arg0) : (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> !llvm.ptr<!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>
    %4 = "polygeist.pointer2memref"(%3) : (!llvm.ptr<!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> memref<?x!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>>
    %5 = "func.call"(%arg0) {callee = @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE13_M_local_dataEv} : (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> memref<?xi8>
    %6 = "func.call"(%arg1) {callee = @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE16_M_get_allocatorEv} : (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> memref<?x!llvm.struct<(struct<(i8)>)>>
    "func.call"(%4, %5, %6) {callee = @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderC1EPcOS3_} : (memref<?x!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>>, memref<?xi8>, memref<?x!llvm.struct<(struct<(i8)>)>>) -> ()
    %7 = "func.call"(%arg1) {callee = @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv} : (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> i8
    %8 = "arith.cmpi"(%7, %2) {predicate = 1 : i64} : (i8, i8) -> i1
    "scf.if"(%8) ({
      %11 = "llvm.getelementptr"(%3) {rawConstantIndices = array<i32: 0, 2>} : (!llvm.ptr<!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> !llvm.ptr<struct<(i64, array<8 x i8>)>>
      %12 = "polygeist.pointer2memref"(%11) : (!llvm.ptr<struct<(i64, array<8 x i8>)>>) -> memref<?xi8>
      %13 = "polygeist.memref2pointer"(%arg1) : (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> !llvm.ptr<!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>
      %14 = "llvm.getelementptr"(%13) {rawConstantIndices = array<i32: 0, 2>} : (!llvm.ptr<!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> !llvm.ptr<struct<(i64, array<8 x i8>)>>
      %15 = "polygeist.pointer2memref"(%14) : (!llvm.ptr<struct<(i64, array<8 x i8>)>>) -> memref<?xi8>
      %16 = "func.call"(%12, %15, %1) {callee = @_ZNSt11char_traitsIcE4copyEPcPKcm} : (memref<?xi8>, memref<?xi8>, i64) -> memref<?xi8>
      "scf.yield"() : () -> ()
    }, {
      %11 = "func.call"(%arg1) {callee = @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7_M_dataEv} : (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> memref<?xi8>
      "func.call"(%arg0, %11) {callee = @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7_M_dataEPc} : (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>, memref<?xi8>) -> ()
      %12 = "polygeist.memref2pointer"(%arg1) : (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> !llvm.ptr<!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>
      %13 = "llvm.getelementptr"(%12) {rawConstantIndices = array<i32: 0, 2>} : (!llvm.ptr<!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> !llvm.ptr<struct<(i64, array<8 x i8>)>>
      %14 = "llvm.getelementptr"(%13) {rawConstantIndices = array<i32: 0, 0>} : (!llvm.ptr<struct<(i64, array<8 x i8>)>>) -> !llvm.ptr<i64>
      %15 = "llvm.load"(%14) : (!llvm.ptr<i64>) -> i64
      "func.call"(%arg0, %15) {callee = @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_capacityEm} : (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>, i64) -> ()
      "scf.yield"() : () -> ()
    }) : (i1) -> ()
    %9 = "func.call"(%arg1) {callee = @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6lengthEv} : (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> i64
    "func.call"(%arg0, %9) {callee = @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_lengthEm} : (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>, i64) -> ()
    %10 = "func.call"(%arg1) {callee = @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE13_M_local_dataEv} : (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> memref<?xi8>
    "func.call"(%arg1, %10) {callee = @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7_M_dataEPc} : (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>, memref<?xi8>) -> ()
    "func.call"(%arg1, %0) {callee = @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE13_M_set_lengthEm} : (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>, i64) -> ()
    "func.return"() : () -> ()
  }) {function_type = (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>, memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> (), llvm.linkage = #llvm.linkage<available_externally>, sym_name = "_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1EOS4_"} : () -> ()
  "func.func"() ({
  ^bb0(%arg0: memref<?x!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>>, %arg1: memref<?xi8>, %arg2: memref<?x!llvm.struct<(struct<(i8)>)>>):
    %0 = "polygeist.memref2pointer"(%arg0) : (memref<?x!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>>) -> !llvm.ptr<!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>>
    %1 = "polygeist.pointer2memref"(%0) : (!llvm.ptr<!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>>) -> memref<?x!llvm.struct<(struct<(i8)>)>>
    "func.call"(%1, %arg2) {callee = @_ZNSaIcEC1ERKS_} : (memref<?x!llvm.struct<(struct<(i8)>)>>, memref<?x!llvm.struct<(struct<(i8)>)>>) -> ()
    %2 = "llvm.getelementptr"(%0) {rawConstantIndices = array<i32: 0, 1>} : (!llvm.ptr<!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>>) -> !llvm.ptr<memref<?xi8>>
    "llvm.store"(%arg1, %2) : (memref<?xi8>, !llvm.ptr<memref<?xi8>>) -> ()
    "func.return"() : () -> ()
  }) {function_type = (memref<?x!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>>, memref<?xi8>, memref<?x!llvm.struct<(struct<(i8)>)>>) -> (), llvm.linkage = #llvm.linkage<available_externally>, sym_name = "_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderC1EPcRKS3_"} : () -> ()
  "func.func"() ({
  ^bb0(%arg0: memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>):
    %0 = "polygeist.memref2pointer"(%arg0) : (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> !llvm.ptr<!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>
    %1 = "llvm.getelementptr"(%0) {rawConstantIndices = array<i32: 0, 2>} : (!llvm.ptr<!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> !llvm.ptr<struct<(i64, array<8 x i8>)>>
    %2 = "polygeist.pointer2memref"(%1) : (!llvm.ptr<struct<(i64, array<8 x i8>)>>) -> memref<?xi8>
    %3 = "func.call"(%2) {callee = @_ZNSt14pointer_traitsIPcE10pointer_toERc} : (memref<?xi8>) -> memref<?xi8>
    "func.return"(%3) : (memref<?xi8>) -> ()
  }) {function_type = (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> memref<?xi8>, llvm.linkage = #llvm.linkage<available_externally>, sym_name = "_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE13_M_local_dataEv"} : () -> ()
  "func.func"() ({
  }) {function_type = (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>, i64, i8) -> (), llvm.linkage = #llvm.linkage<external>, sym_name = "_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_M_constructEmc", sym_visibility = "private"} : () -> ()
  "func.func"() ({
  ^bb0(%arg0: memref<?x!llvm.struct<(i8)>>):
    "func.return"() : () -> ()
  }) {function_type = (memref<?x!llvm.struct<(i8)>>) -> (), llvm.linkage = #llvm.linkage<linkonce_odr>, sym_name = "_ZN9__gnu_cxx13new_allocatorIcEC1Ev"} : () -> ()
  "func.func"() ({
  ^bb0(%arg0: memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>):
    %0 = "polygeist.memref2pointer"(%arg0) : (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> !llvm.ptr<!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>
    %1 = "llvm.getelementptr"(%0) {rawConstantIndices = array<i32: 0, 0>} : (!llvm.ptr<!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> !llvm.ptr<!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>>
    %2 = "llvm.getelementptr"(%1) {rawConstantIndices = array<i32: 0, 1>} : (!llvm.ptr<!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>>) -> !llvm.ptr<memref<?xi8>>
    %3 = "llvm.load"(%2) : (!llvm.ptr<memref<?xi8>>) -> memref<?xi8>
    "func.return"(%3) : (memref<?xi8>) -> ()
  }) {function_type = (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> memref<?xi8>, llvm.linkage = #llvm.linkage<available_externally>, sym_name = "_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7_M_dataEv"} : () -> ()
  "func.func"() ({
  ^bb0(%arg0: memref<?x!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>>, %arg1: memref<?xi8>, %arg2: memref<?x!llvm.struct<(struct<(i8)>)>>):
    %0 = "polygeist.memref2pointer"(%arg0) : (memref<?x!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>>) -> !llvm.ptr<!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>>
    %1 = "polygeist.pointer2memref"(%0) : (!llvm.ptr<!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>>) -> memref<?x!llvm.struct<(struct<(i8)>)>>
    "func.call"(%1, %arg2) {callee = @_ZNSaIcEC1ERKS_} : (memref<?x!llvm.struct<(struct<(i8)>)>>, memref<?x!llvm.struct<(struct<(i8)>)>>) -> ()
    %2 = "llvm.getelementptr"(%0) {rawConstantIndices = array<i32: 0, 1>} : (!llvm.ptr<!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>>) -> !llvm.ptr<memref<?xi8>>
    "llvm.store"(%arg1, %2) : (memref<?xi8>, !llvm.ptr<memref<?xi8>>) -> ()
    "func.return"() : () -> ()
  }) {function_type = (memref<?x!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>>, memref<?xi8>, memref<?x!llvm.struct<(struct<(i8)>)>>) -> (), llvm.linkage = #llvm.linkage<available_externally>, sym_name = "_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderC1EPcOS3_"} : () -> ()
  "func.func"() ({
  ^bb0(%arg0: memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>):
    %0 = "polygeist.memref2pointer"(%arg0) : (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> !llvm.ptr<!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>
    %1 = "llvm.getelementptr"(%0) {rawConstantIndices = array<i32: 0, 0>} : (!llvm.ptr<!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> !llvm.ptr<!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>>
    %2 = "llvm.getelementptr"(%1) {rawConstantIndices = array<i32: 0, 0>} : (!llvm.ptr<!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>>) -> !llvm.ptr<struct<(struct<(i8)>)>>
    %3 = "llvm.mlir.null"() : () -> !llvm.ptr<struct<(struct<(i8)>)>>
    %4 = "llvm.icmp"(%2, %3) {predicate = 1 : i64} : (!llvm.ptr<struct<(struct<(i8)>)>>, !llvm.ptr<struct<(struct<(i8)>)>>) -> i1
    %5 = "arith.select"(%4, %2, %3) : (i1, !llvm.ptr<struct<(struct<(i8)>)>>, !llvm.ptr<struct<(struct<(i8)>)>>) -> !llvm.ptr<struct<(struct<(i8)>)>>
    %6 = "polygeist.pointer2memref"(%5) : (!llvm.ptr<struct<(struct<(i8)>)>>) -> memref<?x!llvm.struct<(struct<(i8)>)>>
    "func.return"(%6) : (memref<?x!llvm.struct<(struct<(i8)>)>>) -> ()
  }) {function_type = (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> memref<?x!llvm.struct<(struct<(i8)>)>>, llvm.linkage = #llvm.linkage<available_externally>, sym_name = "_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE16_M_get_allocatorEv"} : () -> ()
  "func.func"() ({
  ^bb0(%arg0: memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>):
    %0 = "func.call"(%arg0) {callee = @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7_M_dataEv} : (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> memref<?xi8>
    %1 = "func.call"(%arg0) {callee = @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE13_M_local_dataEv} : (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> memref<?xi8>
    %2 = "polygeist.memref2pointer"(%0) : (memref<?xi8>) -> !llvm.ptr<i8>
    %3 = "polygeist.memref2pointer"(%1) : (memref<?xi8>) -> !llvm.ptr<i8>
    %4 = "llvm.icmp"(%2, %3) {predicate = 0 : i64} : (!llvm.ptr<i8>, !llvm.ptr<i8>) -> i1
    %5 = "arith.extui"(%4) : (i1) -> i8
    "func.return"(%5) : (i8) -> ()
  }) {function_type = (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> i8, llvm.linkage = #llvm.linkage<available_externally>, sym_name = "_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_is_localEv"} : () -> ()
  "func.func"() ({
  ^bb0(%arg0: memref<?xi8>, %arg1: memref<?xi8>, %arg2: i64):
    %0 = "arith.constant"() {value = 1 : index} : () -> index
    %1 = "arith.constant"() {value = 0 : i64} : () -> i64
    %2 = "arith.constant"() {value = 0 : index} : () -> index
    %3 = "memref.alloca"() {operand_segment_sizes = array<i32: 0, 0>} : () -> memref<memref<?xi8>>
    %4 = "arith.cmpi"(%arg2, %1) {predicate = 0 : i64} : (i64, i64) -> i1
    %5 = "arith.cmpi"(%arg2, %1) {predicate = 1 : i64} : (i64, i64) -> i1
    "scf.if"(%4) ({
      "affine.store"(%arg0, %3) {map = affine_map<() -> ()>} : (memref<?xi8>, memref<memref<?xi8>>) -> ()
      "scf.yield"() : () -> ()
    }, {
    }) : (i1) -> ()
    "scf.if"(%5) ({
      %7 = "arith.index_cast"(%arg2) : (i64) -> index
      "scf.for"(%2, %7, %0) ({
      ^bb0(%arg3: index):
        %8 = "memref.load"(%arg1, %arg3) : (memref<?xi8>, index) -> i8
        "memref.store"(%8, %arg0, %arg3) : (i8, memref<?xi8>, index) -> ()
        "scf.yield"() : () -> ()
      }) : (index, index, index) -> ()
      "affine.store"(%arg0, %3) {map = affine_map<() -> ()>} : (memref<?xi8>, memref<memref<?xi8>>) -> ()
      "scf.yield"() : () -> ()
    }, {
    }) : (i1) -> ()
    %6 = "affine.load"(%3) {map = affine_map<() -> ()>} : (memref<memref<?xi8>>) -> memref<?xi8>
    "func.return"(%6) : (memref<?xi8>) -> ()
  }) {function_type = (memref<?xi8>, memref<?xi8>, i64) -> memref<?xi8>, llvm.linkage = #llvm.linkage<linkonce_odr>, sym_name = "_ZNSt11char_traitsIcE4copyEPcPKcm"} : () -> ()
  "func.func"() ({
  ^bb0(%arg0: memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>, %arg1: memref<?xi8>):
    %0 = "polygeist.memref2pointer"(%arg0) : (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> !llvm.ptr<!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>
    %1 = "llvm.getelementptr"(%0) {rawConstantIndices = array<i32: 0, 0>} : (!llvm.ptr<!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> !llvm.ptr<!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>>
    %2 = "llvm.getelementptr"(%1) {rawConstantIndices = array<i32: 0, 1>} : (!llvm.ptr<!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>>) -> !llvm.ptr<memref<?xi8>>
    "llvm.store"(%arg1, %2) : (memref<?xi8>, !llvm.ptr<memref<?xi8>>) -> ()
    "func.return"() : () -> ()
  }) {function_type = (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>, memref<?xi8>) -> (), llvm.linkage = #llvm.linkage<available_externally>, sym_name = "_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7_M_dataEPc"} : () -> ()
  "func.func"() ({
  ^bb0(%arg0: memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>, %arg1: i64):
    %0 = "polygeist.memref2pointer"(%arg0) : (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> !llvm.ptr<!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>
    %1 = "llvm.getelementptr"(%0) {rawConstantIndices = array<i32: 0, 2>} : (!llvm.ptr<!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> !llvm.ptr<struct<(i64, array<8 x i8>)>>
    %2 = "llvm.getelementptr"(%1) {rawConstantIndices = array<i32: 0, 0>} : (!llvm.ptr<struct<(i64, array<8 x i8>)>>) -> !llvm.ptr<i64>
    "llvm.store"(%arg1, %2) : (i64, !llvm.ptr<i64>) -> ()
    "func.return"() : () -> ()
  }) {function_type = (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>, i64) -> (), llvm.linkage = #llvm.linkage<available_externally>, sym_name = "_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE11_M_capacityEm"} : () -> ()
  "func.func"() ({
  ^bb0(%arg0: memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>, %arg1: i64):
    %0 = "polygeist.memref2pointer"(%arg0) : (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> !llvm.ptr<!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>
    %1 = "llvm.getelementptr"(%0) {rawConstantIndices = array<i32: 0, 1>} : (!llvm.ptr<!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> !llvm.ptr<i64>
    "llvm.store"(%arg1, %1) : (i64, !llvm.ptr<i64>) -> ()
    "func.return"() : () -> ()
  }) {function_type = (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>, i64) -> (), llvm.linkage = #llvm.linkage<available_externally>, sym_name = "_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_lengthEm"} : () -> ()
  "func.func"() ({
  ^bb0(%arg0: memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>):
    %0 = "polygeist.memref2pointer"(%arg0) : (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> !llvm.ptr<!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>
    %1 = "llvm.getelementptr"(%0) {rawConstantIndices = array<i32: 0, 1>} : (!llvm.ptr<!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> !llvm.ptr<i64>
    %2 = "llvm.load"(%1) : (!llvm.ptr<i64>) -> i64
    "func.return"(%2) : (i64) -> ()
  }) {function_type = (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> i64, llvm.linkage = #llvm.linkage<available_externally>, sym_name = "_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6lengthEv"} : () -> ()
  "func.func"() ({
  ^bb0(%arg0: memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>, %arg1: i64):
    %0 = "arith.constant"() {value = 0 : i8} : () -> i8
    %1 = "memref.alloca"() {operand_segment_sizes = array<i32: 0, 0>} : () -> memref<1xi8>
    %2 = "memref.cast"(%1) : (memref<1xi8>) -> memref<?xi8>
    %3 = "llvm.mlir.undef"() : () -> i8
    "affine.store"(%3, %1) {map = affine_map<() -> (0)>} : (i8, memref<1xi8>) -> ()
    "func.call"(%arg0, %arg1) {callee = @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9_M_lengthEm} : (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>, i64) -> ()
    %4 = "func.call"(%arg0) {callee = @_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7_M_dataEv} : (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> memref<?xi8>
    %5 = "arith.index_cast"(%arg1) : (i64) -> index
    %6 = "polygeist.subindex"(%4, %5) : (memref<?xi8>, index) -> memref<?xi8>
    "affine.store"(%0, %1) {map = affine_map<() -> (0)>} : (i8, memref<1xi8>) -> ()
    "func.call"(%6, %2) {callee = @_ZNSt11char_traitsIcE6assignERcRKc} : (memref<?xi8>, memref<?xi8>) -> ()
    "func.return"() : () -> ()
  }) {function_type = (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>, i64) -> (), llvm.linkage = #llvm.linkage<available_externally>, sym_name = "_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE13_M_set_lengthEm"} : () -> ()
  "func.func"() ({
  ^bb0(%arg0: memref<?x!llvm.struct<(struct<(i8)>)>>, %arg1: memref<?x!llvm.struct<(struct<(i8)>)>>):
    %0 = "polygeist.memref2pointer"(%arg0) : (memref<?x!llvm.struct<(struct<(i8)>)>>) -> !llvm.ptr<struct<(struct<(i8)>)>>
    %1 = "polygeist.pointer2memref"(%0) : (!llvm.ptr<struct<(struct<(i8)>)>>) -> memref<?x!llvm.struct<(i8)>>
    %2 = "polygeist.memref2pointer"(%arg1) : (memref<?x!llvm.struct<(struct<(i8)>)>>) -> !llvm.ptr<struct<(struct<(i8)>)>>
    %3 = "llvm.getelementptr"(%2) {rawConstantIndices = array<i32: 0, 0>} : (!llvm.ptr<struct<(struct<(i8)>)>>) -> !llvm.ptr<struct<(i8)>>
    %4 = "llvm.mlir.null"() : () -> !llvm.ptr<struct<(i8)>>
    %5 = "llvm.icmp"(%3, %4) {predicate = 1 : i64} : (!llvm.ptr<struct<(i8)>>, !llvm.ptr<struct<(i8)>>) -> i1
    %6 = "arith.select"(%5, %3, %4) : (i1, !llvm.ptr<struct<(i8)>>, !llvm.ptr<struct<(i8)>>) -> !llvm.ptr<struct<(i8)>>
    %7 = "polygeist.pointer2memref"(%6) : (!llvm.ptr<struct<(i8)>>) -> memref<?x!llvm.struct<(i8)>>
    "func.call"(%1, %7) {callee = @_ZN9__gnu_cxx13new_allocatorIcEC1ERKS1_} : (memref<?x!llvm.struct<(i8)>>, memref<?x!llvm.struct<(i8)>>) -> ()
    "func.return"() : () -> ()
  }) {function_type = (memref<?x!llvm.struct<(struct<(i8)>)>>, memref<?x!llvm.struct<(struct<(i8)>)>>) -> (), llvm.linkage = #llvm.linkage<available_externally>, sym_name = "_ZNSaIcEC1ERKS_"} : () -> ()
  "func.func"() ({
  ^bb0(%arg0: memref<?xi8>):
    "func.return"(%arg0) : (memref<?xi8>) -> ()
  }) {function_type = (memref<?xi8>) -> memref<?xi8>, llvm.linkage = #llvm.linkage<linkonce_odr>, sym_name = "_ZNSt14pointer_traitsIPcE10pointer_toERc"} : () -> ()
  "func.func"() ({
  ^bb0(%arg0: memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>):
    %0 = "polygeist.memref2pointer"(%arg0) : (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> !llvm.ptr<!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>
    %1 = "llvm.getelementptr"(%0) {rawConstantIndices = array<i32: 0, 2>} : (!llvm.ptr<!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> !llvm.ptr<struct<(i64, array<8 x i8>)>>
    %2 = "polygeist.pointer2memref"(%1) : (!llvm.ptr<struct<(i64, array<8 x i8>)>>) -> memref<?xi8>
    %3 = "func.call"(%2) {callee = @_ZNSt14pointer_traitsIPKcE10pointer_toERS0_} : (memref<?xi8>) -> memref<?xi8>
    "func.return"(%3) : (memref<?xi8>) -> ()
  }) {function_type = (memref<?x!llvm.struct<(!llvm.struct<(struct<(struct<(i8)>)>, memref<?xi8>)>, i64, struct<(i64, array<8 x i8>)>)>>) -> memref<?xi8>, llvm.linkage = #llvm.linkage<available_externally>, sym_name = "_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE13_M_local_dataEv"} : () -> ()
  "func.func"() ({
  ^bb0(%arg0: memref<?xi8>, %arg1: memref<?xi8>):
    %0 = "affine.load"(%arg1) {map = affine_map<() -> (0)>} : (memref<?xi8>) -> i8
    "affine.store"(%0, %arg0) {map = affine_map<() -> (0)>} : (i8, memref<?xi8>) -> ()
    "func.return"() : () -> ()
  }) {function_type = (memref<?xi8>, memref<?xi8>) -> (), llvm.linkage = #llvm.linkage<linkonce_odr>, sym_name = "_ZNSt11char_traitsIcE6assignERcRKc"} : () -> ()
  "func.func"() ({
  ^bb0(%arg0: memref<?x!llvm.struct<(i8)>>, %arg1: memref<?x!llvm.struct<(i8)>>):
    "func.return"() : () -> ()
  }) {function_type = (memref<?x!llvm.struct<(i8)>>, memref<?x!llvm.struct<(i8)>>) -> (), llvm.linkage = #llvm.linkage<linkonce_odr>, sym_name = "_ZN9__gnu_cxx13new_allocatorIcEC1ERKS1_"} : () -> ()
  "func.func"() ({
  ^bb0(%arg0: memref<?xi8>):
    "func.return"(%arg0) : (memref<?xi8>) -> ()
  }) {function_type = (memref<?xi8>) -> memref<?xi8>, llvm.linkage = #llvm.linkage<linkonce_odr>, sym_name = "_ZNSt14pointer_traitsIPKcE10pointer_toERS0_"} : () -> ()
}) {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry<"dlti.endianness", "little">, #dlti.dl_entry<i64, dense<64> : vector<2xi32>>, #dlti.dl_entry<f80, dense<128> : vector<2xi32>>, #dlti.dl_entry<i1, dense<8> : vector<2xi32>>, #dlti.dl_entry<i8, dense<8> : vector<2xi32>>, #dlti.dl_entry<i16, dense<16> : vector<2xi32>>, #dlti.dl_entry<i32, dense<32> : vector<2xi32>>, #dlti.dl_entry<f16, dense<16> : vector<2xi32>>, #dlti.dl_entry<f64, dense<64> : vector<2xi32>>, #dlti.dl_entry<f128, dense<128> : vector<2xi32>>>, llvm.data_layout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128", llvm.target_triple = "x86_64-unknown-linux-gnu", "polygeist.target-cpu" = "x86-64", "polygeist.target-features" = "+cx8,+fxsr,+mmx,+sse,+sse2,+x87", "polygeist.tune-cpu" = "generic"} : () -> ()

Of note is the error line:

loc("/usr/lib/gcc/x86_64-linux-gnu/10.3.1/../../../../include/c++/10.3.1/bits/charconv.h":62:12): error: 'arith.divsi' op requires the same type for all operands and results

Which most likely refers to:

 %34 = "arith.divsi"(%arg4, %9) : (i32, i64) -> i32

It seems that %9 should actually be %8 (the same value, before extension to i64). Or maybe arith.divsi should support operands of mixed types?

yar-sh avatar Apr 06 '23 17:04 yar-sh