This is an archive of the discontinued LLVM Phabricator instance.

Load elimination based on new 'InvarantInfo' property for global variables.
Needs ReviewPublic

Authored by lvoufo on Oct 22 2015, 9:25 PM.

Details

Summary

Extend D14003, D14004, D14005 and D14006 with handling of global variables:
GlobalOpt scans static constructors to mark allocated 'writeonce' memory prior to evaluating the constructors.

This patch also includes new test cases, which are essentially adapted from the test case in D14006 for "fully global" and "partially global" test cases.

This patch is a break-down of (corrected) D13606.

Diff Detail

Event Timeline

lvoufo updated this revision to Diff 38206.Oct 22 2015, 9:25 PM
lvoufo retitled this revision from to Load elimination based on new 'InvarantInfo' property for global variables..
lvoufo updated this object.
lvoufo added reviewers: dberlin, reames, nlewycky.
lvoufo added a subscriber: llvm-commits.
nlewycky edited edge metadata.Nov 8 2015, 4:06 PM

I've been thinking about this patch and I don't understand what change you're trying to make at a high level.

Here's a hypothesis about how to support invariant intrinsics in globalopt: ignore them entirely. GlobalOpt evaluates each instruction in turn, following from caller into the body of a callee. If it can't see any instruction at any time, it aborts the whole chain of evaluation. The point of 'invariant' intrinsics is to mark that an *opaque* callee will not mutate memory, but globalopt never takes any action when given an opaque callee. Therefore, there is nothing to support here, we just need to silently ignore the invariant intrinsics. Does that sound right?

lib/Transforms/IPO/GlobalOpt.cpp
2704–2705

CallSite CS(CurInst);
if (!CS) continue;

reames resigned from this revision.Apr 18 2016, 4:56 PM
reames removed a reviewer: reames.