Replies: 8 comments
-
Sorry to see some possible bug.
As you know, this is example1.c, and it worked fine. |
Beta Was this translation helpful? Give feedback.
-
I've struggled with the same problem, and it seems like the given let check_instr llctx instr memory =
match Llvm.instr_opcode instr with
| Llvm.Opcode.Call when Llvmutils.is_print instr ->
let arg = Llvm.operand instr 0 in
let v = Semantics.eval arg memory in
F.printf "%s @@ %s : %a\n"
(Llvmutils.string_of_lhs arg) (* here *)
(Llvmutils.string_of_location llctx instr)
Memory.Value.pp v Thus, if we use print(1); int a = 1;
print(a); // clang propagates the value 1 to a, so in llvm ir, it is a call to print with i32 1 it yields the A quick fix on your side may be avoiding such patterns, but it would be great if the template code is updated with pattern-matches on the lhs arg of call instructions :) |
Beta Was this translation helpful? Give feedback.
-
I'm sorry to see we have lost opportunity to fix the bug. let check_instr llctx instr memory =
match Llvm.instr_opcode instr with
| Llvm.Opcode.Call when Llvmutils.is_print instr ->
let arg = Llvm.operand instr 0 in
let v = Semantics.eval arg memory in
F.printf "%s @@ %s : %a\n"
(Llvmutils.string_of_exp arg)
(Llvmutils.string_of_location llctx instr)
Memory.Value.pp v Llvmutils.string_of_exp is defined at https://prosyslab-classroom.github.io/llvmutils/llvmutils/Llvmutils/index.html#val-string_of_exp |
Beta Was this translation helpful? Give feedback.
-
@leporia , please check if this fixes the bug. |
Beta Was this translation helpful? Give feedback.
-
The snipped provided is the same as the one in the original template. But here is the fix that I've implemented. let check_instr llctx instr memory =
match Llvm.instr_opcode instr with
| Llvm.Opcode.Call when Llvmutils.is_print instr -> (
let arg = Llvm.operand instr 0 in
let v = Semantics.eval arg memory in
match Llvm.classify_value arg with
| Llvm.ValueKind.ConstantInt ->
F.printf "%s @@ %a\n"
(Llvmutils.string_of_location llctx instr)
Memory.Value.pp v
| Llvm.ValueKind.Instruction _ ->
F.printf "%s @@ %s : %a\n"
(Llvmutils.string_of_lhs arg)
(Llvmutils.string_of_location llctx instr)
Memory.Value.pp v
| _ -> failwith "Unsupported value") I think there is also a bug in the execution of the tests in dune. As they don't take into account the print statements and cut the output incorrectly. |
Beta Was this translation helpful? Give feedback.
-
@leporia, I was mentioning about #186 (comment). It is different from original code. Your solution seems good too! For your next argument, yes, interval domain has a more relaxed check by cutting after the comma. |
Beta Was this translation helpful? Give feedback.
-
Currently we don't grade your custom testcases. We just encourage you to, before submission, test your code by yourself.
|
Beta Was this translation helpful? Give feedback.
-
I'm sorry I totally missed the edit. Thanks a lot for the support! |
Beta Was this translation helpful? Give feedback.
-
Name: Andrea Lepori
When having a print call that takes as argument an immediate LLVM throws the error
Cannot find lhs of i32 5
. I tried to search everywhere and tried to find the instruction that throw this error but I was unsuccessful. It is before the code that we are supposed to implement.I imagine this is a problem in the template? As it is thrown before the execution of any of my code.
Beta Was this translation helpful? Give feedback.
All reactions