aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorPavel Iliin <Pavel.Iliin@arm.com>2024-05-03 18:07:17 +0100
committerGitHub <noreply@github.com>2024-05-03 18:07:17 +0100
commit804202292b7601feee5c091a3a6df6124f4d61e1 (patch)
tree24772fc3b853bd8470cd3521d1ffe96587a90ef1 /clang/lib/CodeGen/CodeGenFunction.cpp
parent8a0073ad4658033b6a4f6bae4fbaf924ac813bc6 (diff)
downloadllvm-804202292b7601feee5c091a3a6df6124f4d61e1.zip
llvm-804202292b7601feee5c091a3a6df6124f4d61e1.tar.gz
llvm-804202292b7601feee5c091a3a6df6124f4d61e1.tar.bz2
[FMV][AArch64] Don't optimize backward compatible features in resolver. (#90928)
For arch64 features, such as Branch Target Identification or MTE (Memory Tagging Extension), compatible with targets that lack their support we may encounter scenarios where a binary compiled with MTE for example is executed on both MTE and non-MTE hardware and we still need to detect at runtime whether the MTE feature is available to choose the appropriate function version. So, we cannot optimize the function multi versioning resolver by removing checks for these features enabled for the target during compilation.
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index 546beae..4778141 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -2761,8 +2761,14 @@ llvm::Value *CodeGenFunction::FormAArch64ResolverCondition(
const MultiVersionResolverOption &RO) {
llvm::SmallVector<StringRef, 8> CondFeatures;
for (const StringRef &Feature : RO.Conditions.Features) {
- // Form condition for features which are not yet enabled in target
- if (!getContext().getTargetInfo().hasFeature(Feature))
+ // 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.equals("bti") || Feature.equals("memtag") ||
+ Feature.equals("memtag2") || Feature.equals("memtag3") ||
+ Feature.equals("dgh"))
CondFeatures.push_back(Feature);
}
if (!CondFeatures.empty()) {