[BRIGFE] Enable whole program optimizations

Programming / Compilers / GCC - visit0r [138bc75d-0d04-0410-961f-82ee72b054a4] - 4 May 2018 16:44 EDT

HSA assumes all program scope HSAIL symbols can be queried from the host runtime API, thus cannot be removed by the IPA.

Getting some inlining happening in the finalized binary required:
- explicitly marking the 'prog' scope functions and the launcher function "externally_visible" to avoid the inliner removing it
- also the host_def ptr is set to externally visible, otherwise IPA assumes it's never set
- adding the 'inline' keyword to functions to enable inlining, otherwise GCC defaults to replaceable functions (one can link over the previous one) which cannot be inlined
- replacing all calls to declarations with calls to definitions to enable the inliner to find the definition
- to fix missing hidden argument types in the generated functions. These were ignored silently until GCC started to be able to inline calls to such functions.
- do not gimplify before fixing the call targets. Otherwise the calls get detached and the definitions are not found. The reason why this happens is not clear, but gimplifying only after call target decl->def conversion fixes this.

ed760c9e77f [BRIGFE] Enable whole program optimizations
gcc/brig/ChangeLog | 11 +++
gcc/brig/brig-lang.c | 4 +-
gcc/brig/brigfrontend/brig-branch-inst-handler.cc | 2 +
gcc/brig/brigfrontend/brig-function-handler.cc | 30 ++++++---
gcc/brig/brigfrontend/brig-function.cc | 4 +-
gcc/brig/brigfrontend/brig-to-generic.cc | 82 ++++++++++++++++++++++-
gcc/brig/brigfrontend/brig-to-generic.h | 8 +++
gcc/brig/brigfrontend/brig-variable-handler.cc | 3 +
8 files changed, 130 insertions(+), 14 deletions(-)

Upstream: gcc.gnu.org


  • Share