[PATCH] D51650: Implement target_clones multiversioning

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 4 11:41:22 PDT 2018


erichkeane created this revision.
erichkeane added reviewers: thiagomacieira, aaron.ballman.

As discussed here: https://lwn.net/Articles/691932/

GCC6.0 adds target_clones multiversioning. This functionality is
an odd cross between the cpu_dispatch and 'target' MV, but is compatible
with neither.

This attribute allows you to list all options, then emits a separately
optimized version of each function per-option (similar to the 
cpu_specific attribute).  It automatically generates a resolver, just
like the other two.

The mangling however, is... ODD to say the least. The mangling format is:
<normal_mangling>.<option string>.<option ordinal>.

However, the 'option ordinal' is where it gets strange. When parsing the
list, 'default' is moved to the end, so "foo,default,bar", foo is 0, bar is 1,
and default is 2.

Otherwise, emission rules should be the same as 'target'.


https://reviews.llvm.org/D51650

Files:
  include/clang/AST/Decl.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/AST/Decl.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/attr-cpuspecific.c
  test/CodeGen/attr-target-clones.c
  test/Misc/pragma-attribute-supported-attributes-list.test
  test/Sema/attr-target-clones.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51650.163880.patch
Type: text/x-patch
Size: 41423 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180904/58286e23/attachment-0001.bin>


More information about the cfe-commits mailing list