This is an archive of the discontinued LLVM Phabricator instance.

Do not let Value::stripPointerCasts() look through returned arg functions.
AbandonedPublic

Authored by jroelofs on Jul 31 2023, 1:26 PM.

Details

Summary

We can allow this in alias analysis context, but it should be avoided for the general case where looking through would cause a semantic difference, i.e. in an objc_retain call (which will soon be marked thisreturn [1]). FWIW, the "bug" here was introduced in [2].

1: https://reviews.llvm.org/D105671
2: https://reviews.llvm.org/D9383

Diff Detail

Event Timeline

jroelofs created this revision.Jul 31 2023, 1:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 31 2023, 1:26 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
jroelofs requested review of this revision.Jul 31 2023, 1:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 31 2023, 1:26 PM
jroelofs edited the summary of this revision. (Show Details)Jul 31 2023, 1:28 PM
jroelofs added a reviewer: nikic.
nikic added a comment.Jul 31 2023, 2:00 PM

We can allow this in alias analysis context, but it should be avoided for the general case where looking through would cause a semantic difference, i.e. in an objc_retain call (which will soon be marked thisreturn [1]). FWIW, the "bug" here was introduced in [2].

returned is not supposed to have any semantic difference. In fact, we will replace calls with the returned attribute with the corresponding argument.

I think this change may still make sense because looking through returned in various analyses is pretty useless, because we can just wait for the call result to be replaced with the argument. But I don't think the current behavior should be a correctness issue.

jroelofs abandoned this revision.Aug 1 2023, 2:15 PM

Found a simpler way to work around the issue that motivated this in D105671.

I don't see much value in this patch now.