[PATCH] D14699: [GlobalOpt] Allow constant globals to be SRA'd
Daniel Berlin via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 16 08:08:41 PST 2015
On Mon, Nov 16, 2015 at 8:01 AM, Mehdi AMINI via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> joker.eph added inline comments.
>
> ================
> Comment at: test/Transforms/GlobalOpt/globalsra.ll:31
> @@ +30,3 @@
> +define void @onlystore2() {
> + store i32 123, i32* getelementptr ({ i32, float, { double } }, {
> i32, float, { double } }* @G2, i32 0, i32 0)
> + ret void
> ----------------
> It is strange that we can store to a constant?
>
>
It's strange in the sense that it probably doesn't do anything sensible,
and is likely not well defined behavior ;-)
But you can't really disallow it in the IR, because if you didn't, you'd
have to do things like make sure optimizations never propagated constants
to certain uses.
IE you couldn't write:
Discover X is constant
for each use of X
replace use with constant
you'd have to write
Discover X is constant
for each use of X
if user of use is not a store
replace use with constant
This is more expensive, and doesn't make the behavior more well defined.
It's still storing to the same place (or else you wouldn't have been able
to prove it constant!)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151116/c95ab94f/attachment.html>
More information about the llvm-commits
mailing list