This is an archive of the discontinued LLVM Phabricator instance.

[Coroutines] Ignore partial lifetime markers refer of an alloca
ClosedPublic

Authored by ChuanqiXu on Oct 21 2021, 4:03 AM.

Details

Summary

When I playing with Coroutines, I found that it is possible to generate following IR:

%struct = alloca ...
%sub.element = getelementptr %struct, i64 0, i64 index ; index is not zero
lifetime.marker.start(%sub.element)
% use of %sub.element
lifetime.marker.end(%sub.element)
store %struct to xxx ;  %struct is escaping!

<suspend points>

Then the AllocaUseVisitor would collect the lifetime marker for sub.element and treat it as the lifetime markers of the alloca! So it judges that the alloca could be put on the stack instead of the frame by judging the lifetime markers only.
The root cause for the bug is that AllocaUseVisitor collects wrong lifetime markers.

This patch fixes this.

Test Plan: check-all

Diff Detail

Event Timeline

ChuanqiXu created this revision.Oct 21 2021, 4:03 AM
ChuanqiXu requested review of this revision.Oct 21 2021, 4:03 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 21 2021, 4:03 AM
lxfind accepted this revision.Oct 21 2021, 8:27 AM

Thank you for fixing this!

This revision is now accepted and ready to land.Oct 21 2021, 8:27 AM