Closed svenstucki closed 8 years ago
I'm attempting to use riscv-llvm to compile some larger projects and noticing this error a lot. I just wanted to add that it's only apparent for me on -O1 and above; -O0 works just fine.
That seems to be the problem indeed. I've only noticed now, because I was trying to run some benchmarks, no problems with -O0
otherwise. I basically cannot compile any of my code with -O1 or better.
The problem above can also be triggered with those arguments only:
clang -cc1 -triple riscv -S -O1 cvp-8xKHIQ.c
(Or -O2
and -O3
of course.)
I think I fixed it or at least found a workaround.
The RISCVInstrInfo::InsertBranchAtInst
function switch only has cases for branch condition codes, which have a corresponding instruction. Branches like BGTU (which it tried to generate in my case) aren't supported. After I added that, I noticed that the RISCVInstrInfo::InsertConstBranchAtInst
function had cases for them and copied them over.
Now I suppose the root cause for this could be different, e.g. if the llvm optimizer isn't supposed to generate those branch conditions at all.
@ievans Have a look at my fork: https://github.com/svenstucki/riscv-llvm
Do you want me to send a pull request?
By the way, the example above results in quite inefficient assembly code. The result is basically the same for -O1
up to -O3
. There are always 5 branches generated, while 2 would suffice.
This appears to be fixed as far as I can tell.
I compared the assembly to the riscv-gcc output(which has 5 branches btw) and there is an extraneous jump in the llvm version due to a missed fall through opportunity. I'll close this issue and refile the performance issue.
Hi, I ran into the error from the title when playing around a bit with clang.
Here's a minimal testcase:
This is the compile command I used (autogenerated from a Makefile with a different target architecture in mind, so not everything makes sense :):
Here's the full error message: