diff options
author | Alexandros Lamprineas <alexandros.lamprineas@arm.com> | 2024-07-19 15:17:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-19 15:17:06 +0100 |
commit | c719d7b390481b095c7498fe75a0bcf60a24bad9 (patch) | |
tree | 3357b5da38c061871760242d7b265a800f5855a9 /clang/lib/CodeGen/CodeGenFunction.cpp | |
parent | 4c28494e7842b26a566f9406f71510eda4a9e576 (diff) | |
download | llvm-c719d7b390481b095c7498fe75a0bcf60a24bad9.zip llvm-c719d7b390481b095c7498fe75a0bcf60a24bad9.tar.gz llvm-c719d7b390481b095c7498fe75a0bcf60a24bad9.tar.bz2 |
[FMV][AArch64] Do not optimize away runtime checks for implied features (#99522)
When generating the body of the ifunc resolver, clang skips runtime
checks for features that are implied from the command line. We bend this
rule for certain features (memtag, bti, dgh), but this happens quite
arbitrarily in my opinion. The reasoning is that some features are in
the HINT instruction space, meaning they operate as NOPs if the hardware
does not support them. Still the user wants to detect their presence
with runtime checks. See #90928 for details.
I think we should always perform runtime checks regardless of the
feature and then try to statically resolve calls whenever a function is
compiled with a sufficiently high set of architecture features (so
including target/target_version/target_clones attributes, and command
line options). This is what GCC does. We have an open PR in LLVM
GlobalOpt since it was suggested not to perform such codegen
optimizations in clang anyway. See #87939.
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 551db09..1e98bea 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -2797,16 +2797,8 @@ void CodeGenFunction::EmitKCFIOperandBundle( llvm::Value *CodeGenFunction::FormAArch64ResolverCondition( const MultiVersionResolverOption &RO) { llvm::SmallVector<StringRef, 8> CondFeatures; - for (const StringRef &Feature : RO.Conditions.Features) { - // Optimize the Function Multi Versioning resolver by creating conditions - // only for features that are not enabled in the target. The exception is - // for features whose extension instructions are executed as NOP on targets - // without extension support. - if (!getContext().getTargetInfo().hasFeature(Feature) || Feature == "bti" || - Feature == "memtag" || Feature == "memtag2" || Feature == "memtag3" || - Feature == "dgh") - CondFeatures.push_back(Feature); - } + for (const StringRef &Feature : RO.Conditions.Features) + CondFeatures.push_back(Feature); if (!CondFeatures.empty()) { return EmitAArch64CpuSupports(CondFeatures); } |