[PATCH] D28053: Cleanup the handling of noinline function attributes, -fno-inline, -fno-inline-functions, -O0, and optnone.

Chandler Carruth via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 22 04:56:27 PST 2016


chandlerc created this revision.
chandlerc added reviewers: rsmith, rnk, mehdi_amini.
chandlerc added a subscriber: cfe-commits.
chandlerc added a dependency: D28047: Remove the '-disable-llvm-passes' flag (which I didn't even know existed, and I suspect many others aren't aware of either) and strength '-disable-llvm-optzns' to do the same thing..
Herald added subscribers: nhaehnle, nemanjai, mcrosier, jholewinski.
Herald added a reviewer: tstellarAMD.

These were really, really tangled together:

- We used the noinline LLVM attribute for -fno-inline
  - But not for -fno-inline-functions (breaking LTO)
  - But we did use it for -finline-hint-functions (yay, LTO is happy!)
  - But we didn't for -O0 (LTO is sad yet again...)
- We had weird structuring of CodeGenOpts with both an inlining enumeration and a boolean. They interacted in weird ways and needlessly.
- A *lot* of set smashing went on with setting these, and then got worse when we considered optnone and other inlining-effecting attributes.
- A bunch of inline affecting attributes were managed in a completely different place from -fno-inline.
- Even with -fno-inline we failed to put the LLVM noinline attribute onto many generated function definitions because they didn't show up as AST-level functions.
- If you passed -O0 but -finline-functions we would run the normal inliner pass in LLVM despite it being in the O0 pipeline, which really doesn't make much sense.

Sadly, this causes a bunch of churn in tests because we don't run the
optimizer in the tests and check the contents of attribute sets. It
would be awesome if attribute sets were a bit more FileCheck friendly,
but oh well.

I think this is a significant improvement and should remove the semantic
need to change what inliner pass we run in order to comply with the
requested inlining semantics by relying completely on attributes. It
also cleans up tho optnone and related handling a bit.

One unfortunate aspect of this is that for generating alwaysinline
routines like those in OpenMP we end up removing noinline and then
adding alwaysinline. I tried a bunch of other approaches, but because we
recompute function attributes from scratch and don't have a declaration
here I couldn't find anything substantially cleaner than this.

Depends on https://reviews.llvm.org/D28047


https://reviews.llvm.org/D28053

Files:
  include/clang/Frontend/CodeGenOptions.def
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/BackendUtil.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CXX/special/class.dtor/p3-0x.cpp
  test/CodeGen/2008-04-08-NoExceptions.c
  test/CodeGen/address-safety-attr-kasan.cpp
  test/CodeGen/address-safety-attr.cpp
  test/CodeGen/address-space-field1.c
  test/CodeGen/alias.c
  test/CodeGen/attr-minsize.cpp
  test/CodeGen/attributes.c
  test/CodeGen/incomplete-function-type-2.c
  test/CodeGen/inline-optim.c
  test/CodeGen/mips16-attr.c
  test/CodeGen/mrtd.c
  test/CodeGen/ms-declspecs.c
  test/CodeGen/ppc64-complex-parms.c
  test/CodeGen/ppc64-complex-return.c
  test/CodeGen/ppc64-extend.c
  test/CodeGen/sanitize-thread-attr.cpp
  test/CodeGen/sanitize-thread-no-checking-at-run-time.m
  test/CodeGen/unwind-attr.c
  test/CodeGenCXX/attr.cpp
  test/CodeGenCXX/cxx11-exception-spec.cpp
  test/CodeGenCXX/cxx11-noreturn.cpp
  test/CodeGenCXX/derived-to-base.cpp
  test/CodeGenCXX/global-dtor-no-atexit.cpp
  test/CodeGenCXX/global-init.cpp
  test/CodeGenCXX/inline-hint.cpp
  test/CodeGenCXX/main-norecurse.cpp
  test/CodeGenCXX/microsoft-abi-array-cookies.cpp
  test/CodeGenCXX/no-exceptions.cpp
  test/CodeGenCXX/optnone-class-members.cpp
  test/CodeGenCXX/optnone-def-decl.cpp
  test/CodeGenCXX/reference-cast.cpp
  test/CodeGenCXX/threadsafe-statics.cpp
  test/CodeGenCXX/thunks.cpp
  test/CodeGenCXX/virtual-base-cast.cpp
  test/CodeGenObjC/gnu-exceptions.m
  test/CodeGenObjC/objc-literal-tests.m
  test/CodeGenObjCXX/lambda-expressions.mm
  test/CodeGenOpenCL/amdgpu-attrs.cl
  test/Driver/darwin-iphone-defaults.m
  test/PCH/objc_container.m

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28053.82329.patch
Type: text/x-patch
Size: 40607 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161222/2aa1ef88/attachment-0001.bin>


More information about the cfe-commits mailing list