[PATCH] D30363: COFF ICF: Merge only functions. Do not merge read-only data.

David Majnemer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 27 14:06:42 PST 2017


majnemer added a comment.

In https://reviews.llvm.org/D30363#687794, @pcc wrote:

> In https://reviews.llvm.org/D30363#687719, @majnemer wrote:
>
> > MSVC won't merge read only data COMDATs? Microsoft's documentation has the following:
> >
> > > When /OPT:REF is enabled either explicitly or by default, a limited form of /OPT:ICF is enabled that only folds identical functions. If you want /OPT:REF but not /OPT:ICF, you must specify either /OPT:REF,NOICF or /OPT:NOICF.
> >
> >
> >
> > > The linker behaves differently when /OPT:REF is specified—and ICF is in effect by default—than it does when /OPT:REF,ICF is specified explicitly. The form of ICF that's enabled with /OPT:REF alone does not fold read-only data—this includes .rdata, .pdata, and .xdata. Therefore, fewer functions are folded when images are produced for x64 because functions in these modules are more dependent on read-only data—for example, .pdata and .xdata. To get full ICF folding behavior, explicitly specify /OPT:ICF.
> >
> > It sounds like Microsoft's default behavior is /OPT:REF. With that flag, they will fold identical functions. However, they provide access to full folding using /OPT:REF,ICF
> >
> > Perhaps we should provide the functionality via a similar flag?
>
>
> Maybe, but I'd slightly prefer to encode the information in the object files rather than introducing another flag.


It'd be nice if we can swap out clang with MSVC and still get the /OPT:ICF semantics (when desired). Making this feature available _only_ via the object file format would forbid that.


https://reviews.llvm.org/D30363





More information about the llvm-commits mailing list