Implement Attribute Target MultiVersioning
authorErich Keane <erich.keane@intel.com>
Mon, 8 Jan 2018 21:34:17 +0000 (21:34 +0000)
committerErich Keane <erich.keane@intel.com>
Mon, 8 Jan 2018 21:34:17 +0000 (21:34 +0000)
commitd09c994ced99a8f84a58449ea3e15ed0020f87da
tree886b7b91bb1fa9a285bc7fd7ffc2ffb570efecee
parent2756c43cf8366998ba1fae7741be78a6ef075bb0
Implement Attribute Target MultiVersioning

GCC's attribute 'target', in addition to being an optimization hint,
also allows function multiversioning. We currently have the former
implemented, this is the latter's implementation.

This works by enabling functions with the same name/signature to coexist,
so that they can all be emitted. Multiversion state is stored in the
FunctionDecl itself, and SemaDecl manages the definitions.
Note that it ends up having to permit redefinition of functions so
that they can all be emitted. Additionally, all versions of the function
must be emitted, so this also manages that.

Note that this includes some additional rules that GCC does not, since
defining something as a MultiVersion function after a usage has been made illegal.

The only 'history rewriting' that happens is if a function is emitted before
it has been converted to a multiversion'ed function, at which point its name
needs to be changed.

Function templates and virtual functions are NOT yet supported (not supported
in GCC either).

Additionally, constructors/destructors are disallowed, but the former is
planned.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322028 91177308-0d34-0410-b5e6-96231b3b80d8
31 files changed:
include/clang/AST/ASTContext.h
include/clang/AST/Decl.h
include/clang/Basic/Attr.td
include/clang/Basic/DiagnosticSemaKinds.td
include/clang/Basic/TargetInfo.h
include/clang/Basic/X86Target.def
include/clang/Sema/Overload.h
lib/AST/ASTContext.cpp
lib/Basic/Targets/X86.cpp
lib/Basic/Targets/X86.h
lib/CodeGen/CodeGenFunction.cpp
lib/CodeGen/CodeGenFunction.h
lib/CodeGen/CodeGenModule.cpp
lib/CodeGen/CodeGenModule.h
lib/Sema/Sema.cpp
lib/Sema/SemaDecl.cpp
lib/Sema/SemaOverload.cpp
lib/Serialization/ASTReaderDecl.cpp
lib/Serialization/ASTWriterDecl.cpp
test/CodeGen/attr-target-mv-func-ptrs.c [new file with mode: 0644]
test/CodeGen/attr-target-mv-va-args.c [new file with mode: 0644]
test/CodeGen/attr-target-mv.c [new file with mode: 0644]
test/CodeGenCXX/attr-target-mv-diff-ns.cpp [new file with mode: 0644]
test/CodeGenCXX/attr-target-mv-func-ptrs.cpp [new file with mode: 0644]
test/CodeGenCXX/attr-target-mv-member-funcs.cpp [new file with mode: 0644]
test/CodeGenCXX/attr-target-mv-modules.cpp [new file with mode: 0644]
test/CodeGenCXX/attr-target-mv-out-of-line-defs.cpp [new file with mode: 0644]
test/CodeGenCXX/attr-target-mv-overloads.cpp [new file with mode: 0644]
test/Sema/attr-target-mv-bad-target.c [new file with mode: 0644]
test/Sema/attr-target-mv.c [new file with mode: 0644]
test/SemaCXX/attr-target-mv.cpp [new file with mode: 0644]