Closed chun92 closed 9 years ago
This is an error in AVR-LLVM. I have opened up a new issue for this problem (#94).
Note that if you want to get the code to compile quickly, an easy fix would be to use rcall _Z3foov
instead of call _Z3foov
. The rcall
instruction does not have this problem.
By the way, did you say that you compiled the original code and it ran correctly on Arduino? :P
The problem occurs when I tried to write the function in the other source.
For example, I made the foo()
function in foo.h and tried to call foo()
in main.cpp
, foo()
function is called with call _Z3foov
instruction. I wonder that the problem is originated from linking problem or instruction problem. :D
LLVM by default lowers calls to a CALL k
instruction, which causes an assertion error (see issue #94). We should probably try to use RJMP k
instead, as it is more efficient.
With optimisations, the function is inlined, and so a call isn't generated, so the error doesn't call.
I compiled following source code to test the I/O test and I/O doesn't works in function call. Following is the compilation command.
In original assembly code, function foo is inlined to main function and I check that output works correctly on Arduino Uno board. but when I substitute
out 5, r24
tocall _Z3foov
below theLBB1_1
label, output doesn't works. I'm not sure that I make some stupid mistakes or there are any bugs in clang, but I'm embarrassed to see the I/O fails with regular function body and call instruction which clang generated. (I doubt there is calling convention problem) I found this problem in linking the object files while I build the Arduino libraries.