This is an archive of the discontinued LLVM Phabricator instance.

[Proof of concept] Clang lowering: Add 'writeonce' annotations on constant objects.
Needs ReviewPublic

Authored by lvoufo on Aug 6 2015, 5:15 PM.

Details

Summary

[No formal review needed at this time.]

Diff Detail

Event Timeline

lvoufo updated this revision to Diff 31495.Aug 6 2015, 5:15 PM
lvoufo retitled this revision from to [Proof of concepts] Clang lowering: Add 'writeonce' annotations on constant objects..
lvoufo updated this object.
lvoufo added reviewers: chandlerc, majnemer, nlewycky.
lvoufo retitled this revision from [Proof of concepts] Clang lowering: Add 'writeonce' annotations on constant objects. to [Proof of concept] Clang lowering: Add 'writeonce' annotations on constant objects..
lvoufo updated this revision to Diff 31565.Aug 7 2015, 6:13 PM

Generalized generation of 'writeonce' annotations.

lvoufo updated this revision to Diff 32331.Aug 17 2015, 12:41 PM

Bug Fix:

  • the inliner and -gvn were removing or ignoring calls to constructors that were prematurely treated as readonly when their arguments were writeonce.
  • As result, calls like call void @_Z3bar1A(i32 %agg.tmp.sroa.0.0.copyload) were eventually replaced with call void @_Z3bar1A(i32 undef).
  • This is not the case anymore.

This patch uses the @llvm.invariant.start/end intrinsics to either

  • mark that writeonce memory locations have been written into and thus can now be treated as readonly, or
  • mark that it's okay to write into a writeonce memory location again.

The intrinsics are generated immediately after writing into a given address location, and, when applicable, at the end of a variable's lifetime.

lvoufo updated this revision to Diff 32334.Aug 17 2015, 12:59 PM

Remove duplicate generation of invariant.start intrisic call for writeonce addresses.

lvoufo edited reviewers, added: dberlin; removed: nlewycky.Aug 21 2015, 12:54 PM
lvoufo updated this revision to Diff 34052.Sep 4 2015, 11:28 AM

Bug Fix: Global const object cases work again.

Solution: Teach BasicAA to not treat @llvm.invariant.start/end() intrinsic calls as potentially writing to memory.

lvoufo updated this revision to Diff 34185.Sep 7 2015, 8:33 PM

Remove explicit 'writeonce' annotations; not worth the overhead of keeping them around (e.g. propagation through new AllocaInst's).

lvoufo updated this revision to Diff 35061.Sep 17 2015, 10:08 PM

POC done (based on the sample programs in the design doc).

Moving towards initial patch submission for review:

  • Fix unexpected failures in regression tests: 8
  • generalize and add new test cases.
chandlerc edited edge metadata.Sep 17 2015, 10:24 PM

FYI, if this is something you'd like to start more active code review on, I
would recommend closing this particular entry on Phabricator and creating a
new one with llvm-commits subscribed from the start. Adding a mailing list
doesn't work well with Phabricator sadly. =/ It will also give a good
chance to update the description because I know you've made a lot of
progress based on the design review, etc.

lvoufo updated this revision to Diff 35296.EditedSep 21 2015, 12:51 PM
lvoufo edited edge metadata.

Update diff with more visible context (-U999999).

[ * This was submitted in error -- Please ignore this diff *]