[LLVMdev] Target description flags for instructions which may trap
evan.cheng at apple.com
Thu Oct 30 08:57:01 PDT 2008
On Oct 30, 2008, at 7:08 AM, Richard Osborne wrote:
> What are the correct target description side effect flags for
> instructions which may trap (e.g. divide / remainder)? The divide
> instruction in my backend currently has no flags set. I've enabled the
> MachineLICM pass and it's causing a miscompilation by hoisting a
> by zero instruction out of the loop. Clearly this pass needs to be
> aware that this is not safe. The current test in the MachineLICM is as
> // Ignore stuff that we obviously can't hoist.
> if (TID.mayStore() || TID.isCall() || TID.isReturn() ||
> TID.isBranch() ||
> return false;
> Setting hasSideEffects = 1 seems to work, but I'm not sure if that's
> intended use of this flag. I notice that divide / remainder
> for other architectures are not marked in this way. Also it is also
> pessimistic: if the divisor is know to be non zero then the
> couldn't trap and would be safe to motion.
All such side effects that are not explicitly modeled fall under the
hasSideEffects bucket. It's something you can use now.
That said, there has been a lot of interest in enhancing LLVM with
modeling trapping instructions. You should do a search on llvmdev.
> Richard Osborne | XMOS
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
More information about the llvm-dev