[llvm] r195150 - DataLayout: value initialize globals to avoid static construction.

Sean Silva silvas at purdue.edu
Wed Nov 20 13:27:57 PST 2013


On Wed, Nov 20, 2013 at 1:34 PM, Chris Lattner <clattner at apple.com> wrote:

>
> On Nov 19, 2013, at 12:28 PM, Benjamin Kramer <benny.kra at googlemail.com>
> wrote:
>
> Author: d0k
> Date: Tue Nov 19 14:28:04 2013
> New Revision: 195150
>
> URL: http://llvm.org/viewvc/llvm-project?rev=195150&view=rev
> Log:
> DataLayout: value initialize globals to avoid static construction.
>
>
> Nice!  Random thought: how difficult would it be to get globalopt to
> "constant fold" these initializers?
>

It might also be an unlucky product of the current pass ordering. For
example, the globalopt failure in <
http://llvm.org/bugs/show_bug.cgi?id=16710> can be ameliorated by running
an extra `-globalopt -constprop` after the usual -O3 passes have been run.

-- Sean Silva


>
> -Chris
>
>
>
> Modified:
>    llvm/trunk/lib/IR/DataLayout.cpp
>
> Modified: llvm/trunk/lib/IR/DataLayout.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DataLayout.cpp?rev=195150&r1=195149&r2=195150&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/IR/DataLayout.cpp (original)
> +++ llvm/trunk/lib/IR/DataLayout.cpp Tue Nov 19 14:28:04 2013
> @@ -118,7 +118,7 @@ LayoutAlignElem::operator==(const Layout
> }
>
> const LayoutAlignElem
> -DataLayout::InvalidAlignmentElem = LayoutAlignElem::get(INVALID_ALIGN, 0,
> 0, 0);
> +DataLayout::InvalidAlignmentElem = { INVALID_ALIGN, 0, 0, 0 };
>
>
> //===----------------------------------------------------------------------===//
> // PointerAlignElem, PointerAlign support
> @@ -145,7 +145,7 @@ PointerAlignElem::operator==(const Point
> }
>
> const PointerAlignElem
> -DataLayout::InvalidPointerElem = PointerAlignElem::get(~0U, 0U, 0U, 0U);
> +DataLayout::InvalidPointerElem = { 0U, 0U, 0U, ~0U };
>
>
> //===----------------------------------------------------------------------===//
> //                       DataLayout Class Implementation
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131120/abab9f98/attachment.html>


More information about the llvm-commits mailing list