r322618 - [CodeGen] Fix a crash on mangling multiversioned functions
George Burgess IV via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 16 20:46:05 PST 2018
Author: gbiv
Date: Tue Jan 16 20:46:04 2018
New Revision: 322618
URL: http://llvm.org/viewvc/llvm-project?rev=322618&view=rev
Log:
[CodeGen] Fix a crash on mangling multiversioned functions
`multiVersionSortPriority` expects features to have no prefix. We
currently carry them around in the format "+${feature}".
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGen/attr-target-mv.c
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=322618&r1=322617&r2=322618&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Jan 16 20:46:04 2018
@@ -753,8 +753,12 @@ static void AppendTargetMangling(const C
const auto &Target = CGM.getTarget();
TargetAttr::ParsedTargetAttr Info =
Attr->parse([&Target](StringRef LHS, StringRef RHS) {
- return Target.multiVersionSortPriority(LHS) >
- Target.multiVersionSortPriority(RHS);
+ // Multiversioning doesn't allow "no-${feature}", so we can
+ // only have "+" prefixes here.
+ assert(LHS.startswith("+") && RHS.startswith("+") &&
+ "Features should always have a prefix.");
+ return Target.multiVersionSortPriority(LHS.substr(1)) >
+ Target.multiVersionSortPriority(RHS.substr(1));
});
bool IsFirst = true;
Modified: cfe/trunk/test/CodeGen/attr-target-mv.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-target-mv.c?rev=322618&r1=322617&r2=322618&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/attr-target-mv.c (original)
+++ cfe/trunk/test/CodeGen/attr-target-mv.c Tue Jan 16 20:46:04 2018
@@ -25,6 +25,14 @@ void bar3() {
inline __attribute__((target("default"))) void foo_decls(void) {}
inline __attribute__((target("sse4.2"))) void foo_decls(void) {}
+inline __attribute__((target("default"))) void foo_multi(void) {}
+inline __attribute__((target("avx,sse4.2"))) void foo_multi(void) {}
+inline __attribute__((target("sse4.2,fma4"))) void foo_multi(void) {}
+inline __attribute__((target("arch=ivybridge,fma4,sse4.2"))) void foo_multi(void) {}
+void bar4() {
+ foo_multi();
+}
+
// CHECK: @foo.ifunc = ifunc i32 (), i32 ()* ()* @foo.resolver
// CHECK: @foo_inline.ifunc = ifunc i32 (), i32 ()* ()* @foo_inline.resolver
// CHECK: @foo_decls.ifunc = ifunc void (), void ()* ()* @foo_decls.resolver
@@ -77,3 +85,7 @@ inline __attribute__((target("sse4.2")))
// CHECK: define available_externally void @foo_decls()
// CHECK: define available_externally void @foo_decls.sse4.2()
+// CHECK: define available_externally void @foo_multi.avx_sse4.2()
+// CHECK: define available_externally void @foo_multi.fma4_sse4.2()
+// CHECK: define available_externally void @foo_multi.arch_ivybridge_fma4_sse4.2()
+
More information about the cfe-commits
mailing list