[llvm] r237593 - Exploit dereferenceable_or_null attribute in LICM pass

Nick Lewycky nlewycky at google.com
Thu May 21 16:38:24 PDT 2015


On 18 May 2015 at 11:07, Sanjoy Das <sanjoy at playingwithpointers.com> wrote:

> Author: sanjoy
> Date: Mon May 18 13:07:00 2015
> New Revision: 237593
>
> URL: http://llvm.org/viewvc/llvm-project?rev=237593&view=rev
> Log:
> Exploit dereferenceable_or_null attribute in LICM pass
>
> Summary:
> Allow hoisting of loads from values marked with dereferenceable_or_null
> attribute. For values marked with the attribute perform
> context-sensitive analysis to determine whether it's known-non-null or
> not.
>

This commit caused PR23608, see the testcase in that PR.

-/// Only sink or hoist an instruction if it is not a trapping instruction
> +/// Only sink or hoist an instruction if it is not a trapping instruction,
> +/// or if the instruction is known not to trap when moved to the
> preheader.
>  /// or if it is a trapping instruction and is guaranteed to execute.
> -///
> -static bool isSafeToExecuteUnconditionally(const Instruction &Inst,
> +static bool isSafeToExecuteUnconditionally(const Instruction &Inst,
>                                             const DominatorTree *DT,
> +                                           const TargetLibraryInfo *TLI,
>                                             const Loop *CurLoop,
>                                             const LICMSafetyInfo
> *SafetyInfo) {
> -  // If it is not a trapping instruction, it is always safe to hoist.
> -  if (isSafeToSpeculativelyExecute(&Inst))
> +  const Instruction *CtxI = CurLoop->getLoopPreheader()->getTerminator();
>

A Loop* is not guaranteed to have a preheader, in which case
CurLoop->getLoopPreheader() will return null.

Nick


> +  if (isSafeToSpeculativelyExecute(&Inst, CtxI, DT, TLI))
>      return true;
>
>    return isGuaranteedToExecute(Inst, DT, CurLoop, SafetyInfo);
>

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150521/ed9fdcae/attachment.html>


More information about the llvm-commits mailing list