[No formal review is needed at this time]
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...
- 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.
remove assertion checking if we are ever utilizing argument-based onlyReadsMemory() on CallSite's.
Do not mark call arguments of non-pointer types readonly.
The associated call site may still be marked 'readonly'.
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.
Remove explicit 'writeonce' annotations; not worth the overhead of keeping them around (e.g. propagation through new AllocaInst's).
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.