This is an archive of the discontinued LLVM Phabricator instance.

Fix store detection for return value in CGCall
ClosedPublic

Authored by kuhar on Aug 27 2015, 2:09 AM.

Details

Summary

findDominatingStoreToReturn in CGCall.cpp didn't check if a candidate store instruction used the ReturnValue as pointer operand or value operand. This led to wrong code gen - in later stages (load-store elision code) the found store and its operand would be erased, causing ReturnValue to become a <badref>.

The patch adds a check that makes sure that ReturnValue is a pointer operand of store instruction. Regression test is also added.

This fixes PR24386.

Diff Detail

Repository
rL LLVM

Event Timeline

kuhar updated this revision to Diff 33304.Aug 27 2015, 2:09 AM
kuhar retitled this revision from to Fix store detection for return value in CGCall.
kuhar updated this object.
kuhar set the repository for this revision to rL LLVM.
kuhar added a subscriber: cfe-commits.
aadg added a subscriber: aadg.Sep 2 2015, 5:38 AM

Just a minor nitpick (see below)

lib/CodeGen/CGCall.cpp
2332 ↗(On Diff #33304)

It might be worth stating in a comment why this is needed --- for the benefit of people who will read this code later.

aadg added a comment.Sep 2 2015, 6:06 AM

Yet another comment (see below).

lib/CodeGen/CGCall.cpp
2332 ↗(On Diff #33304)

I also note that those lines are looking very much like those in the if above (handling the multiple use of the return value case)... This issue was fixed above, but not here. Would it be possible to avoid code duplication ?

kuhar updated this revision to Diff 33919.Sep 3 2015, 2:50 AM

Some refactoring + comments added.

kuhar marked 2 inline comments as done.Sep 3 2015, 2:51 AM
kuhar updated this revision to Diff 33921.Sep 3 2015, 2:53 AM
aadg accepted this revision.Sep 7 2015, 3:09 AM
aadg added a reviewer: aadg.

This looks ok to me.

This revision is now accepted and ready to land.Sep 7 2015, 3:09 AM
kuhar updated this revision to Diff 34206.Sep 8 2015, 3:34 AM
kuhar edited edge metadata.

Merge with the latest changes to CGCall.cpp

This revision was automatically updated to reflect the committed changes.