diff options
author | Alexandros Lamprineas <alexandros.lamprineas@arm.com> | 2025-01-07 08:51:23 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-07 08:51:23 +0000 |
commit | 93011fe2a5268aab9bf59e71b9d21a3818d1e199 (patch) | |
tree | 295d2cc21c7c45a171854e6f497fa2c1bb1b9fc1 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 446a426436c0b7e457992981d3a1f2b4fda19992 (diff) | |
download | llvm-93011fe2a5268aab9bf59e71b9d21a3818d1e199.zip llvm-93011fe2a5268aab9bf59e71b9d21a3818d1e199.tar.gz llvm-93011fe2a5268aab9bf59e71b9d21a3818d1e199.tar.bz2 |
[FMV][AArch64][clang] Emit fmv-features metadata in LLVM IR. (#118544)
We need to be able to propagate information about FMV attribute strings
from C/C++ source to LLVM IR. This is necessary so that we can
distinguish which target-features are coming from the cmdline, which are
coming from the target attribute, and which are coming from feature
dependency expansion. We need this for static resolution of calls in
LLVM. Here's a motivating example:
Suppose you have target_version("i8mm+dotprod") and
target_version("fcma"). The first version clearly has higher priority.
Now suppose you specify -march=armv8-a+i8mm on the command line. Then
the versions would have target-features "+i8mm,+dotprod" and
"+i8mm,+fcma" respectively. If you are using those to deduce version
priority, then you would incorrectly deduce that the second version was
higher priority than the first.
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index c49f763..5f15f0f 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -2748,7 +2748,21 @@ bool CodeGenModule::GetCPUAndFeaturesAttributes(GlobalDecl GD, Attrs.addAttribute("target-features", llvm::join(Features, ",")); AddedAttr = true; } - + if (getTarget().getTriple().isAArch64()) { + llvm::SmallVector<StringRef, 8> Feats; + if (TV) + TV->getFeatures(Feats); + else if (TC) + TC->getFeatures(Feats, GD.getMultiVersionIndex()); + if (!Feats.empty()) { + llvm::sort(Feats); + std::string FMVFeatures; + for (StringRef F : Feats) + FMVFeatures.append(",+" + F.str()); + Attrs.addAttribute("fmv-features", FMVFeatures.substr(1)); + AddedAttr = true; + } + } return AddedAttr; } |