diff options
author | Stephen Tozer <stephen.tozer@sony.com> | 2024-10-04 13:13:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-04 13:13:30 +0100 |
commit | d826b0c90f0b0ebebd2b7ed37bf6ff71b34360c8 (patch) | |
tree | fa24aa06476e838c067d8862f60b1f2c0746dac4 /llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp | |
parent | 6294679faa8ae57873b7fcdc00a4deb522d31c38 (diff) | |
download | llvm-d826b0c90f0b0ebebd2b7ed37bf6ff71b34360c8.zip llvm-d826b0c90f0b0ebebd2b7ed37bf6ff71b34360c8.tar.gz llvm-d826b0c90f0b0ebebd2b7ed37bf6ff71b34360c8.tar.bz2 |
[LLVM] Add HasFakeUses to MachineFunction (#110097)
Following the addition of the llvm.fake.use intrinsic and corresponding
MIR instruction, two further changes are planned: to add an
-fextend-lifetimes flag to Clang that emits these intrinsics, and to
have -Og enable this flag by default. Currently, some logic for handling
fake uses is gated by the optdebug attribute, which is intended to be
switched on by -fextend-lifetimes (and by extension -Og later on).
However, the decision was made that a general optdebug attribute should
be incompatible with other opt_ attributes (e.g. optsize, optnone),
since they all express different intents for how to optimize the
program. We would still like to allow -fextend-lifetimes with optsize
however (i.e. -Os -fextend-lifetimes should be legal), since it may be a
useful configuration and there is no technical reason to not allow it.
This patch resolves this by tracking MachineFunctions that have fake
uses, allowing us to run passes that interact with them and skip passes
that clash with them.
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp index 8405ba9..6a6bc19 100644 --- a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp @@ -31,6 +31,7 @@ #include "llvm/IR/Function.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/IntrinsicInst.h" +#include "llvm/IR/Intrinsics.h" #include "llvm/IR/Module.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" @@ -200,12 +201,22 @@ void FunctionLoweringInfo::set(const Function &fn, MachineFunction &mf, } } } - // Look for calls to the @llvm.va_start intrinsic. We can omit some - // prologue boilerplate for variadic functions that don't examine their - // arguments. if (const auto *II = dyn_cast<IntrinsicInst>(&I)) { - if (II->getIntrinsicID() == Intrinsic::vastart) + switch (II->getIntrinsicID()) { + case Intrinsic::vastart: + // Look for calls to the @llvm.va_start intrinsic. We can omit + // some prologue boilerplate for variadic functions that don't + // examine their arguments. MF->getFrameInfo().setHasVAStart(true); + break; + case Intrinsic::fake_use: + // Look for llvm.fake.uses, so that we can remove loads into fake + // uses later if necessary. + MF->setHasFakeUses(true); + break; + default: + break; + } } // If we have a musttail call in a variadic function, we need to ensure |