[PATCH] D76886: [InlineFunction] Disable emission of alignment assumptions by default

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 26 13:36:13 PDT 2020


nikic created this revision.
nikic added reviewers: efriedma, hfinkel, jdoerfert.
Herald added subscribers: llvm-commits, JDevlieghere.
Herald added a project: LLVM.

In D74183 <https://reviews.llvm.org/D74183> clang started emitting alignment for `sret` parameters unconditionally. This caused a 1.5% compile-time regression on tramp3d-v4. The reason is that we now generate many instance of IR like

  %ptrint = ptrtoint %class.GuardLayers* %guards_m to i64
  %maskedptr = and i64 %ptrint, 3
  %maskcond = icmp eq i64 %maskedptr, 0
  tail call void @llvm.assume(i1 %maskcond)

to preserve the alignment information during inlining. Based on the size increase of the final binary, it is likely that these assumptions not only increase compile-time, but also regress optimizations (due to the usual issues with assumes).

We already encountered the same problem in Rust, where we (unlike Clang) generally prefer to emit alignment information absolutely everywhere it is available. We were only able to do this after hardcoding `-preserve-alignment-assumptions-during-inlining=false`, because we were seeing significant optimization and compile-time regressions otherwise.

This patch disables `-preserve-alignment-assumptions-during-inlining` by default, because we should not be punishing people for adding more alignment annotations.

I think once the operand bundle work by @Tyker and @jdoerfert shakes out, it might be possible to use an operand bundle based assume for this instead and avoid some/most of the overhead.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76886

Files:
  lib/Transforms/Utils/InlineFunction.cpp


Index: lib/Transforms/Utils/InlineFunction.cpp
===================================================================
--- lib/Transforms/Utils/InlineFunction.cpp
+++ lib/Transforms/Utils/InlineFunction.cpp
@@ -80,9 +80,12 @@
   cl::Hidden,
   cl::desc("Convert noalias attributes to metadata during inlining."));
 
+// Disabled by default, because the added alignment assumptions may increase
+// compile-time and block optimizations. This option is not suitable for use
+// with frontends that emit comprehensive parameter alignment annotations.
 static cl::opt<bool>
 PreserveAlignmentAssumptions("preserve-alignment-assumptions-during-inlining",
-  cl::init(true), cl::Hidden,
+  cl::init(false), cl::Hidden,
   cl::desc("Convert align attributes to assumptions during inlining."));
 
 llvm::InlineResult llvm::InlineFunction(CallBase *CB, InlineFunctionInfo &IFI,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76886.252963.patch
Type: text/x-patch
Size: 865 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200326/bbd4e540/attachment.bin>


More information about the llvm-commits mailing list