Commit Graph

13 Commits

Author SHA1 Message Date
Dmitry Polukhin 6194d9f5d8 [MSVC2015] dllexport for defaulted special class members
Clang doesn't dllexport defaulted special member function defaulted
inside class but does it if they defaulted outside class. MSVC doesn't
make any distinction where they were defaulted. Also MSVC 2013 and 2015
export different set of members. MSVC2015 doesn't emit trivial defaulted
x-tors but does emit copy assign operator.

Differential revision: http://reviews.llvm.org/D20422

llvm-svn: 270535
2016-05-24 06:37:14 +00:00
David Majnemer fac5243493 [MS ABI] Give linkonce_odr, instead of external_linkage, to certain kinds of static data members
Out-of-line definitions of static data members which have an inline
initializer must get GVA_DiscardableODR linkage instead of
GVA_StrongExternal linkage.

MSVC 2013's behavior is different with respect to this and would cause
link errors if one TU provided a definition while another did not.
MSVC 2015 fixed this bug, making this OK.  Note that the 2015 behavior
is always compatible with 2013: it never produces a strong definition.

This essentially reverts r237787.

llvm-svn: 250757
2015-10-19 23:22:49 +00:00
David Majnemer 6d1780cfb8 [MS ABI] Explicit specialization of static data members are weak
Normally, explicit specializations are treated like strong external
definitions.  However, MSVC treats explicit specializations of static
data members as weak.  MSVC 2013's <regex> implementation has such an
explicit specialization which leads to clang emitting a strong
definition in each translation unit which includes it.  Tweak clang's
linkage calculation to give such entities GVA_StrongODR linkage instead.

This fixes PR24165.

llvm-svn: 242592
2015-07-17 23:36:49 +00:00
Alexey Bataev 15413ea02b [MSVC] Handle out-of-line definition of static data member correctly (fix for http://llvm.org/PR21164), by Alexey Frolov
There are 3 cases of defining static const member:

initialized inside the class, not defined outside the class.
initialized inside the class, defined outside the class.
not initialized inside the class, defined outside the class.
Revision r213304 was supposed to fix the linkage problem of case (1), but mistakenly it made case (2) behave the same.
As a result, out-of-line definition of static data member is not handled correctly.
Proposed patch distinguishes between cases (1) and (2) and allows to properly emit static const members under –fms-compatibility option.

This fixes http://llvm.org/PR21164.
Differential Revision: http://reviews.llvm.org/D9850

llvm-svn: 237787
2015-05-20 11:57:02 +00:00
Rafael Espindola 0d4fb98504 [patch][pr19848] Produce explicit comdats in clang.
The llvm IR until recently had no support for comdats. This was a problem when
targeting C++ on ELF/COFF as just using weak linkage would cause quite a bit of
dead bits to remain on the executable (unless -ffunction-sections,
-fdata-sections and --gc-sections were used).

To fix the problem, llvm's codegen will just assume that any weak or linkonce
that is not in an explicit comdat should be output in one with the same name as
the global.

This unfortunately breaks cases like pr19848 where a weak symbol is not
xpected to be part of any comdat.

Now that we have explicit comdats in the IR, we can finally get both cases
right.

This first patch just makes clang give explicit comdats to GlobalValues where
t is allowed to.

A followup patch to llvm will then stop implicitly producing comdats.

llvm-svn: 225705
2015-01-12 22:13:53 +00:00
Hal Finkel a2347baaec Mark C++ reference parameters as dereferenceable
Because references must be initialized using some evaluated expression, they
must point to something, and a callee can assume the reference parameter is
dereferenceable. Taking advantage of a new attribute just added to LLVM, mark
them as such.

Because dereferenceability in addrspace(0) implies nonnull in the backend, we
don't need both attributes. However, we need to know the size of the object to
use the dereferenceable attribute, so for incomplete types we still emit only
nonnull.

llvm-svn: 213386
2014-07-18 15:52:10 +00:00
Hans Wennborg 56fc62bf01 MS compatibility: always emit dllexported in-class initialized static data members (PR20140)
This makes us emit dllexported in-class initialized static data members (which
are treated as definitions in MSVC), even when they're not referenced.

It also makes their special linkage reflected in the GVA linkage instead of
getting massaged in CodeGen.

Differential Revision: http://reviews.llvm.org/D4563

llvm-svn: 213304
2014-07-17 20:25:23 +00:00
Hans Wennborg dfcb7d6a97 Defer codegen of inline method definitions to the end of current top level declaration
We would previously fail to emit a definition of bar() for the following code:

  struct __declspec(dllexport) S {
    void foo() {
      t->bar();
    }
    struct T {
      void bar() {}
    };
    T *t;
  };

Note that foo() is an exported method, but bar() is not. However, foo() refers
to bar() so we need to emit its definition. We would previously fail to
realise that bar() is used.

By deferring the method definitions until the end of the top level declaration,
we can simply call EmitTopLevelDecl on them and rely on the usual mechanisms
to decide whether the method should be emitted or not.

Differential Revision: http://reviews.llvm.org/D4038

llvm-svn: 210356
2014-06-06 17:36:17 +00:00
Alp Toker 7f07d5f3c0 Remove unused struct from test
This presumably got inadvertently copied from dllimport-members.cpp.

llvm-svn: 209919
2014-05-30 21:07:40 +00:00
Nico Rieck 816607b8bc Make runlines consistent with other dll attribute tests
llvm-svn: 209831
2014-05-29 16:57:34 +00:00
Nico Rieck b4662c3e5a MS ABI: Emit static data members with proper linkage
llvm-svn: 209826
2014-05-29 16:50:46 +00:00
Nick Lewycky 9b46eb8112 Add 'nonnull' parameter or return attribute when producing an llvm pointer type in a function type where the C++ type is a reference. Update the tests.
llvm-svn: 209723
2014-05-28 09:56:42 +00:00
Nico Rieck 755a36f593 IRGen: Add more tests for dll attributes
llvm-svn: 209596
2014-05-25 10:34:16 +00:00