Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Lowering to llvm mlir fails due to hl.add operation on pointers #773

Open
kumarak opened this issue Feb 7, 2025 · 0 comments
Open
Labels
bug Something isn't working

Comments

@kumarak
Copy link
Member

kumarak commented Feb 7, 2025

VAST version

v0.0.66

LLVM version

19.1.0

Operating system

macos

Description

Lowering to llvm mlir fails with llvm.add operation expecting integer as its operand type

test_ptr.c:4:15: error: unexpected error: 'llvm.add' op operand #0 must be signless integer or LLVM dialect-compatible vector of signless integer, but got '!llvm.ptr'
    return p1 + 1;
              ^
test_ptr.c:4:15: error: unexpected note: see current operation: %4 = "llvm.add"(%2, %3) <{overflowFlags = #llvm.overflow<none>}> : (!llvm.ptr, i32) -> !llvm.ptr
    return p1 + 1;
              ^
// -----// IR Dump After IRsToLLVM Failed (vast-irs-to-llvm) //----- //
"builtin.module"() ({
  "builtin.module"() <{sym_name = "/Users/akshayk/Documents/workspace/demo/vast/build/test_ptr.c"}> ({
    "llvm.func"() <{CConv = #llvm.cconv<ccc>, function_type = !llvm.func<ptr (ptr)>, linkage = #llvm.linkage<external>, sym_name = "ptr_increment", visibility_ = 0 : i64}> ({
    ^bb0(%arg0: !llvm.ptr):
      %0 = "llvm.mlir.constant"() <{value = 1 : i64}> : () -> i64
      %1 = "llvm.alloca"(%0) <{elem_type = !llvm.ptr}> : (i64) -> !llvm.ptr
      "llvm.store"(%arg0, %1) <{ordering = 0 : i64}> : (!llvm.ptr, !llvm.ptr) -> ()
      %2 = "llvm.load"(%1) <{ordering = 0 : i64}> : (!llvm.ptr) -> !llvm.ptr
      %3 = "llvm.mlir.constant"() <{value = 1 : i32}> : () -> i32
      %4 = "llvm.add"(%2, %3) <{overflowFlags = #llvm.overflow<none>}> : (!llvm.ptr, i32) -> !llvm.ptr
      "llvm.return"(%4) : (!llvm.ptr) -> ()
    }) : () -> ()
  }) {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry<!hl.ptr<si32>, {vast.abi_align.key = 64 : i32, vast.dl.bw = 64 : i32}>, #dlti.dl_entry<!hl.ptr<ui32>, {vast.abi_align.key = 64 : i32, vast.dl.bw = 64 : i32}>>, vast.core.lang = #core<lang c>, vast.core.target_triple = "arm64-apple-macosx15.0.0"} : () -> ()
}) : () -> ()


[VAST fatal] MLIR pass manager failed when running vast passes

Steps to Reproduce

cat << EOF > test.c
unsigned int *ptr_increment(int *p1) {
    return p1 + 1;
}
EOF

vast-front -vast-emit-mlir=llvm test.c -o test.mlir
@kumarak kumarak added the bug Something isn't working label Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant