Add alloca size threshold for StackTagging initializer merging.
authorEvgenii Stepanov <eugenis@google.com>
Thu, 15 Oct 2020 23:10:42 +0000 (16:10 -0700)
committerEvgenii Stepanov <eugenis@google.com>
Mon, 19 Oct 2020 20:44:07 +0000 (13:44 -0700)
commit188a7d671019247932b7242c7794960ca1986b5a
tree1f0099f5c663067cebc32ebd15d79aaf6d6db661
parentc76968d8b60e5ac75d3630eeff685a44d8450f74
Add alloca size threshold for StackTagging initializer merging.

Summary:
Initializer merging generates pretty inefficient code for large allocas
that also happens to trigger an exponential algorithm somewhere in
Machine Instruction Scheduler. See https://bugs.llvm.org/show_bug.cgi?id=47867.

This change adds an upper limit for the alloca size. The default limit
is selected such that worst case size of memtag-generated code is
similar to non-memtag (but because of the ISA quirks, this case is
realized at the different value of alloca size, ex. memset inlining
triggers at sizes below 512, but stack tagging instructions are 2x
shorter, so limit is approx. 256).

We could try harder to emit more compact code with initializer merging,
but that would only affect large, sparsely initialized allocas, and
those are doing fine already.

Reviewers: vitalybuka, pcc

Subscribers: llvm-commits
llvm/lib/Target/AArch64/AArch64StackTagging.cpp
llvm/test/CodeGen/AArch64/stack-tagging-initializer-merge.ll