vast
vast copied to clipboard
[Bug]: Lowering to llvm mlir fails due to `hl.add` operation on pointers
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
hey @kumarak @xlauko I think I can help out here. Can you please assign this to me?
@felixjordandev, You can submit a PR with the fixes. I don't think any of us working on this at the moment.
I have create a PR #789 Please review this @kumarak @xlauko