[LLVMdev] interesting LLVM code optimization issue regarding timer registers

Tim Northover t.p.northover at gmail.com
Fri Feb 21 11:24:55 PST 2014


Hi Reed,

> How would this intrinsic be implemented properly in llvm so this cannot
> happen?

At the intrinsic level, you'd make sure @llvm.whatever had the most
side-effecty definition possible (I think it's actually the default:
"this may read or write completely random memory wherever it feels
like").

At the instruction level, you'd make sure hasSideEffects=1 was set.

Theoretically, a completely side-effect-free sequence of instructions
might still be moved around, but you're almost certainly Doing It
Wrong if that affects you: LLVM is always going to be able to insert
COPYs, spills and various other bits in there that you didn't write
down.

Cheers.

Tim.



More information about the llvm-dev mailing list