This is an archive of the discontinued LLVM Phabricator instance.

[Polly][ScopDetection] Only allow SCoP-wide available base pointers
ClosedPublic

Authored by Meinersbur on Mar 7 2017, 7:44 AM.

Details

Summary

Simplify ScopDetection::isInvariant. Essentially deny everything that is defined within the SCoP and is not load-hoisted.

The previous understanding of "invariant" has a few holes:

  • Expressions without side-effects with only invariant arguments, but are defined withing the SCoP's region with the exception of selects [sic!] and PHIs. These should be part of the index expression and not of the base pointer.
  • Function calls with !mayHaveSideEffects() (readnone nounwind). These must always return the same value and have no side-effect. However, we do not know which value it returns. For instance, a call
@C = external global i32
...
%ptr = call float* @getNextBasePtr(float* %A, float %B)

Might return

  • %A, so it aliases with it in the SCoP
  • %B, so it aliases with it in the SCoP
  • @C, so it aliases with it in the SCoP
  • a new pointer everytime it is called, such as malloc()
  • a pointer into the allocated block of one of the aforementioned
  • any of the above, at random

Hence we cannot know whether it aliases with something. It might still be useful with -polly-ignore-aliasing, if the user really wants unsafe code generation. Functions such as getNextBasePtr are usually inlined anyway (or not marked with readnone nounwind because they are defined in another translation unit).

On the other side it is a problem for the code generator if the base pointer is not available anywhere in the SCoP, when it needs to regenerate the access function (when setNewAccessRelation is called, such as in D28518, DeLICM and JSONImporter). The code generator currently assumes that base pointers are availably globally and generates invalid code (referring to the base pointer of the original code).

Diff Detail

Repository
rL LLVM

Event Timeline

Meinersbur created this revision.Mar 7 2017, 7:44 AM
Meinersbur updated this revision to Diff 90923.Mar 7 2017, 1:21 PM
  • Rebase to r297195
  • Update some comments
  • Add context
Meinersbur updated this revision to Diff 90924.Mar 7 2017, 1:28 PM
  • Undo unnecessary change in ReportVariantBasePtr-01.ll
Harbormaster completed remote builds in B4598: Diff 90924.
grosser accepted this revision.Mar 7 2017, 9:33 PM

LGTM. We can add these functions later on. Let's first get it correct.

This revision is now accepted and ready to land.Mar 7 2017, 9:33 PM
This revision was automatically updated to reflect the committed changes.