[PATCH] D36712: Emit section information for extern variables

Krzysztof Parzyszek via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 15 13:00:49 PDT 2017

kparzysz added a comment.

In https://reviews.llvm.org/D36712#842433, @efriedma wrote:

> I can't see how "undefined behavior" could possibly be the right answer in that case.  Every definition has to end up in some section eventually, and in many cases we don't know what section that will be when a global is declared.  (For example, we put constants into different sections depending on the contents of the initializer.)

These constants don't have explicit section information in the IR.  The typical scenario is that neither the declarations of a global, nor its definition have that.  In the cases when the section is explicitly given on a definition, it was likely imposed by something like the "section" attribute in the source.  I don't think it's unreasonable to expect that the declarations (in the original source as well as in the generated IR) should carry that information as well.  However, since clang has apparently been ignoring that attribute on declarations, it's been generating IR where declarations may not have sections, but the corresponding definitions do.


More information about the cfe-commits mailing list