This is an archive of the discontinued LLVM Phabricator instance.

StackLifetime: Remove asserts for multiple lifetime intrinsics.
ClosedPublic

Authored by pcc on Aug 18 2021, 3:14 PM.

Details

Summary

According to the langref, it is valid to have multiple consecutive
lifetime start or end intrinsics on the same object.

For llvm.lifetime.start:
"If ptr [...] is a stack object that is already alive, it simply
fills all bytes of the object with poison."

For llvm.lifetime.end:
"Calling llvm.lifetime.end on an already dead alloca is no-op."

However, we currently fail an assertion in such cases. I've observed
the assertion failure when the loop vectorization pass duplicates
the intrinsic.

We can conservatively handle these intrinsics by ignoring all but
the first one, which can be implemented by removing the assertions.

Diff Detail

Event Timeline

pcc created this revision.Aug 18 2021, 3:14 PM
pcc requested review of this revision.Aug 18 2021, 3:14 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 18 2021, 3:14 PM

Please update test/Analysis/StackSafetyAnalysis/lifetime.ll instead, and it would be good to extend it with testcases for liveness between two start and two end calls.

pcc updated this revision to Diff 367375.Aug 18 2021, 5:50 PM

Test this in test/Analysis/StackSafetyAnalysis/lifetime.ll instead

eugenis accepted this revision.Aug 18 2021, 6:00 PM

LGTM

This revision is now accepted and ready to land.Aug 18 2021, 6:00 PM