<div dir="ltr">Hey Vedant,<div>You are right that this is a reasonable alternative.</div><div>It would save some hash lookups, but not sure it's worth it one way or the other.<div><br></div><div>I'll approve the original patch and leave it up to Geoff to decide</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jul 13, 2017 at 6:59 PM, Vedant Kumar <span dir="ltr"><<a href="mailto:vsk@apple.com" target="_blank">vsk@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I'm a newbie to this part of llvm, but it seems like isSameMemGeneration isn't expected to be passed instructions which don't have corresponding memory accesses. One alternative approach is to check that the parsed mem-inst for the candidate instruction is valid, before querying isSameMemGeneration. That could save some time.<br>
<br>
E.g:<br>
<br>
<br><br>
<br>
best,<br>
vedant<br>
<br>
<br>
> On Jul 12, 2017, at 11:45 AM, Geoff Berry via Phabricator via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br>
><br>
> gberry created this revision.<br>
> Herald added subscribers: Prazek, mcrosier.<br>
><br>
> When checking for memory dependencies between calls using MemorySSA,<br>
> handle cases where the calls have no MemoryAccess associated with them<br>
> because the AA analysis being used has determined that the call does not<br>
> read/write memory.<br>
><br>
> Fixes PR33756<br>
><br>
><br>
> <a href="https://reviews.llvm.org/D35317" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D35317</a><br>
><br>
> Files:<br>
>  lib/Transforms/Scalar/<wbr>EarlyCSE.cpp<br>
>  test/Transforms/EarlyCSE/<wbr>globalsaa-memoryssa.ll<br>
><br>
><br>
> Index: test/Transforms/EarlyCSE/<wbr>globalsaa-memoryssa.ll<br>
> ==============================<wbr>==============================<wbr>=======<br>
> --- /dev/null<br>
> +++ test/Transforms/EarlyCSE/<wbr>globalsaa-memoryssa.ll<br>
> @@ -0,0 +1,23 @@<br>
> +; RUN: opt < %s -S -globals-aa -early-cse-memssa | FileCheck %s<br>
> +<br>
> +define i16 @f1() readonly {<br>
> +  ret i16 0<br>
> +}<br>
> +<br>
> +declare void @f2()<br>
> +<br>
> +; Check that EarlyCSE correctly handles function calls that don't have<br>
> +; a MemoryAccess.  In this case the calls to @f1 have no<br>
> +; MemoryAccesses since globals-aa determines that @f1 doesn't<br>
> +; read/write memory at all.<br>
> +<br>
> +; CHECK-LABEL: @f3(<br>
> +; CHECK-NEXT: %call1 = call i16 @f1()<br>
> +; CHECK-NEXT: call void @f2()<br>
> +; CHECK-NEXT  ret void<br>
> +define void @f3() {<br>
> +  %call1 = call i16 @f1()<br>
> +  call void @f2()<br>
> +  %call2 = call i16 @f1()<br>
> +  ret void<br>
> +}<br>
> Index: lib/Transforms/Scalar/<wbr>EarlyCSE.cpp<br>
> ==============================<wbr>==============================<wbr>=======<br>
> --- lib/Transforms/Scalar/<wbr>EarlyCSE.cpp<br>
> +++ lib/Transforms/Scalar/<wbr>EarlyCSE.cpp<br>
> @@ -562,13 +562,20 @@<br>
>   if (!MSSA)<br>
>     return false;<br>
><br>
> +  // If MemorySSA has determined that one of EarlierInst or LaterInst does not<br>
> +  // read/write memory, then we can safely return true here.<br>
> +  MemoryAccess *EarlierMA = MSSA->getMemoryAccess(<wbr>EarlierInst);<br>
> +  MemoryAccess *LaterMA = MSSA->getMemoryAccess(<wbr>LaterInst);<br>
> +  if (!EarlierMA || !LaterMA)<br>
> +    return true;<br>
> +<br>
>   // Since we know LaterDef dominates LaterInst and EarlierInst dominates<br>
>   // LaterInst, if LaterDef dominates EarlierInst then it can't occur between<br>
>   // EarlierInst and LaterInst and neither can any other write that potentially<br>
>   // clobbers LaterInst.<br>
>   MemoryAccess *LaterDef =<br>
>       MSSA->getWalker()-><wbr>getClobberingMemoryAccess(<wbr>LaterInst);<br>
> -  return MSSA->dominates(LaterDef, MSSA->getMemoryAccess(<wbr>EarlierInst));<br>
> +  return MSSA->dominates(LaterDef, EarlierMA);<br>
> }<br>
><br>
> bool EarlyCSE::processNode(<wbr>DomTreeNode *Node) {<br>
><br>
><br>
> <D35317.106266.patch>_________<wbr>______________________________<wbr>________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
<br>
<br></blockquote></div><br></div>