This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Simplify how GC works with MergeInputSection.
AbandonedPublic

Authored by grimar on Oct 17 2017, 4:23 AM.

Details

Reviewers
ruiu
rafael
Summary

This change do a cleanup of handling MergeInputSection when doing GC.
Previously additional checks leaked to MarkLive.cpp, patch eliminates this leaks.

Should be useful for D38724.

Diff Detail

Event Timeline

grimar created this revision.Oct 17 2017, 4:23 AM
grimar added inline comments.Oct 17 2017, 4:31 AM
ELF/InputSection.h
274

I wonder if shouldGCPieces would be better name.

ruiu added inline comments.Oct 18 2017, 12:09 PM
ELF/InputSection.h
275

Why don't you garbage-collect non-allocated strings?

grimar added inline comments.Oct 19 2017, 4:53 AM
ELF/InputSection.h
275

Honestly not sure I got the question right, because my patch does not change this logic and
we do that really long time (if not from begining).

Reason behind not-collecting non-allocated string sections I believe is following. Usually
such sections are debug ones. For example .debug_str section is non-allocatable and contains
strings(It has "MS" flags normally).

We can apply string merging optimization to such section, but we should not collect it.
.debug_info section has references to .debug_str via DW_FORM_strp, so it
has relocation that calculates an offset in .debug_str. .
.debug_info itself is also debug non-allocatable section
which should not be collected, otherwise we would lose all debug information.
And there is nothing else that can keep .debug_str alive as there are normally no references to .debug_str from
allocatable sections I think. Does this answer your question ?

grimar abandoned this revision.Oct 23 2017, 9:01 AM

Abandoning per D38724's comments.