This is an archive of the discontinued LLVM Phabricator instance.

[SimplifyLibCalls] Teach the Fortified libcall simplifier to look through objectsize.
AbandonedPublic

Authored by ab on Oct 24 2014, 2:52 PM.

Details

Reviewers
hfinkel
Summary

It used to only try to fold fortified (_chk) libcalls with a constant objectsize.
However, in most cases, the @llvm.objectsize intrinsic is used. Teach the
LibCallSimplifier to ask for the objectsize to handle the latter case.

Three-ish (one, really) new optimizations opportunities were created in the tests.

Diff Detail

Event Timeline

ab updated this revision to Diff 15439.Oct 24 2014, 2:52 PM
ab retitled this revision from to [SimplifyLibCalls] Teach the Fortified libcall simplifier to look through objectsize..
ab updated this object.
ab edited the test plan for this revision. (Show Details)
ab added a reviewer: hfinkel.
ab added a subscriber: Unknown Object (MLST).
ab added a comment.Oct 24 2014, 4:34 PM

Note that this + D498 seem to have caused two major differences in
the testsuite, lowercase and sqlite3.

The execution time for SingleSource/Benchmarks/Misc/lowercase went
down by 99.98% (!), because the actual lowercasing logic was optimized
out, leaving only the iteration printfs. At first glance, the change
seems correct; I'll look into it in more detail.

MultiSource/Applications/sqlite3 has seen its compile time grow by
~25% to 20s. Interestingly, a ~1.5% execution slowdown is also
incurred (seems unrelated to D498, only caused by moving stuff around
because of the _chk -> intrinsic optimizations enabled by this patch).

getObjectSize, which is used in the objectsize patch, is somewhat
expensive. But profiling shows that there are two slowdown sources: a
little more everywhere, and MemDepAnalysis::getNonLocalPointerDependency.
Both seem to be caused by the transformation of most _chk calls to
intrinsics (enabled by the objectsize patch).

At this point I'm not sure whether it's currently worth it to do this
_chk+llvm.objectsize -> intrinsic lowering, earlier than CGP.
If not I think the D498 optimization would be pretty useless on
fortified targets (like the rest of memcpyopt, one might add.)

I'll try to isolate the impact of this specific patch. Meanwhile, feedback
would be much appreciated!

ab planned changes to this revision.Nov 12 2014, 3:35 PM
ab abandoned this revision.Jan 22 2015, 9:14 AM