From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22227 invoked by alias); 16 Jan 2014 18:02:32 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 22170 invoked by uid 48); 16 Jan 2014 18:02:29 -0000 From: "hubicka at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/46507] std::get and devirtualization on non-automatic variables Date: Thu, 16 Jan 2014 18:02:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 4.6.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: hubicka at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: hubicka at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-01/txt/msg01735.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46507 --- Comment #10 from Jan Hubicka --- I agree we want to do as much as possible in FE. ODR decisions are basically done in frontend now - we basically use mangling of virtual tables given to us by C++ FE. Eventually we will want to get ODR information on all types, not only polymorphic ones. Then I plan to go with Jason's suggested way of calling decl_assembler name on types to get mangling from C++ FE rather than my initial attempt to actually compare types for equivalence by their high level names that hits interesting issues with templates. It is left in code mostly as backup if the other solution blows up our memory footprint. I do not think we can do type inheritance analysis + devirtualization purely by frotnend, since it is naturally an inter-procuedural problem that needs to be handled by LTO. We already have sane way to represent the type inheritance tree by binfos. What we need to work on is a sane and safe way representing the relevant type information that is given to you by C++ standard but thrown away on way to GIMPLE so the propagation can work. I was thinking of type assert expressions that can be inserted by FE on places where dynamic type is known for non-trivial reasons. Those can be used as starting points for the propagation of type information and removed after IPA. This would allow us to preserve information while inlining and also make it easier to deal with dynamic type changes. For simple operations, like in this testcase, this approach may be however impractical producing too many new gimple statements. I am slowly getting to stage where current devirt infrastructure seems to work as expected and seems to use most of information already there in gimple that seems to be safe to assume. My plan was to basically wait for this release cycle, see how many bugs shows up so I am sure I do not miss something obvious (well, like the virtual inheritance fun). I think only parts we miss now is to - move ipa-cp to new infrastructure - move dynamic type change code to ipa-devirt and make it work with contextes - understand ctors/dtors calls, since we already ave flag marking them specially. I also collected testcases we need to handle. I will try to sit down and prepare some proposal about what we need to preserve in gimple. I think we also want central place (probably in ipa-devirt toplevel comment) documenting all the information we take into account and assumptions we make. So far they are mostly trivial (i.e. static vars/automatic vars/values passed by invisible references are known to have their type and not derived type) except for Martin's dynamic changing code.