[LLVMdev] LICM for function calls

Raoux, Thomas F thomas.f.raoux at intel.com
Tue Jul 14 07:45:20 PDT 2015


Hi,

Right now in LICM (and many other transformations) we always assume it is never safe to speculatively execute a function call. 

The following function always return false for all function calls except for few intrinsics:
bool llvm::isSafeToSpeculativelyExecute(const Value *V,
                                        const DataLayout *TD) {
...
  case Instruction::Call: {
   if (const IntrinsicInst *II = dyn_cast<IntrinsicInst>(Inst)) {
...
   }
    return false; // The called function could have undefined behavior or
                  // side-effects, even if marked readnone nounwind.

In some cases this could have an important performance impact so I'm looking for a potential way to improve it.

Is there any combination of attributes which would guarantee that a function is safe to speculatively execute a function call? (As far as I can tell there isn't.)

Does anybody have a suggestion on what would be the best way to implement such functionality? Or do you think such optimization is undesirable?

Cheers,
Thomas




More information about the llvm-dev mailing list