Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FMV][AArch64] Changes in fmv-features metadata. #122192

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

labrinea
Copy link
Collaborator

@labrinea labrinea commented Jan 8, 2025

  • We want the default version to have this attribute too otherwise it becomes indistinguishable from non-versioned functions.

  • We don't need the '+' unlike target-features which can negate. This will allow using the parsing API of target_version/clones for the metadata too.

* We want the default version to have this attribute too otherwise
  it becomes indistinguishable from non-versioned functions.

* We don't need the '+' unlike target-features which can negate.
  This will allow using the parsing API of target_version/clones
  for the metadata too.
@labrinea labrinea requested a review from jroelofs January 8, 2025 23:37
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:codegen labels Jan 8, 2025
@llvmbot
Copy link
Member

llvmbot commented Jan 8, 2025

@llvm/pr-subscribers-clang-codegen

Author: Alexandros Lamprineas (labrinea)

Changes
  • We want the default version to have this attribute too otherwise it becomes indistinguishable from non-versioned functions.

  • We don't need the '+' unlike target-features which can negate. This will allow using the parsing API of target_version/clones for the metadata too.


Patch is 32.23 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/122192.diff

6 Files Affected:

  • (modified) clang/lib/CodeGen/CodeGenModule.cpp (+12-4)
  • (modified) clang/test/CodeGen/AArch64/fmv-features.c (+49-47)
  • (modified) clang/test/CodeGen/AArch64/fmv-priority.c (+1-1)
  • (modified) clang/test/CodeGen/AArch64/fmv-streaming.c (+14-11)
  • (modified) clang/test/CodeGen/attr-target-clones-aarch64.c (+28-28)
  • (modified) clang/test/CodeGen/attr-target-version.c (+43-43)
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 7db1ed72fa5cde..e6c2dadb510c59 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -2748,17 +2748,25 @@ bool CodeGenModule::GetCPUAndFeaturesAttributes(GlobalDecl GD,
     Attrs.addAttribute("target-features", llvm::join(Features, ","));
     AddedAttr = true;
   }
+  // Add metadata for AArch64 Function Multi Versioning.
   if (getTarget().getTriple().isAArch64()) {
     llvm::SmallVector<StringRef, 8> Feats;
-    if (TV)
+    bool IsDefault = false;
+    if (TV) {
+      IsDefault = TV->isDefaultVersion();
       TV->getFeatures(Feats);
-    else if (TC)
+    } else if (TC) {
+      IsDefault = TC->isDefaultVersion(GD.getMultiVersionIndex());
       TC->getFeatures(Feats, GD.getMultiVersionIndex());
-    if (!Feats.empty()) {
+    }
+    if (IsDefault) {
+      Attrs.addAttribute("fmv-features");
+      AddedAttr = true;
+    } else if (!Feats.empty()) {
       llvm::sort(Feats);
       std::string FMVFeatures;
       for (StringRef F : Feats)
-        FMVFeatures.append(",+" + F.str());
+        FMVFeatures.append("," + F.str());
       Attrs.addAttribute("fmv-features", FMVFeatures.substr(1));
       AddedAttr = true;
     }
diff --git a/clang/test/CodeGen/AArch64/fmv-features.c b/clang/test/CodeGen/AArch64/fmv-features.c
index f78bf4b5d59c2b..8c5a6ae98e0f14 100644
--- a/clang/test/CodeGen/AArch64/fmv-features.c
+++ b/clang/test/CodeGen/AArch64/fmv-features.c
@@ -145,56 +145,58 @@ __attribute__((target_version("aes+bf16+bti+crc"))) int fmv(void) { return 0; }
 // CHECK-NOT: define dso_local i32 @fmv._M{{.*}}
 __attribute__((target_version("non_existent_extension"))) int fmv(void);
 
+// CHECK: define dso_local i32 @fmv.default() #[[default:[0-9]+]] {
 __attribute__((target_version("default"))) int fmv(void);
 
 int caller() {
   return fmv();
 }
 
-// CHECK: attributes #[[aes]] = { {{.*}} "fmv-features"="+aes"
-// CHECK: attributes #[[bf16]] = { {{.*}} "fmv-features"="+bf16"
-// CHECK: attributes #[[bti]] = { {{.*}} "fmv-features"="+bti"
-// CHECK: attributes #[[crc]] = { {{.*}} "fmv-features"="+crc"
-// CHECK: attributes #[[dit]] = { {{.*}} "fmv-features"="+dit"
-// CHECK: attributes #[[dotprod]] = { {{.*}} "fmv-features"="+dotprod"
-// CHECK: attributes #[[dpb]] = { {{.*}} "fmv-features"="+dpb"
-// CHECK: attributes #[[dpb2]] = { {{.*}} "fmv-features"="+dpb2"
-// CHECK: attributes #[[f32mm]] = { {{.*}} "fmv-features"="+f32mm"
-// CHECK: attributes #[[f64mm]] = { {{.*}} "fmv-features"="+f64mm"
-// CHECK: attributes #[[fcma]] = { {{.*}} "fmv-features"="+fcma"
-// CHECK: attributes #[[flagm]] = { {{.*}} "fmv-features"="+flagm"
-// CHECK: attributes #[[flagm2]] = { {{.*}} "fmv-features"="+flagm2"
-// CHECK: attributes #[[fp]] = { {{.*}} "fmv-features"="+fp"
-// CHECK: attributes #[[fp16]] = { {{.*}} "fmv-features"="+fp16"
-// CHECK: attributes #[[fp16fml]] = { {{.*}} "fmv-features"="+fp16fml"
-// CHECK: attributes #[[frintts]] = { {{.*}} "fmv-features"="+frintts"
-// CHECK: attributes #[[i8mm]] = { {{.*}} "fmv-features"="+i8mm"
-// CHECK: attributes #[[jscvt]] = { {{.*}} "fmv-features"="+jscvt"
-// CHECK: attributes #[[ls64]] = { {{.*}} "fmv-features"="+ls64"
-// CHECK: attributes #[[lse]] = { {{.*}} "fmv-features"="+lse"
-// CHECK: attributes #[[memtag]] = { {{.*}} "fmv-features"="+memtag"
-// CHECK: attributes #[[mops]] = { {{.*}} "fmv-features"="+mops"
-// CHECK: attributes #[[predres]] = { {{.*}} "fmv-features"="+predres"
-// CHECK: attributes #[[rcpc]] = { {{.*}} "fmv-features"="+rcpc"
-// CHECK: attributes #[[rcpc2]] = { {{.*}} "fmv-features"="+rcpc2"
-// CHECK: attributes #[[rcpc3]] = { {{.*}} "fmv-features"="+rcpc3"
-// CHECK: attributes #[[rdm]] = { {{.*}} "fmv-features"="+rdm"
-// CHECK: attributes #[[rng]] = { {{.*}} "fmv-features"="+rng"
-// CHECK: attributes #[[sb]] = { {{.*}} "fmv-features"="+sb"
-// CHECK: attributes #[[sha2]] = { {{.*}} "fmv-features"="+sha2"
-// CHECK: attributes #[[sha3]] = { {{.*}} "fmv-features"="+sha3"
-// CHECK: attributes #[[simd]] = { {{.*}} "fmv-features"="+simd"
-// CHECK: attributes #[[sm4]] = { {{.*}} "fmv-features"="+sm4"
-// CHECK: attributes #[[sme]] = { {{.*}} "fmv-features"="+sme"
-// CHECK: attributes #[[sme_f64f64]] = { {{.*}} "fmv-features"="+sme-f64f64"
-// CHECK: attributes #[[sme_i16i64]] = { {{.*}} "fmv-features"="+sme-i16i64"
-// CHECK: attributes #[[sme2]] = { {{.*}} "fmv-features"="+sme2"
-// CHECK: attributes #[[ssbs]] = { {{.*}} "fmv-features"="+ssbs"
-// CHECK: attributes #[[sve]] = { {{.*}} "fmv-features"="+sve"
-// CHECK: attributes #[[sve2]] = { {{.*}} "fmv-features"="+sve2"
-// CHECK: attributes #[[sve2_aes]] = { {{.*}} "fmv-features"="+sve2-aes"
-// CHECK: attributes #[[sve2_bitperm]] = { {{.*}} "fmv-features"="+sve2-bitperm"
-// CHECK: attributes #[[sve2_sha3]] = { {{.*}} "fmv-features"="+sve2-sha3"
-// CHECK: attributes #[[sve2_sm4]] = { {{.*}} "fmv-features"="+sve2-sm4"
-// CHECK: attributes #[[wfxt]] = { {{.*}} "fmv-features"="+wfxt"
-// CHECK: attributes #[[multiple_features]] = { {{.*}} "fmv-features"="+aes,+bf16,+bti,+crc"
+// CHECK: attributes #[[aes]] = {{.*}} "fmv-features"="aes"
+// CHECK: attributes #[[bf16]] = {{.*}} "fmv-features"="bf16"
+// CHECK: attributes #[[bti]] = {{.*}} "fmv-features"="bti"
+// CHECK: attributes #[[crc]] = {{.*}} "fmv-features"="crc"
+// CHECK: attributes #[[dit]] = {{.*}} "fmv-features"="dit"
+// CHECK: attributes #[[dotprod]] = {{.*}} "fmv-features"="dotprod"
+// CHECK: attributes #[[dpb]] = {{.*}} "fmv-features"="dpb"
+// CHECK: attributes #[[dpb2]] = {{.*}} "fmv-features"="dpb2"
+// CHECK: attributes #[[f32mm]] = {{.*}} "fmv-features"="f32mm"
+// CHECK: attributes #[[f64mm]] = {{.*}} "fmv-features"="f64mm"
+// CHECK: attributes #[[fcma]] = {{.*}} "fmv-features"="fcma"
+// CHECK: attributes #[[flagm]] = {{.*}} "fmv-features"="flagm"
+// CHECK: attributes #[[flagm2]] = {{.*}} "fmv-features"="flagm2"
+// CHECK: attributes #[[fp]] = {{.*}} "fmv-features"="fp"
+// CHECK: attributes #[[fp16]] = {{.*}} "fmv-features"="fp16"
+// CHECK: attributes #[[fp16fml]] = {{.*}} "fmv-features"="fp16fml"
+// CHECK: attributes #[[frintts]] = {{.*}} "fmv-features"="frintts"
+// CHECK: attributes #[[i8mm]] = {{.*}} "fmv-features"="i8mm"
+// CHECK: attributes #[[jscvt]] = {{.*}} "fmv-features"="jscvt"
+// CHECK: attributes #[[ls64]] = {{.*}} "fmv-features"="ls64"
+// CHECK: attributes #[[lse]] = {{.*}} "fmv-features"="lse"
+// CHECK: attributes #[[memtag]] = {{.*}} "fmv-features"="memtag"
+// CHECK: attributes #[[mops]] = {{.*}} "fmv-features"="mops"
+// CHECK: attributes #[[predres]] = {{.*}} "fmv-features"="predres"
+// CHECK: attributes #[[rcpc]] = {{.*}} "fmv-features"="rcpc"
+// CHECK: attributes #[[rcpc2]] = {{.*}} "fmv-features"="rcpc2"
+// CHECK: attributes #[[rcpc3]] = {{.*}} "fmv-features"="rcpc3"
+// CHECK: attributes #[[rdm]] = {{.*}} "fmv-features"="rdm"
+// CHECK: attributes #[[rng]] = {{.*}} "fmv-features"="rng"
+// CHECK: attributes #[[sb]] = {{.*}} "fmv-features"="sb"
+// CHECK: attributes #[[sha2]] = {{.*}} "fmv-features"="sha2"
+// CHECK: attributes #[[sha3]] = {{.*}} "fmv-features"="sha3"
+// CHECK: attributes #[[simd]] = {{.*}} "fmv-features"="simd"
+// CHECK: attributes #[[sm4]] = {{.*}} "fmv-features"="sm4"
+// CHECK: attributes #[[sme]] = {{.*}} "fmv-features"="sme"
+// CHECK: attributes #[[sme_f64f64]] = {{.*}} "fmv-features"="sme-f64f64"
+// CHECK: attributes #[[sme_i16i64]] = {{.*}} "fmv-features"="sme-i16i64"
+// CHECK: attributes #[[sme2]] = {{.*}} "fmv-features"="sme2"
+// CHECK: attributes #[[ssbs]] = {{.*}} "fmv-features"="ssbs"
+// CHECK: attributes #[[sve]] = {{.*}} "fmv-features"="sve"
+// CHECK: attributes #[[sve2]] = {{.*}} "fmv-features"="sve2"
+// CHECK: attributes #[[sve2_aes]] = {{.*}} "fmv-features"="sve2-aes"
+// CHECK: attributes #[[sve2_bitperm]] = {{.*}} "fmv-features"="sve2-bitperm"
+// CHECK: attributes #[[sve2_sha3]] = {{.*}} "fmv-features"="sve2-sha3"
+// CHECK: attributes #[[sve2_sm4]] = {{.*}} "fmv-features"="sve2-sm4"
+// CHECK: attributes #[[wfxt]] = {{.*}} "fmv-features"="wfxt"
+// CHECK: attributes #[[multiple_features]] = {{.*}} "fmv-features"="aes,bf16,bti,crc"
+// CHECK: attributes #[[default]] = {{.*}} "fmv-features"
diff --git a/clang/test/CodeGen/AArch64/fmv-priority.c b/clang/test/CodeGen/AArch64/fmv-priority.c
index 080bb54736a750..ff82aef89a33dc 100644
--- a/clang/test/CodeGen/AArch64/fmv-priority.c
+++ b/clang/test/CodeGen/AArch64/fmv-priority.c
@@ -26,7 +26,7 @@ int call() { return fn(); }
 //
 //
 // CHECK-LABEL: define dso_local i32 @call(
-// CHECK-SAME: ) #[[ATTR0]] {
+// CHECK-SAME: ) #[[ATTR1:[0-9]+]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
 // CHECK-NEXT:    [[CALL:%.*]] = call i32 @fn()
 // CHECK-NEXT:    ret i32 [[CALL]]
diff --git a/clang/test/CodeGen/AArch64/fmv-streaming.c b/clang/test/CodeGen/AArch64/fmv-streaming.c
index 68ba3e5cfaa78e..dc0c35a9a30775 100644
--- a/clang/test/CodeGen/AArch64/fmv-streaming.c
+++ b/clang/test/CodeGen/AArch64/fmv-streaming.c
@@ -53,10 +53,10 @@ __attribute__((target_version("default"))) void sc_callee(void) __arm_streaming_
 
 
 // CHECK-LABEL: define {{[^@]+}}@n_caller
-// CHECK-SAME: () #[[default]] {
+// CHECK-SAME: () #[[caller:[0-9]+]] {
 // CHECK:    call void @n_callee()
-// CHECK:    call void @s_callee() #[[streaming:[0-9]+]]
-// CHECK:    call void @sc_callee() #[[streaming_compatible:[0-9]+]]
+// CHECK:    call void @s_callee() #[[callsite_streaming:[0-9]+]]
+// CHECK:    call void @sc_callee() #[[callsite_streaming_compatible:[0-9]+]]
 //
 void n_caller(void) {
   n_callee();
@@ -66,10 +66,10 @@ void n_caller(void) {
 
 
 // CHECK-LABEL: define {{[^@]+}}@s_caller
-// CHECK-SAME: () #[[default_streaming]] {
+// CHECK-SAME: () #[[caller_streaming:[0-9]+]] {
 // CHECK:    call void @n_callee()
-// CHECK:    call void @s_callee() #[[streaming]]
-// CHECK:    call void @sc_callee() #[[streaming_compatible]]
+// CHECK:    call void @s_callee() #[[callsite_streaming]]
+// CHECK:    call void @sc_callee() #[[callsite_streaming_compatible]]
 //
 void s_caller(void) __arm_streaming {
   n_callee();
@@ -79,10 +79,10 @@ void s_caller(void) __arm_streaming {
 
 
 // CHECK-LABEL: define {{[^@]+}}@sc_caller
-// CHECK-SAME: () #[[default_streaming_compatible]] {
+// CHECK-SAME: () #[[caller_streaming_compatible:[0-9]+]] {
 // CHECK:    call void @n_callee()
-// CHECK:    call void @s_callee() #[[streaming]]
-// CHECK:    call void @sc_callee() #[[streaming_compatible]]
+// CHECK:    call void @s_callee() #[[callsite_streaming]]
+// CHECK:    call void @sc_callee() #[[callsite_streaming_compatible]]
 //
 void sc_caller(void) __arm_streaming_compatible {
   n_callee();
@@ -103,5 +103,8 @@ void sc_caller(void) __arm_streaming_compatible {
 // CHECK: attributes #[[simd_streaming_compatible]] = {{.*}} "aarch64_pstate_sm_compatible"
 // CHECK: attributes #[[locally_streaming_sme2_streaming_compatible]] = {{.*}} "aarch64_pstate_sm_body" "aarch64_pstate_sm_compatible"
 // CHECK: attributes #[[default_streaming_compatible]] = {{.*}} "aarch64_pstate_sm_compatible"
-// CHECK: attributes #[[streaming]] = {{.*}} "aarch64_pstate_sm_enabled"
-// CHECK: attributes #[[streaming_compatible]] = {{.*}} "aarch64_pstate_sm_compatible"
+// CHECK: attributes #[[caller]] = {{.*}}
+// CHECK: attributes #[[caller_streaming]] = {{.*}} "aarch64_pstate_sm_enabled"
+// CHECK: attributes #[[caller_streaming_compatible]] = {{.*}} "aarch64_pstate_sm_compatible"
+// CHECK: attributes #[[callsite_streaming]] = {{.*}} "aarch64_pstate_sm_enabled"
+// CHECK: attributes #[[callsite_streaming_compatible]] = {{.*}} "aarch64_pstate_sm_compatible"
diff --git a/clang/test/CodeGen/attr-target-clones-aarch64.c b/clang/test/CodeGen/attr-target-clones-aarch64.c
index b7e3a328db8773..9e1588cd483366 100644
--- a/clang/test/CodeGen/attr-target-clones-aarch64.c
+++ b/clang/test/CodeGen/attr-target-clones-aarch64.c
@@ -252,56 +252,56 @@ inline int __attribute__((target_clones("fp16", "sve2-bitperm+fcma", "default"))
 //
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: define {{[^@]+}}@ftc.default
-// CHECK-SAME: () #[[ATTR8]] {
+// CHECK-SAME: () #[[ATTR9:[0-9]+]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:    ret i32 0
 //
 //
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: define {{[^@]+}}@ftc_def.default
-// CHECK-SAME: () #[[ATTR8]] {
+// CHECK-SAME: () #[[ATTR9]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:    ret i32 1
 //
 //
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: define {{[^@]+}}@ftc_dup1.default
-// CHECK-SAME: () #[[ATTR8]] {
+// CHECK-SAME: () #[[ATTR9]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:    ret i32 2
 //
 //
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: define {{[^@]+}}@ftc_dup2.default
-// CHECK-SAME: () #[[ATTR8]] {
+// CHECK-SAME: () #[[ATTR9]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:    ret i32 3
 //
 //
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: define {{[^@]+}}@ftc_dup3.default
-// CHECK-SAME: () #[[ATTR8]] {
+// CHECK-SAME: () #[[ATTR9]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:    ret i32 4
 //
 //
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: define {{[^@]+}}@ftc_inline2._Mfp16
-// CHECK-SAME: () #[[ATTR9:[0-9]+]] {
+// CHECK-SAME: () #[[ATTR10:[0-9]+]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:    ret i32 2
 //
 //
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: define {{[^@]+}}@ftc_inline2._MfcmaMsve2-bitperm
-// CHECK-SAME: () #[[ATTR10:[0-9]+]] {
+// CHECK-SAME: () #[[ATTR11:[0-9]+]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:    ret i32 2
 //
 //
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: define {{[^@]+}}@ftc_inline2.default
-// CHECK-SAME: () #[[ATTR8]] {
+// CHECK-SAME: () #[[ATTR9]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:    ret i32 2
 //
@@ -330,28 +330,28 @@ inline int __attribute__((target_clones("fp16", "sve2-bitperm+fcma", "default"))
 //
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: define {{[^@]+}}@ftc_inline1._MrngMsimd
-// CHECK-SAME: () #[[ATTR11:[0-9]+]] {
+// CHECK-SAME: () #[[ATTR12:[0-9]+]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:    ret i32 1
 //
 //
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: define {{[^@]+}}@ftc_inline1._MpredresMrcpc
-// CHECK-SAME: () #[[ATTR12:[0-9]+]] {
+// CHECK-SAME: () #[[ATTR13:[0-9]+]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:    ret i32 1
 //
 //
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: define {{[^@]+}}@ftc_inline1._Msve2-aesMwfxt
-// CHECK-SAME: () #[[ATTR13:[0-9]+]] {
+// CHECK-SAME: () #[[ATTR14:[0-9]+]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:    ret i32 1
 //
 //
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: define {{[^@]+}}@ftc_inline1.default
-// CHECK-SAME: () #[[ATTR8]] {
+// CHECK-SAME: () #[[ATTR9]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:    ret i32 1
 //
@@ -395,14 +395,14 @@ inline int __attribute__((target_clones("fp16", "sve2-bitperm+fcma", "default"))
 //
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: define {{[^@]+}}@ftc_inline3._MsbMsve
-// CHECK-SAME: () #[[ATTR14:[0-9]+]] {
+// CHECK-SAME: () #[[ATTR15:[0-9]+]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:    ret i32 3
 //
 //
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: define {{[^@]+}}@ftc_inline3.default
-// CHECK-SAME: () #[[ATTR8]] {
+// CHECK-SAME: () #[[ATTR9]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:    ret i32 3
 //
@@ -709,56 +709,56 @@ inline int __attribute__((target_clones("fp16", "sve2-bitperm+fcma", "default"))
 //
 // CHECK-MTE-BTI: Function Attrs: noinline nounwind optnone
 // CHECK-MTE-BTI-LABEL: define {{[^@]+}}@ftc.default
-// CHECK-MTE-BTI-SAME: () #[[ATTR8]] {
+// CHECK-MTE-BTI-SAME: () #[[ATTR9:[0-9]+]] {
 // CHECK-MTE-BTI-NEXT:  entry:
 // CHECK-MTE-BTI-NEXT:    ret i32 0
 //
 //
 // CHECK-MTE-BTI: Function Attrs: noinline nounwind optnone
 // CHECK-MTE-BTI-LABEL: define {{[^@]+}}@ftc_def.default
-// CHECK-MTE-BTI-SAME: () #[[ATTR8]] {
+// CHECK-MTE-BTI-SAME: () #[[ATTR9]] {
 // CHECK-MTE-BTI-NEXT:  entry:
 // CHECK-MTE-BTI-NEXT:    ret i32 1
 //
 //
 // CHECK-MTE-BTI: Function Attrs: noinline nounwind optnone
 // CHECK-MTE-BTI-LABEL: define {{[^@]+}}@ftc_dup1.default
-// CHECK-MTE-BTI-SAME: () #[[ATTR8]] {
+// CHECK-MTE-BTI-SAME: () #[[ATTR9]] {
 // CHECK-MTE-BTI-NEXT:  entry:
 // CHECK-MTE-BTI-NEXT:    ret i32 2
 //
 //
 // CHECK-MTE-BTI: Function Attrs: noinline nounwind optnone
 // CHECK-MTE-BTI-LABEL: define {{[^@]+}}@ftc_dup2.default
-// CHECK-MTE-BTI-SAME: () #[[ATTR8]] {
+// CHECK-MTE-BTI-SAME: () #[[ATTR9]] {
 // CHECK-MTE-BTI-NEXT:  entry:
 // CHECK-MTE-BTI-NEXT:    ret i32 3
 //
 //
 // CHECK-MTE-BTI: Function Attrs: noinline nounwind optnone
 // CHECK-MTE-BTI-LABEL: define {{[^@]+}}@ftc_dup3.default
-// CHECK-MTE-BTI-SAME: () #[[ATTR8]] {
+// CHECK-MTE-BTI-SAME: () #[[ATTR9]] {
 // CHECK-MTE-BTI-NEXT:  entry:
 // CHECK-MTE-BTI-NEXT:    ret i32 4
 //
 //
 // CHECK-MTE-BTI: Function Attrs: noinline nounwind optnone
 // CHECK-MTE-BTI-LABEL: define {{[^@]+}}@ftc_inline2._Mfp16
-// CHECK-MTE-BTI-SAME: () #[[ATTR9:[0-9]+]] {
+// CHECK-MTE-BTI-SAME: () #[[ATTR10:[0-9]+]] {
 // CHECK-MTE-BTI-NEXT:  entry:
 // CHECK-MTE-BTI-NEXT:    ret i32 2
 //
 //
 // CHECK-MTE-BTI: Function Attrs: noinline nounwind optnone
 // CHECK-MTE-BTI-LABEL: define {{[^@]+}}@ftc_inline2._MfcmaMsve2-bitperm
-// CHECK-MTE-BTI-SAME: () #[[ATTR10:[0-9]+]] {
+// CHECK-MTE-BTI-SAME: () #[[ATTR11:[0-9]+]] {
 // CHECK-MTE-BTI-NEXT:  entry:
 // CHECK-MTE-BTI-NEXT:    ret i32 2
 //
 //
 // CHECK-MTE-BTI: Function Attrs: noinline nounwind optnone
 // CHECK-MTE-BTI-LABEL: define {{[^@]+}}@ftc_inline2.default
-// CHECK-MTE-BTI-SAME: () #[[ATTR8]] {
+// CHECK-MTE-BTI-SAME: () #[[ATTR9]] {
 // CHECK-MTE-BTI-NEXT:  entry:
 // CHECK-MTE-BTI-NEXT:    ret i32 2
 //
@@ -787,28 +787,28 @@ inline int __attribute__((target_clones("fp16", "sve2-bitperm+fcma", "default"))
 //
 // CHECK-MTE-BTI: Function Attrs: noinline nounwind optnone
 // CHECK-MTE-BTI-LABEL: define {{[^@]+}}@ftc_inline1._MrngMsimd
-// CHECK-MTE-BTI-SAME: () #[[ATTR11:[0-9]+]] {
+// CHECK-MTE-BTI-SAME: () #[[ATTR12:[0-9]+]] {
 // CHECK-MTE-BTI-NEXT:  entry:
 // CHECK-MTE-BTI-NEXT:    ret i32 1
 //
 //
 // CHECK-MTE-BTI: Function Attrs: noinline nounwind optnone
 // CHECK-MTE-BTI-LABEL: define {{[^@]+}}@ftc_inline1._MpredresMrcpc
-// CHECK-MTE-BTI-SAME: () #[[ATTR12:[0-9]+]] {
+// CHECK-MTE-BTI-SAME: () #[[ATTR13:[0-9]+]] {
 // CHECK-MTE-BTI-NEXT:  entry:
 // CHECK-MTE-BTI-NEXT:    ret i32 1
 //
 //
 // CHECK-MTE-BTI: Function Attrs: noinline nounwind optnone
 // CHECK-MTE-BTI-LABEL: define {{[^@]+}}@ftc_inline1._Msve2-aesMwfxt
-// CHECK-MTE-BTI-SAME: () #[[ATTR13:[0-9]+]] {
+// CHECK-MTE-BTI-SAME: () #[[ATTR14:[0-9]+]] {
 // CHECK-MTE-BTI-NEXT:  entry:
 // CHECK-MTE-BTI-NEXT:    ret i32 1
 //
 //
 // CHECK-MTE-BTI: Function Attrs: noinline nounwind optnone
 // CHECK-MTE-BTI-LABEL: define {{[^@]+}}@ftc_inline1.default
-// CHECK-MTE-BTI-SAME: () #[[ATTR8]] {
+// CHECK-MTE-BTI-SAME: () #[[ATTR9]] {
 // CHECK-MTE-BTI-NEXT:  entry:
 // CHECK-MTE-BTI-NEXT:    ret i32 1
 //
@@ -852,14 +852,14 @@ inline int __attribute__((target_clones("fp16", "sve2-bitperm+fcma", "default"))
 //
 // CHECK-MTE-BTI: Function Attrs: noinline nounwind optnone
 // CHECK-MTE-BTI-LABEL: define {{[^@]+}}@ftc_inline3._MsbMsve
-// CHECK-MTE-BTI-SAME: () #[[ATTR14:[0-9]+]] {
+// CHECK-MTE-BTI-SAME: () #[[ATTR15:[0-9]+]] {
 // CHECK-MTE-BTI-NEXT:  entry:
 // CHECK-MTE-BTI-NEXT:    ret i32 3
 //
 //
 // CHECK-MTE-BTI: Function Attrs: noinline nounwind optnone
 // CHECK-MTE-BTI-LABEL: define {{[^@]+}}@ftc_inline3.default
-// CHECK-MTE-BTI-SAME: () #[[ATTR8]] {
+// CHECK-MTE-BTI-SAME: () #[[ATTR9]] {
 // CHECK-MTE-BTI-NEXT:  entry:
 // CHECK-MTE-BTI-NEXT:    ret i32 3
 //
diff --git a/clang/test/CodeGen/attr-target-version.c b/clang/test/CodeGen/attr-target-version.c
index 336d8b0a4dffa0..a75514d63bce3c 100644
--- a/clang/test/CodeGen/attr-target-version.c
+++ b/clang/test/CodeGen/attr-target-version.c
@@ -272,7 +272,7 @@ int caller(void) { return used_def_without_default_decl() + used_decl_without_de
 //
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: define {{[^@]+}}@foo
-// CHECK-SAME: () #[[ATTR9]] {
+// CHECK-SAME: () #[[ATTR15:[0-9]+]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:    [[CALL:%.*]] = cal...
[truncated]

@llvmbot
Copy link
Member

llvmbot commented Jan 8, 2025

@llvm/pr-subscribers-clang

Author: Alexandros Lamprineas (labrinea)

Changes
  • We want the default version to have this attribute too otherwise it becomes indistinguishable from non-versioned functions.

  • We don't need the '+' unlike target-features which can negate. This will allow using the parsing API of target_version/clones for the metadata too.


Patch is 32.23 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/122192.diff

6 Files Affected:

  • (modified) clang/lib/CodeGen/CodeGenModule.cpp (+12-4)
  • (modified) clang/test/CodeGen/AArch64/fmv-features.c (+49-47)
  • (modified) clang/test/CodeGen/AArch64/fmv-priority.c (+1-1)
  • (modified) clang/test/CodeGen/AArch64/fmv-streaming.c (+14-11)
  • (modified) clang/test/CodeGen/attr-target-clones-aarch64.c (+28-28)
  • (modified) clang/test/CodeGen/attr-target-version.c (+43-43)
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 7db1ed72fa5cde..e6c2dadb510c59 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -2748,17 +2748,25 @@ bool CodeGenModule::GetCPUAndFeaturesAttributes(GlobalDecl GD,
     Attrs.addAttribute("target-features", llvm::join(Features, ","));
     AddedAttr = true;
   }
+  // Add metadata for AArch64 Function Multi Versioning.
   if (getTarget().getTriple().isAArch64()) {
     llvm::SmallVector<StringRef, 8> Feats;
-    if (TV)
+    bool IsDefault = false;
+    if (TV) {
+      IsDefault = TV->isDefaultVersion();
       TV->getFeatures(Feats);
-    else if (TC)
+    } else if (TC) {
+      IsDefault = TC->isDefaultVersion(GD.getMultiVersionIndex());
       TC->getFeatures(Feats, GD.getMultiVersionIndex());
-    if (!Feats.empty()) {
+    }
+    if (IsDefault) {
+      Attrs.addAttribute("fmv-features");
+      AddedAttr = true;
+    } else if (!Feats.empty()) {
       llvm::sort(Feats);
       std::string FMVFeatures;
       for (StringRef F : Feats)
-        FMVFeatures.append(",+" + F.str());
+        FMVFeatures.append("," + F.str());
       Attrs.addAttribute("fmv-features", FMVFeatures.substr(1));
       AddedAttr = true;
     }
diff --git a/clang/test/CodeGen/AArch64/fmv-features.c b/clang/test/CodeGen/AArch64/fmv-features.c
index f78bf4b5d59c2b..8c5a6ae98e0f14 100644
--- a/clang/test/CodeGen/AArch64/fmv-features.c
+++ b/clang/test/CodeGen/AArch64/fmv-features.c
@@ -145,56 +145,58 @@ __attribute__((target_version("aes+bf16+bti+crc"))) int fmv(void) { return 0; }
 // CHECK-NOT: define dso_local i32 @fmv._M{{.*}}
 __attribute__((target_version("non_existent_extension"))) int fmv(void);
 
+// CHECK: define dso_local i32 @fmv.default() #[[default:[0-9]+]] {
 __attribute__((target_version("default"))) int fmv(void);
 
 int caller() {
   return fmv();
 }
 
-// CHECK: attributes #[[aes]] = { {{.*}} "fmv-features"="+aes"
-// CHECK: attributes #[[bf16]] = { {{.*}} "fmv-features"="+bf16"
-// CHECK: attributes #[[bti]] = { {{.*}} "fmv-features"="+bti"
-// CHECK: attributes #[[crc]] = { {{.*}} "fmv-features"="+crc"
-// CHECK: attributes #[[dit]] = { {{.*}} "fmv-features"="+dit"
-// CHECK: attributes #[[dotprod]] = { {{.*}} "fmv-features"="+dotprod"
-// CHECK: attributes #[[dpb]] = { {{.*}} "fmv-features"="+dpb"
-// CHECK: attributes #[[dpb2]] = { {{.*}} "fmv-features"="+dpb2"
-// CHECK: attributes #[[f32mm]] = { {{.*}} "fmv-features"="+f32mm"
-// CHECK: attributes #[[f64mm]] = { {{.*}} "fmv-features"="+f64mm"
-// CHECK: attributes #[[fcma]] = { {{.*}} "fmv-features"="+fcma"
-// CHECK: attributes #[[flagm]] = { {{.*}} "fmv-features"="+flagm"
-// CHECK: attributes #[[flagm2]] = { {{.*}} "fmv-features"="+flagm2"
-// CHECK: attributes #[[fp]] = { {{.*}} "fmv-features"="+fp"
-// CHECK: attributes #[[fp16]] = { {{.*}} "fmv-features"="+fp16"
-// CHECK: attributes #[[fp16fml]] = { {{.*}} "fmv-features"="+fp16fml"
-// CHECK: attributes #[[frintts]] = { {{.*}} "fmv-features"="+frintts"
-// CHECK: attributes #[[i8mm]] = { {{.*}} "fmv-features"="+i8mm"
-// CHECK: attributes #[[jscvt]] = { {{.*}} "fmv-features"="+jscvt"
-// CHECK: attributes #[[ls64]] = { {{.*}} "fmv-features"="+ls64"
-// CHECK: attributes #[[lse]] = { {{.*}} "fmv-features"="+lse"
-// CHECK: attributes #[[memtag]] = { {{.*}} "fmv-features"="+memtag"
-// CHECK: attributes #[[mops]] = { {{.*}} "fmv-features"="+mops"
-// CHECK: attributes #[[predres]] = { {{.*}} "fmv-features"="+predres"
-// CHECK: attributes #[[rcpc]] = { {{.*}} "fmv-features"="+rcpc"
-// CHECK: attributes #[[rcpc2]] = { {{.*}} "fmv-features"="+rcpc2"
-// CHECK: attributes #[[rcpc3]] = { {{.*}} "fmv-features"="+rcpc3"
-// CHECK: attributes #[[rdm]] = { {{.*}} "fmv-features"="+rdm"
-// CHECK: attributes #[[rng]] = { {{.*}} "fmv-features"="+rng"
-// CHECK: attributes #[[sb]] = { {{.*}} "fmv-features"="+sb"
-// CHECK: attributes #[[sha2]] = { {{.*}} "fmv-features"="+sha2"
-// CHECK: attributes #[[sha3]] = { {{.*}} "fmv-features"="+sha3"
-// CHECK: attributes #[[simd]] = { {{.*}} "fmv-features"="+simd"
-// CHECK: attributes #[[sm4]] = { {{.*}} "fmv-features"="+sm4"
-// CHECK: attributes #[[sme]] = { {{.*}} "fmv-features"="+sme"
-// CHECK: attributes #[[sme_f64f64]] = { {{.*}} "fmv-features"="+sme-f64f64"
-// CHECK: attributes #[[sme_i16i64]] = { {{.*}} "fmv-features"="+sme-i16i64"
-// CHECK: attributes #[[sme2]] = { {{.*}} "fmv-features"="+sme2"
-// CHECK: attributes #[[ssbs]] = { {{.*}} "fmv-features"="+ssbs"
-// CHECK: attributes #[[sve]] = { {{.*}} "fmv-features"="+sve"
-// CHECK: attributes #[[sve2]] = { {{.*}} "fmv-features"="+sve2"
-// CHECK: attributes #[[sve2_aes]] = { {{.*}} "fmv-features"="+sve2-aes"
-// CHECK: attributes #[[sve2_bitperm]] = { {{.*}} "fmv-features"="+sve2-bitperm"
-// CHECK: attributes #[[sve2_sha3]] = { {{.*}} "fmv-features"="+sve2-sha3"
-// CHECK: attributes #[[sve2_sm4]] = { {{.*}} "fmv-features"="+sve2-sm4"
-// CHECK: attributes #[[wfxt]] = { {{.*}} "fmv-features"="+wfxt"
-// CHECK: attributes #[[multiple_features]] = { {{.*}} "fmv-features"="+aes,+bf16,+bti,+crc"
+// CHECK: attributes #[[aes]] = {{.*}} "fmv-features"="aes"
+// CHECK: attributes #[[bf16]] = {{.*}} "fmv-features"="bf16"
+// CHECK: attributes #[[bti]] = {{.*}} "fmv-features"="bti"
+// CHECK: attributes #[[crc]] = {{.*}} "fmv-features"="crc"
+// CHECK: attributes #[[dit]] = {{.*}} "fmv-features"="dit"
+// CHECK: attributes #[[dotprod]] = {{.*}} "fmv-features"="dotprod"
+// CHECK: attributes #[[dpb]] = {{.*}} "fmv-features"="dpb"
+// CHECK: attributes #[[dpb2]] = {{.*}} "fmv-features"="dpb2"
+// CHECK: attributes #[[f32mm]] = {{.*}} "fmv-features"="f32mm"
+// CHECK: attributes #[[f64mm]] = {{.*}} "fmv-features"="f64mm"
+// CHECK: attributes #[[fcma]] = {{.*}} "fmv-features"="fcma"
+// CHECK: attributes #[[flagm]] = {{.*}} "fmv-features"="flagm"
+// CHECK: attributes #[[flagm2]] = {{.*}} "fmv-features"="flagm2"
+// CHECK: attributes #[[fp]] = {{.*}} "fmv-features"="fp"
+// CHECK: attributes #[[fp16]] = {{.*}} "fmv-features"="fp16"
+// CHECK: attributes #[[fp16fml]] = {{.*}} "fmv-features"="fp16fml"
+// CHECK: attributes #[[frintts]] = {{.*}} "fmv-features"="frintts"
+// CHECK: attributes #[[i8mm]] = {{.*}} "fmv-features"="i8mm"
+// CHECK: attributes #[[jscvt]] = {{.*}} "fmv-features"="jscvt"
+// CHECK: attributes #[[ls64]] = {{.*}} "fmv-features"="ls64"
+// CHECK: attributes #[[lse]] = {{.*}} "fmv-features"="lse"
+// CHECK: attributes #[[memtag]] = {{.*}} "fmv-features"="memtag"
+// CHECK: attributes #[[mops]] = {{.*}} "fmv-features"="mops"
+// CHECK: attributes #[[predres]] = {{.*}} "fmv-features"="predres"
+// CHECK: attributes #[[rcpc]] = {{.*}} "fmv-features"="rcpc"
+// CHECK: attributes #[[rcpc2]] = {{.*}} "fmv-features"="rcpc2"
+// CHECK: attributes #[[rcpc3]] = {{.*}} "fmv-features"="rcpc3"
+// CHECK: attributes #[[rdm]] = {{.*}} "fmv-features"="rdm"
+// CHECK: attributes #[[rng]] = {{.*}} "fmv-features"="rng"
+// CHECK: attributes #[[sb]] = {{.*}} "fmv-features"="sb"
+// CHECK: attributes #[[sha2]] = {{.*}} "fmv-features"="sha2"
+// CHECK: attributes #[[sha3]] = {{.*}} "fmv-features"="sha3"
+// CHECK: attributes #[[simd]] = {{.*}} "fmv-features"="simd"
+// CHECK: attributes #[[sm4]] = {{.*}} "fmv-features"="sm4"
+// CHECK: attributes #[[sme]] = {{.*}} "fmv-features"="sme"
+// CHECK: attributes #[[sme_f64f64]] = {{.*}} "fmv-features"="sme-f64f64"
+// CHECK: attributes #[[sme_i16i64]] = {{.*}} "fmv-features"="sme-i16i64"
+// CHECK: attributes #[[sme2]] = {{.*}} "fmv-features"="sme2"
+// CHECK: attributes #[[ssbs]] = {{.*}} "fmv-features"="ssbs"
+// CHECK: attributes #[[sve]] = {{.*}} "fmv-features"="sve"
+// CHECK: attributes #[[sve2]] = {{.*}} "fmv-features"="sve2"
+// CHECK: attributes #[[sve2_aes]] = {{.*}} "fmv-features"="sve2-aes"
+// CHECK: attributes #[[sve2_bitperm]] = {{.*}} "fmv-features"="sve2-bitperm"
+// CHECK: attributes #[[sve2_sha3]] = {{.*}} "fmv-features"="sve2-sha3"
+// CHECK: attributes #[[sve2_sm4]] = {{.*}} "fmv-features"="sve2-sm4"
+// CHECK: attributes #[[wfxt]] = {{.*}} "fmv-features"="wfxt"
+// CHECK: attributes #[[multiple_features]] = {{.*}} "fmv-features"="aes,bf16,bti,crc"
+// CHECK: attributes #[[default]] = {{.*}} "fmv-features"
diff --git a/clang/test/CodeGen/AArch64/fmv-priority.c b/clang/test/CodeGen/AArch64/fmv-priority.c
index 080bb54736a750..ff82aef89a33dc 100644
--- a/clang/test/CodeGen/AArch64/fmv-priority.c
+++ b/clang/test/CodeGen/AArch64/fmv-priority.c
@@ -26,7 +26,7 @@ int call() { return fn(); }
 //
 //
 // CHECK-LABEL: define dso_local i32 @call(
-// CHECK-SAME: ) #[[ATTR0]] {
+// CHECK-SAME: ) #[[ATTR1:[0-9]+]] {
 // CHECK-NEXT:  [[ENTRY:.*:]]
 // CHECK-NEXT:    [[CALL:%.*]] = call i32 @fn()
 // CHECK-NEXT:    ret i32 [[CALL]]
diff --git a/clang/test/CodeGen/AArch64/fmv-streaming.c b/clang/test/CodeGen/AArch64/fmv-streaming.c
index 68ba3e5cfaa78e..dc0c35a9a30775 100644
--- a/clang/test/CodeGen/AArch64/fmv-streaming.c
+++ b/clang/test/CodeGen/AArch64/fmv-streaming.c
@@ -53,10 +53,10 @@ __attribute__((target_version("default"))) void sc_callee(void) __arm_streaming_
 
 
 // CHECK-LABEL: define {{[^@]+}}@n_caller
-// CHECK-SAME: () #[[default]] {
+// CHECK-SAME: () #[[caller:[0-9]+]] {
 // CHECK:    call void @n_callee()
-// CHECK:    call void @s_callee() #[[streaming:[0-9]+]]
-// CHECK:    call void @sc_callee() #[[streaming_compatible:[0-9]+]]
+// CHECK:    call void @s_callee() #[[callsite_streaming:[0-9]+]]
+// CHECK:    call void @sc_callee() #[[callsite_streaming_compatible:[0-9]+]]
 //
 void n_caller(void) {
   n_callee();
@@ -66,10 +66,10 @@ void n_caller(void) {
 
 
 // CHECK-LABEL: define {{[^@]+}}@s_caller
-// CHECK-SAME: () #[[default_streaming]] {
+// CHECK-SAME: () #[[caller_streaming:[0-9]+]] {
 // CHECK:    call void @n_callee()
-// CHECK:    call void @s_callee() #[[streaming]]
-// CHECK:    call void @sc_callee() #[[streaming_compatible]]
+// CHECK:    call void @s_callee() #[[callsite_streaming]]
+// CHECK:    call void @sc_callee() #[[callsite_streaming_compatible]]
 //
 void s_caller(void) __arm_streaming {
   n_callee();
@@ -79,10 +79,10 @@ void s_caller(void) __arm_streaming {
 
 
 // CHECK-LABEL: define {{[^@]+}}@sc_caller
-// CHECK-SAME: () #[[default_streaming_compatible]] {
+// CHECK-SAME: () #[[caller_streaming_compatible:[0-9]+]] {
 // CHECK:    call void @n_callee()
-// CHECK:    call void @s_callee() #[[streaming]]
-// CHECK:    call void @sc_callee() #[[streaming_compatible]]
+// CHECK:    call void @s_callee() #[[callsite_streaming]]
+// CHECK:    call void @sc_callee() #[[callsite_streaming_compatible]]
 //
 void sc_caller(void) __arm_streaming_compatible {
   n_callee();
@@ -103,5 +103,8 @@ void sc_caller(void) __arm_streaming_compatible {
 // CHECK: attributes #[[simd_streaming_compatible]] = {{.*}} "aarch64_pstate_sm_compatible"
 // CHECK: attributes #[[locally_streaming_sme2_streaming_compatible]] = {{.*}} "aarch64_pstate_sm_body" "aarch64_pstate_sm_compatible"
 // CHECK: attributes #[[default_streaming_compatible]] = {{.*}} "aarch64_pstate_sm_compatible"
-// CHECK: attributes #[[streaming]] = {{.*}} "aarch64_pstate_sm_enabled"
-// CHECK: attributes #[[streaming_compatible]] = {{.*}} "aarch64_pstate_sm_compatible"
+// CHECK: attributes #[[caller]] = {{.*}}
+// CHECK: attributes #[[caller_streaming]] = {{.*}} "aarch64_pstate_sm_enabled"
+// CHECK: attributes #[[caller_streaming_compatible]] = {{.*}} "aarch64_pstate_sm_compatible"
+// CHECK: attributes #[[callsite_streaming]] = {{.*}} "aarch64_pstate_sm_enabled"
+// CHECK: attributes #[[callsite_streaming_compatible]] = {{.*}} "aarch64_pstate_sm_compatible"
diff --git a/clang/test/CodeGen/attr-target-clones-aarch64.c b/clang/test/CodeGen/attr-target-clones-aarch64.c
index b7e3a328db8773..9e1588cd483366 100644
--- a/clang/test/CodeGen/attr-target-clones-aarch64.c
+++ b/clang/test/CodeGen/attr-target-clones-aarch64.c
@@ -252,56 +252,56 @@ inline int __attribute__((target_clones("fp16", "sve2-bitperm+fcma", "default"))
 //
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: define {{[^@]+}}@ftc.default
-// CHECK-SAME: () #[[ATTR8]] {
+// CHECK-SAME: () #[[ATTR9:[0-9]+]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:    ret i32 0
 //
 //
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: define {{[^@]+}}@ftc_def.default
-// CHECK-SAME: () #[[ATTR8]] {
+// CHECK-SAME: () #[[ATTR9]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:    ret i32 1
 //
 //
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: define {{[^@]+}}@ftc_dup1.default
-// CHECK-SAME: () #[[ATTR8]] {
+// CHECK-SAME: () #[[ATTR9]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:    ret i32 2
 //
 //
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: define {{[^@]+}}@ftc_dup2.default
-// CHECK-SAME: () #[[ATTR8]] {
+// CHECK-SAME: () #[[ATTR9]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:    ret i32 3
 //
 //
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: define {{[^@]+}}@ftc_dup3.default
-// CHECK-SAME: () #[[ATTR8]] {
+// CHECK-SAME: () #[[ATTR9]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:    ret i32 4
 //
 //
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: define {{[^@]+}}@ftc_inline2._Mfp16
-// CHECK-SAME: () #[[ATTR9:[0-9]+]] {
+// CHECK-SAME: () #[[ATTR10:[0-9]+]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:    ret i32 2
 //
 //
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: define {{[^@]+}}@ftc_inline2._MfcmaMsve2-bitperm
-// CHECK-SAME: () #[[ATTR10:[0-9]+]] {
+// CHECK-SAME: () #[[ATTR11:[0-9]+]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:    ret i32 2
 //
 //
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: define {{[^@]+}}@ftc_inline2.default
-// CHECK-SAME: () #[[ATTR8]] {
+// CHECK-SAME: () #[[ATTR9]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:    ret i32 2
 //
@@ -330,28 +330,28 @@ inline int __attribute__((target_clones("fp16", "sve2-bitperm+fcma", "default"))
 //
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: define {{[^@]+}}@ftc_inline1._MrngMsimd
-// CHECK-SAME: () #[[ATTR11:[0-9]+]] {
+// CHECK-SAME: () #[[ATTR12:[0-9]+]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:    ret i32 1
 //
 //
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: define {{[^@]+}}@ftc_inline1._MpredresMrcpc
-// CHECK-SAME: () #[[ATTR12:[0-9]+]] {
+// CHECK-SAME: () #[[ATTR13:[0-9]+]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:    ret i32 1
 //
 //
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: define {{[^@]+}}@ftc_inline1._Msve2-aesMwfxt
-// CHECK-SAME: () #[[ATTR13:[0-9]+]] {
+// CHECK-SAME: () #[[ATTR14:[0-9]+]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:    ret i32 1
 //
 //
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: define {{[^@]+}}@ftc_inline1.default
-// CHECK-SAME: () #[[ATTR8]] {
+// CHECK-SAME: () #[[ATTR9]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:    ret i32 1
 //
@@ -395,14 +395,14 @@ inline int __attribute__((target_clones("fp16", "sve2-bitperm+fcma", "default"))
 //
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: define {{[^@]+}}@ftc_inline3._MsbMsve
-// CHECK-SAME: () #[[ATTR14:[0-9]+]] {
+// CHECK-SAME: () #[[ATTR15:[0-9]+]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:    ret i32 3
 //
 //
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: define {{[^@]+}}@ftc_inline3.default
-// CHECK-SAME: () #[[ATTR8]] {
+// CHECK-SAME: () #[[ATTR9]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:    ret i32 3
 //
@@ -709,56 +709,56 @@ inline int __attribute__((target_clones("fp16", "sve2-bitperm+fcma", "default"))
 //
 // CHECK-MTE-BTI: Function Attrs: noinline nounwind optnone
 // CHECK-MTE-BTI-LABEL: define {{[^@]+}}@ftc.default
-// CHECK-MTE-BTI-SAME: () #[[ATTR8]] {
+// CHECK-MTE-BTI-SAME: () #[[ATTR9:[0-9]+]] {
 // CHECK-MTE-BTI-NEXT:  entry:
 // CHECK-MTE-BTI-NEXT:    ret i32 0
 //
 //
 // CHECK-MTE-BTI: Function Attrs: noinline nounwind optnone
 // CHECK-MTE-BTI-LABEL: define {{[^@]+}}@ftc_def.default
-// CHECK-MTE-BTI-SAME: () #[[ATTR8]] {
+// CHECK-MTE-BTI-SAME: () #[[ATTR9]] {
 // CHECK-MTE-BTI-NEXT:  entry:
 // CHECK-MTE-BTI-NEXT:    ret i32 1
 //
 //
 // CHECK-MTE-BTI: Function Attrs: noinline nounwind optnone
 // CHECK-MTE-BTI-LABEL: define {{[^@]+}}@ftc_dup1.default
-// CHECK-MTE-BTI-SAME: () #[[ATTR8]] {
+// CHECK-MTE-BTI-SAME: () #[[ATTR9]] {
 // CHECK-MTE-BTI-NEXT:  entry:
 // CHECK-MTE-BTI-NEXT:    ret i32 2
 //
 //
 // CHECK-MTE-BTI: Function Attrs: noinline nounwind optnone
 // CHECK-MTE-BTI-LABEL: define {{[^@]+}}@ftc_dup2.default
-// CHECK-MTE-BTI-SAME: () #[[ATTR8]] {
+// CHECK-MTE-BTI-SAME: () #[[ATTR9]] {
 // CHECK-MTE-BTI-NEXT:  entry:
 // CHECK-MTE-BTI-NEXT:    ret i32 3
 //
 //
 // CHECK-MTE-BTI: Function Attrs: noinline nounwind optnone
 // CHECK-MTE-BTI-LABEL: define {{[^@]+}}@ftc_dup3.default
-// CHECK-MTE-BTI-SAME: () #[[ATTR8]] {
+// CHECK-MTE-BTI-SAME: () #[[ATTR9]] {
 // CHECK-MTE-BTI-NEXT:  entry:
 // CHECK-MTE-BTI-NEXT:    ret i32 4
 //
 //
 // CHECK-MTE-BTI: Function Attrs: noinline nounwind optnone
 // CHECK-MTE-BTI-LABEL: define {{[^@]+}}@ftc_inline2._Mfp16
-// CHECK-MTE-BTI-SAME: () #[[ATTR9:[0-9]+]] {
+// CHECK-MTE-BTI-SAME: () #[[ATTR10:[0-9]+]] {
 // CHECK-MTE-BTI-NEXT:  entry:
 // CHECK-MTE-BTI-NEXT:    ret i32 2
 //
 //
 // CHECK-MTE-BTI: Function Attrs: noinline nounwind optnone
 // CHECK-MTE-BTI-LABEL: define {{[^@]+}}@ftc_inline2._MfcmaMsve2-bitperm
-// CHECK-MTE-BTI-SAME: () #[[ATTR10:[0-9]+]] {
+// CHECK-MTE-BTI-SAME: () #[[ATTR11:[0-9]+]] {
 // CHECK-MTE-BTI-NEXT:  entry:
 // CHECK-MTE-BTI-NEXT:    ret i32 2
 //
 //
 // CHECK-MTE-BTI: Function Attrs: noinline nounwind optnone
 // CHECK-MTE-BTI-LABEL: define {{[^@]+}}@ftc_inline2.default
-// CHECK-MTE-BTI-SAME: () #[[ATTR8]] {
+// CHECK-MTE-BTI-SAME: () #[[ATTR9]] {
 // CHECK-MTE-BTI-NEXT:  entry:
 // CHECK-MTE-BTI-NEXT:    ret i32 2
 //
@@ -787,28 +787,28 @@ inline int __attribute__((target_clones("fp16", "sve2-bitperm+fcma", "default"))
 //
 // CHECK-MTE-BTI: Function Attrs: noinline nounwind optnone
 // CHECK-MTE-BTI-LABEL: define {{[^@]+}}@ftc_inline1._MrngMsimd
-// CHECK-MTE-BTI-SAME: () #[[ATTR11:[0-9]+]] {
+// CHECK-MTE-BTI-SAME: () #[[ATTR12:[0-9]+]] {
 // CHECK-MTE-BTI-NEXT:  entry:
 // CHECK-MTE-BTI-NEXT:    ret i32 1
 //
 //
 // CHECK-MTE-BTI: Function Attrs: noinline nounwind optnone
 // CHECK-MTE-BTI-LABEL: define {{[^@]+}}@ftc_inline1._MpredresMrcpc
-// CHECK-MTE-BTI-SAME: () #[[ATTR12:[0-9]+]] {
+// CHECK-MTE-BTI-SAME: () #[[ATTR13:[0-9]+]] {
 // CHECK-MTE-BTI-NEXT:  entry:
 // CHECK-MTE-BTI-NEXT:    ret i32 1
 //
 //
 // CHECK-MTE-BTI: Function Attrs: noinline nounwind optnone
 // CHECK-MTE-BTI-LABEL: define {{[^@]+}}@ftc_inline1._Msve2-aesMwfxt
-// CHECK-MTE-BTI-SAME: () #[[ATTR13:[0-9]+]] {
+// CHECK-MTE-BTI-SAME: () #[[ATTR14:[0-9]+]] {
 // CHECK-MTE-BTI-NEXT:  entry:
 // CHECK-MTE-BTI-NEXT:    ret i32 1
 //
 //
 // CHECK-MTE-BTI: Function Attrs: noinline nounwind optnone
 // CHECK-MTE-BTI-LABEL: define {{[^@]+}}@ftc_inline1.default
-// CHECK-MTE-BTI-SAME: () #[[ATTR8]] {
+// CHECK-MTE-BTI-SAME: () #[[ATTR9]] {
 // CHECK-MTE-BTI-NEXT:  entry:
 // CHECK-MTE-BTI-NEXT:    ret i32 1
 //
@@ -852,14 +852,14 @@ inline int __attribute__((target_clones("fp16", "sve2-bitperm+fcma", "default"))
 //
 // CHECK-MTE-BTI: Function Attrs: noinline nounwind optnone
 // CHECK-MTE-BTI-LABEL: define {{[^@]+}}@ftc_inline3._MsbMsve
-// CHECK-MTE-BTI-SAME: () #[[ATTR14:[0-9]+]] {
+// CHECK-MTE-BTI-SAME: () #[[ATTR15:[0-9]+]] {
 // CHECK-MTE-BTI-NEXT:  entry:
 // CHECK-MTE-BTI-NEXT:    ret i32 3
 //
 //
 // CHECK-MTE-BTI: Function Attrs: noinline nounwind optnone
 // CHECK-MTE-BTI-LABEL: define {{[^@]+}}@ftc_inline3.default
-// CHECK-MTE-BTI-SAME: () #[[ATTR8]] {
+// CHECK-MTE-BTI-SAME: () #[[ATTR9]] {
 // CHECK-MTE-BTI-NEXT:  entry:
 // CHECK-MTE-BTI-NEXT:    ret i32 3
 //
diff --git a/clang/test/CodeGen/attr-target-version.c b/clang/test/CodeGen/attr-target-version.c
index 336d8b0a4dffa0..a75514d63bce3c 100644
--- a/clang/test/CodeGen/attr-target-version.c
+++ b/clang/test/CodeGen/attr-target-version.c
@@ -272,7 +272,7 @@ int caller(void) { return used_def_without_default_decl() + used_decl_without_de
 //
 // CHECK: Function Attrs: noinline nounwind optnone
 // CHECK-LABEL: define {{[^@]+}}@foo
-// CHECK-SAME: () #[[ATTR9]] {
+// CHECK-SAME: () #[[ATTR15:[0-9]+]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:    [[CALL:%.*]] = cal...
[truncated]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:codegen clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants