[PATCH] D67013: [GVN] Verify value equality before doing phi translation for call instruction

Wei Mi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 30 10:43:40 PDT 2019


wmi created this revision.
wmi added reviewers: asbirlea, resistor.
Herald added a project: LLVM.
wmi updated this revision to Diff 218134.
wmi added a comment.

Add the missing testcase.


This is an updated version of https://reviews.llvm.org/D66909 to fix PR42605.

Basically, current phi translatation translates an old value number to an new value number for a call instruction based on the literal equality of call expression, without verifying there is no clobber in between. This is incorrect.

To get a finegrain check, use MachineDependence analysis to do the job. However, this is still not ideal. Although given a call instruction, `MemoryDependenceResults::getCallDependencyFrom` returns identical call instructions without clobber in between using MemDepResult with its DepType to be `Def`. However, identical is too strict here and we want it to be relaxed a little to consider phi-translation -- callee is the same, param operands can be different. That means changing the semantic of `MemDepResult::Def` and I don't know the potential impact.

So currently the patch is still conservative to only handle MemDepResult::NonFuncLocal, which means the current call has no function local clobber. If there is clobber, even if the clobber doesn't stand in between the current call and the call with the new value, we won't do phi-translate.


Repository:
  rL LLVM

https://reviews.llvm.org/D67013

Files:
  include/llvm/Transforms/Scalar/GVN.h
  lib/Transforms/Scalar/GVN.cpp
  test/Transforms/GVN/pr42605.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67013.218134.patch
Type: text/x-patch
Size: 6428 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190830/c52a555b/attachment.bin>


More information about the llvm-commits mailing list