This is an archive of the discontinued LLVM Phabricator instance.

[Extension] Optimizing const member objects.
Needs ReviewPublic

Authored by lvoufo on Oct 9 2015, 7:45 PM.

Details

Summary

Continued from D13603...

When generating invariant_start intrinsic calls for any given (instantiated) object, instead of simply recording information about whether the object is 'const', record the offsets of sub-fields of the objects that are 'const'. This turns the definition of the invariant_start instruction into a variadic function of at least two arguments, where the first two arguments are information about the allocated memory.

If the invariant_start call instruction only has two arguments, then the object is 'writeonce'. Otherwise, it is not 'writeonce' but has 'writeonce' sub-fields at the indicated offsets.

Diff Detail

Event Timeline

lvoufo updated this revision to Diff 37020.Oct 9 2015, 7:45 PM
lvoufo retitled this revision from to [Extension] Optimizing const member objects..
lvoufo updated this object.
lvoufo added a subscriber: cfe-commits.
lvoufo updated this revision to Diff 37023.Oct 9 2015, 8:04 PM
lvoufo updated this revision to Diff 37024.Oct 9 2015, 8:06 PM
lvoufo updated this object.Oct 23 2015, 3:23 PM
lvoufo updated this revision to Diff 39411.Nov 5 2015, 1:51 PM
lvoufo removed a reviewer: majnemer.

Remove commented out line -- Offsets not needed on invariant_end calls after all.

lvoufo updated this revision to Diff 39458.Nov 5 2015, 6:30 PM
lvoufo added a reviewer: majnemer.

Reify computed invariant offsets, and while we're at it, cleanup InvariantArgs: move it out of CodeGenModule.h and remove Offsets member field since offsets are already in the start instructions.

lvoufo updated this revision to Diff 39463.Nov 5 2015, 7:10 PM
lvoufo updated this revision to Diff 39464.Nov 5 2015, 7:12 PM
lvoufo updated this revision to Diff 39465.
lvoufo updated this revision to Diff 39466.Nov 5 2015, 7:24 PM
lvoufo updated this revision to Diff 39467.Nov 5 2015, 7:28 PM
rsmith added a subscriber: rsmith.Dec 2 2015, 5:18 PM
rsmith added inline comments.
lib/CodeGen/CGDecl.cpp
933

Instead of tracking a separate Computed flag, use InvariantOffsets.count(Record) here, and insert the value below.

943–959

It'd be good to also handle the case of a const field of class type that contains a mutable member -- in that case, all members other than the mutable member can be marked as invariant.

956–957

The recursive call to ComputeInvariatOffsets here invalidates your Args reference (DenseMap insertions invalidate all iterators and references to map elements).