This is an archive of the discontinued LLVM Phabricator instance.

[LangRef] mention that the lifetime intrinsics' description in LangRef isn't everything
ClosedPublic

Authored by aqjune on Mar 6 2021, 1:54 AM.

Details

Summary

This is a minor patch that addresses concerns about lifetime in D94002.

We need to mention that what's written in LangRef isn't everything about lifetime.start/end
and its semantics depends on the stack coloring algorithm's pattern matching of a stack pointer.

If the stack coloring algorithm cannot conclude that a pointer is a stack-allocated object, the pointer is conservatively
considered as a non-stack one because stack coloring won't take this lifetime into account while assigning addresses.

A reference from alloca to lifetime.start/end is added as well.

Diff Detail

Event Timeline

aqjune created this revision.Mar 6 2021, 1:54 AM
aqjune requested review of this revision.Mar 6 2021, 1:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 6 2021, 1:54 AM
RalfJung added inline comments.Mar 6 2021, 2:43 AM
llvm/docs/LangRef.rst
18127

Would this alternatively be captured by saying that if ptr is a stack-allocated object, then it *might* have the effect of the original alloca creating a dead object and this intrinsic making it live (but non-deterministically, not doing this and just replacing the content by poison is also allowed)?

aqjune added inline comments.Mar 6 2021, 4:00 AM
llvm/docs/LangRef.rst
18127

It will help remove the mentioning of dependency on stack coloring's implementation, but due to practical reasons I think the current text is better.

It's because the current text reveals the problem of the status quo: alloca's lifetime depends on the stack coloring's implementation.
I think this mentioning will help people in the future raise questions about removal of this dependency, if lucky enough. Since this isn't a small problem, fully resolving this would require a dedicated team... I don't know.

Also, personally I prefer being simple here; nondeterminism is a hard concept and there's an opportunity that it can be interpreted differently by readers.

RalfJung added inline comments.Mar 6 2021, 4:31 AM
llvm/docs/LangRef.rst
18127

As you wish. But then I'd probably weaken the statement earlier in this text where it says that

If ``ptr`` is a stack-allocated object and it points to the first byte of
the object, the object is initially marked as dead.
After '``llvm.lifetime.start``', the stack object that ``ptr`` points is marked
as alive and has an uninitialized value.

Currently, this statement is first made only to be later partially revised; that seems confusing.

aqjune updated this revision to Diff 328843.Mar 6 2021, 11:37 PM

Forward-declare the dependency on the stack coloring algorithm

aqjune updated this revision to Diff 328844.Mar 6 2021, 11:39 PM

Reduce diff

aqjune added inline comments.Mar 6 2021, 11:40 PM
llvm/docs/LangRef.rst
18127

To minimize touching existing text, I moved it just after the sentence.

aqjune marked an inline comment as done.Mar 6 2021, 11:40 PM

LGTM, thanks. :)

This revision was not accepted when it landed; it landed in state Needs Review.Mar 8 2021, 6:34 PM
This revision was automatically updated to reflect the committed changes.