[PATCH] D22295: Introduce GlobalSplit pass.

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 26 21:10:35 PDT 2016


eli.friedman added a comment.

I'll try to outline a scenario where this misbehaves...

Suppose you have an unnamed_addr global, call it "const int a[2][5]", and a loop which sums up all the elements of a[0].  You can express the sum something like this: `int* p = a[0]; while (p != a[1]) { sum += *p; ++p; }`.  Both a[0] and a[1] can be marked inrange: a[0] because all the loads are in range, a[1] because there aren't any memory operations over it.  The loop explodes for obvious reasons if you split a[1] into a separate global.

The obvious way to make this illegal is to make marking a[1] inrange illegal (the "comparisons are undefined" rule).  There isn't any marking you can put on the global which will help because the optimizer can insert the pointer comparison without knowing a global is even involved.


https://reviews.llvm.org/D22295





More information about the llvm-commits mailing list