[PATCH] D55527: Normalize GlobalDecls when used with CPUDispatch

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 10 11:53:20 PST 2018


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

Previously, CPUDispatch functionality did some wacky things with
GlobalDecls, which resulted in multiple GlobalDecls having the same
mangled name. This patch corrects this in a few ways:

First, it Moves the emission of CPUDispatch resolvers to the end of the
translation unit.  This is akin to how 'target' multiversioning works,
and permits the resolver emission mechanism to see all possible
FunctionDecls in the TU.

Second, it changes the meaning of the GlobalDecl MultiVersionIndex to
MultiVersionOrdinal.  In the case of CPUSpecific, '0' now means "A call
to a non-present CPUDispatch function".  Other ordinals are the order of
the CPU Name in the attribute source.  In the case of CPUDispatch, '0'
is the resolver function, and other ordinals represent the non-present
CPU-Specific version.

Because of this, the 1:1 relationship between a GlobalDecl and a
Mangled Name is restored. Additionally, it results in functions only
being emitted when necessary, rather than use a variety of hackery to
emit in cases we presume they would be used.


https://reviews.llvm.org/D55527

Files:
  include/clang/AST/GlobalDecl.h
  include/clang/Basic/Attr.td
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  test/CodeGen/attr-cpuspecific.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55527.177580.patch
Type: text/x-patch
Size: 25582 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181210/f9796976/attachment-0001.bin>


More information about the cfe-commits mailing list