[LLVMdev] interesting LLVM code optimization issue regarding timer registers

James Courtier-Dutton james.dutton at gmail.com
Sat Feb 22 00:43:04 PST 2014


On 21 February 2014 19:12, reed kotler <rkotler at mips.com> wrote:
> This problem was reported to me by a friend who has an LLVM port that is not
> put back to open source.
>
> Essentially, there is an intrinsic call _lr which is a load register.
>
> so then user code has something like:
>
> start_time = _lr(TIMER_REGISTER)
> .....
> some_code_to_time
> ....
> end_time = _lr(TIMER_REGISTER)
>
> So what happens is that LLVM moves the code as follows:
>
>
>
> start_time = _lr(TIMER_REGISTER)
> end_time = _lr(TIMER_REGISTER)
> .....
> some_code_to_time
> ......
>
> How would this intrinsic be implemented properly in llvm so this cannot
> happen?
>

Is compiling with -O0 acceptable here?
Probably not if you want "some_code_to_time" to be optimized with LLVM.
Is "_Ir(TIMER_REGISTER)" being set as volatile?



More information about the llvm-dev mailing list