Hello,<br><br>I'm taking a really good look at the MemoryDependenceAnalysis pass, but I'm slightly confused about one little thing.  I think it's a bug but I'm not confident enough to submit a bug report.  <br>

<br>Is there a reason why read-only calls are considered to "clobber" pointers in the non-load case (which is what gets returned due to the fall-through in the switch -- see below).  It seems this should be returning a "def" instead.  My thinking is the code should look like this (from line 288 on, +++ marks addition):<br style="font-family: courier new,monospace;">

<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">     // See if this instruction (e.g. a call or vaarg) mod/ref's the pointer.</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">     switch (AA->getModRefInfo(Inst, MemPtr, MemSize)) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">     case AliasAnalysis::NoModRef:</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">       // If the call has no effect on the queried pointer, just ignore it.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">       continue;</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">     case AliasAnalysis::Mod:</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">       // If we're in an invariant region, we can ignore calls that ONLY</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">       // modify the pointer.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">       if (InvariantTag) continue;</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">       return MemDepResult::getClobber(Inst);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">     case AliasAnalysis::Ref:</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">       // If the call is known to never store to the pointer, and if this is a</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">       // load query, we can safely ignore it (scan past it).</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">       if (isLoad)</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">         continue;</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">+++    return MemDepResult::getDef(Inst);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">     default:</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">       // Otherwise, there is a potential dependence.  Return a clobber.</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">       return MemDepResult::getClobber(Inst);</span><br style="font-family: courier new,monospace;">

<span style="font-family: courier new,monospace;">     }</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"></span><br>If this seems right to you too,  I've attached the patch.  If this isn't right, can someone please explain the logic?<br>

<br>Thanks,<br>Marc<br>