This is an archive of the discontinued LLVM Phabricator instance.

[Proof of concept] Read, write and use 'writeonce' annotations.
Needs ReviewPublic

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

Details

Summary

[No formal review is needed at this time]

Diff Detail

Event Timeline

lvoufo updated this revision to Diff 31497.Aug 6 2015, 5:35 PM
lvoufo retitled this revision from to [Proof of concept] Read, write and use 'writeonce' annotations..
lvoufo updated this object.
lvoufo added reviewers: chandlerc, majnemer, nlewycky.
lvoufo updated this object.
lvoufo updated this object.
lvoufo updated this object.
lvoufo updated this revision to Diff 31566.Aug 7 2015, 6:20 PM

Fix "ghost" writeonce annotations problems.
So we are no longer generating them in the middle of optimizations.
However, writeonce behavior seems to still be inserted...

lvoufo updated this revision to Diff 32332.Aug 17 2015, 12:42 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 markings are done as part of the -functionattrs pass for now.

lvoufo updated this revision to Diff 32351.Aug 17 2015, 4:10 PM

remove assertion checking if we are ever utilizing argument-based onlyReadsMemory() on CallSite's.

lvoufo updated this revision to Diff 32828.Aug 21 2015, 8:34 AM

Do not mark call arguments of non-pointer types readonly.
The associated call site may still be marked 'readonly'.

NOTE: Marking the CallSite readonly is a temporary functionality, as it is not entirely correct but helps the proof of concept.
lvoufo updated this revision to Diff 32855.Aug 21 2015, 1:01 PM

Bug Fix: 'writeonce' global variable is truly not 'readonly' until it's written to.

lvoufo updated this revision to Diff 34050.Sep 4 2015, 11:26 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 34182.Sep 7 2015, 8:28 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 35065.Sep 17 2015, 10:19 PM
lvoufo updated this object.

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

Moving towards initial patch submission for review:

  • Fix unexpected failures in regression tests: 6
  • Increase MaxInstsToScan value to appropriate value (8?): cf. D12886
  • generalize and add new test cases.