OSDN Git Service

[Inliner] Fix a nasty bug when inlining a non-recursive trace of
authorChandler Carruth <chandlerc@gmail.com>
Sat, 19 Aug 2017 06:56:11 +0000 (06:56 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Sat, 19 Aug 2017 06:56:11 +0000 (06:56 +0000)
commitc3557e20c34b4156efe83dda92c13203bde91a27
tree08eea8463372c4fc2b6842fc847b6344f3e3e286
parentff12911639ac671cd59889af2d12367bcff7cb78
[Inliner] Fix a nasty bug when inlining a non-recursive trace of
a function into itself.

We tried to fix this before in r306495 but that got reverted as the
assert was actually hit.

This fixes the original bug (which we seem to have lost track of with
the revert) by blocking a second remapping when the function being
inlined is also the caller and the remapping could succeed but
erroneously.

The included test case would actually load from an inlined copy of the
alloca before this change, failing to load the stored value and
miscompiling.

Many thanks to Richard Smith for diagnosing a user miscompile to this
bug, and to Kyle for the first attempt and initial analysis and David Li
for remembering the issue and how to fix it and suggesting the patch.
I'm just stitching it together and landing it. =]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311229 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Utils/CloneFunction.cpp
test/Transforms/Inline/recursive.ll