Skip to content

Commit 6f54a54

Browse files
authored
[FMV] Remove duplicate features from mangled name. (#84165)
ACLE suggests: ARM-software/acle#308. GCC emits diagnostics for attribute strings which contain duplicate features, but for now let's follow the SPEC in regards to mangling rules and we can change the semantic behavior of the compiler later if there's value to it.
1 parent afac64c commit 6f54a54

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

clang/lib/CodeGen/Targets/AArch64.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,9 +886,11 @@ void AArch64ABIInfo::appendAttributeMangling(StringRef AttrStr,
886886
return LHS.compare(RHS) < 0;
887887
});
888888

889+
llvm::SmallDenseSet<StringRef, 8> UniqueFeats;
889890
for (auto &Feat : Features)
890891
if (auto Ext = llvm::AArch64::parseArchExtension(Feat))
891-
Out << 'M' << Ext->Name;
892+
if (UniqueFeats.insert(Ext->Name).second)
893+
Out << 'M' << Ext->Name;
892894
}
893895

894896
std::unique_ptr<TargetCodeGenInfo>

clang/test/CodeGen/attr-target-version.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ int hoo(void) {
273273
// CHECK-NEXT: [[TMP3:%.*]] = and i1 true, [[TMP2]]
274274
// CHECK-NEXT: br i1 [[TMP3]], label [[RESOLVER_RETURN:%.*]], label [[RESOLVER_ELSE:%.*]]
275275
// CHECK: resolver_return:
276-
// CHECK-NEXT: ret ptr @fmv_inline._MfcmaMfp16Mfp16MrdmMsme
276+
// CHECK-NEXT: ret ptr @fmv_inline._MfcmaMfp16MrdmMsme
277277
// CHECK: resolver_else:
278278
// CHECK-NEXT: [[TMP4:%.*]] = load i64, ptr @__aarch64_cpu_features, align 8
279279
// CHECK-NEXT: [[TMP5:%.*]] = and i64 [[TMP4]], 864726312827224064
@@ -582,7 +582,7 @@ int hoo(void) {
582582
//
583583
//
584584
// CHECK: Function Attrs: noinline nounwind optnone
585-
// CHECK-LABEL: define {{[^@]+}}@fmv_inline._MfcmaMfp16Mfp16MrdmMsme
585+
// CHECK-LABEL: define {{[^@]+}}@fmv_inline._MfcmaMfp16MrdmMsme
586586
// CHECK-SAME: () #[[ATTR13:[0-9]+]] {
587587
// CHECK-NEXT: entry:
588588
// CHECK-NEXT: ret i32 2

0 commit comments

Comments
 (0)