`llvm.add` is interpreted as `llvm.addrspacecast`

./std/primitive.mojo:71:64: error: 'llvm.addrspacecast' op requires a single operand
value: __mlir_op.`llvm.add`[_type: __mlir_type.i32](self.value, rhs.value)
./std/primitive.mojo:71:64: error: 'llvm.addrspacecast' op requires a single operand
value: __mlir_op.`llvm.add`[_type: __mlir_type.i32](self.value, rhs.value)
This feels like it's not working correctly, considering add is documented as something else.
62 Replies
jmky
jmky13mo ago
Can you share the actual docs on LLVM dialect for this Op? I also find that the translation between Mojo syntax to dialect is a black box to us For eg the index.casts index.castu syntax are different from Mojo's
TeamPuzel
TeamPuzel13mo ago
this is why they're different
No description
TeamPuzel
TeamPuzel13mo ago
both llvm and index dialects are off by one at least that's what it looks like :D well, sometimes
ModularBot
ModularBot13mo ago
Congrats @TeamPuzel, you just advanced to level 13!
TeamPuzel
TeamPuzel13mo ago
it seems like you have to use the one before what you actually want
TeamPuzel
TeamPuzel13mo ago
it's the second one
TeamPuzel
TeamPuzel13mo ago
whichever one I use mojo seems to take the next
No description
Stole
Stole13mo ago
This is quite funny. On my machine, I can't seem to use anything from the llvm dialect (and haven't tried to before), it can't find the llvm.add and other __mlir_ops, but the index dialect works fine and isn't one off as yours seems to be. For example, I can run the following, and it prints 64:
print(__mlir_op.`index.sizeof`[_type : __mlir_type.index]())
print(__mlir_op.`index.sizeof`[_type : __mlir_type.index]())
Okay, now I get the same one-off error with llvm dialect. Strange. (just in case, my mojo --version is mojo 0.2.1 (64d14e85))
TeamPuzel
TeamPuzel13mo ago
odd, I have the exact same version Not all of them are one off which makes it even more weird to me Though if I actually try to use llvm.ashr (which I assume must be add for me) it gives me an add error!
Stole
Stole13mo ago
First my LSP says that llvm.add is unregistered, then running it in console says llvm.addrspacecast wants a single operand.
TeamPuzel
TeamPuzel13mo ago
Yeah, I'm using ssh into a linux laptop with too little ram to handle the lsp so I don't even see those :D if you use ashr you will get add
Stole
Stole13mo ago
On my end it crashes if I replace add with ashr 🤷‍♂️
TeamPuzel
TeamPuzel13mo ago
unfortunately trying to add i32 in this way crashes llvm
mojo: /__w/modular/modular/third-party/llvm-project/llvm/include/llvm/Support/Casting.h:572: decltype(auto) llvm::cast(From &) [To = mlir::BytecodeOpInterface, From = mlir::Operation]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
Please submit a bug report to https://github.com/modularml/mojo/issues and include the crash backtrace along with all the relevant source codes.
Stack dump:
0. Program arguments: mojo run ./test.mojo
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 mojo 0x0000561a0e3f6957
1 mojo 0x0000561a0e3f452e
2 mojo 0x0000561a0e3f702f
3 libc.so.6 0x00007f5596442520
4 libc.so.6 0x00007f5596496a7c pthread_kill + 300
5 libc.so.6 0x00007f5596442476 raise + 22
6 libc.so.6 0x00007f55964287f3 abort + 211
7 libc.so.6 0x00007f559642871b
8 libc.so.6 0x00007f5596439e96
9 mojo 0x0000561a0fcffd35
10 mojo 0x0000561a0fd00ed8
11 mojo 0x0000561a0fcffe8f
12 mojo 0x0000561a0fcff0e0
13 mojo 0x0000561a0fcf2c70
14 mojo 0x0000561a0e849174
15 mojo 0x0000561a0e7b8fcc
16 mojo 0x0000561a0fd53913
17 mojo 0x0000561a0fd53b79
18 mojo 0x0000561a0fd198c4
19 mojo 0x0000561a0e7b7344
20 mojo 0x0000561a0e83e854
21 mojo 0x0000561a0e81caef
22 mojo 0x0000561a0e81d2ab
23 mojo 0x0000561a0e3c14ff
24 mojo 0x0000561a0e3a8a50
25 mojo 0x0000561a0e3c0460
26 mojo 0x0000561a0e3a2926
27 libc.so.6 0x00007f5596429d90
28 libc.so.6 0x00007f5596429e40 __libc_start_main + 128
29 mojo 0x0000561a0e3a212e
Aborted
mojo: /__w/modular/modular/third-party/llvm-project/llvm/include/llvm/Support/Casting.h:572: decltype(auto) llvm::cast(From &) [To = mlir::BytecodeOpInterface, From = mlir::Operation]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
Please submit a bug report to https://github.com/modularml/mojo/issues and include the crash backtrace along with all the relevant source codes.
Stack dump:
0. Program arguments: mojo run ./test.mojo
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0 mojo 0x0000561a0e3f6957
1 mojo 0x0000561a0e3f452e
2 mojo 0x0000561a0e3f702f
3 libc.so.6 0x00007f5596442520
4 libc.so.6 0x00007f5596496a7c pthread_kill + 300
5 libc.so.6 0x00007f5596442476 raise + 22
6 libc.so.6 0x00007f55964287f3 abort + 211
7 libc.so.6 0x00007f559642871b
8 libc.so.6 0x00007f5596439e96
9 mojo 0x0000561a0fcffd35
10 mojo 0x0000561a0fd00ed8
11 mojo 0x0000561a0fcffe8f
12 mojo 0x0000561a0fcff0e0
13 mojo 0x0000561a0fcf2c70
14 mojo 0x0000561a0e849174
15 mojo 0x0000561a0e7b8fcc
16 mojo 0x0000561a0fd53913
17 mojo 0x0000561a0fd53b79
18 mojo 0x0000561a0fd198c4
19 mojo 0x0000561a0e7b7344
20 mojo 0x0000561a0e83e854
21 mojo 0x0000561a0e81caef
22 mojo 0x0000561a0e81d2ab
23 mojo 0x0000561a0e3c14ff
24 mojo 0x0000561a0e3a8a50
25 mojo 0x0000561a0e3c0460
26 mojo 0x0000561a0e3a2926
27 libc.so.6 0x00007f5596429d90
28 libc.so.6 0x00007f5596429e40 __libc_start_main + 128
29 mojo 0x0000561a0e3a212e
Aborted
Stole
Stole13mo ago
Yep lol
Want results from more Discord servers?
Add your server