Commit Graph

32 Commits

Author SHA1 Message Date
Joel E. Denny 72c2783012 [FileCheck] Add -allow-deprecated-dag-overlap to failing clang tests
See https://reviews.llvm.org/D47106 for details.

Reviewed By: probinson

Differential Revision: https://reviews.llvm.org/D47172

llvm-svn: 336844
2018-07-11 20:26:20 +00:00
Piotr Padlewski e368de364e Add -fforce-emit-vtables
Summary:
 In many cases we can't devirtualize
 because definition of vtable is not present. Most of the
 time it is caused by inline virtual function not beeing
 emitted. Forcing emitting of vtable adds a reference of these
 inline virtual functions.
 Note that GCC was always doing it.

Reviewers: rjmccall, rsmith, amharc, kuhar

Subscribers: llvm-commits, cfe-commits

Differential Revision: https://reviews.llvm.org/D47108

Co-authored-by: Krzysztof Pszeniczny <krzysztof.pszeniczny@gmail.com>
llvm-svn: 334600
2018-06-13 13:55:42 +00:00
Tim Northover 36bb6d5d46 Switch to gnu++14 as the default dialect.
This is C++14 with conforming GNU extensions.

llvm-svn: 320250
2017-12-09 12:09:54 +00:00
Akira Hatanaka 2246167362 [Sema] Mark a virtual CXXMethodDecl as used if a call to it can be
devirtualized.

The code to detect devirtualized calls is already in IRGen, so move the
code to lib/AST and make it a shared utility between Sema and IRGen.

This commit fixes a linkage error I was seeing when compiling the
following code:

$ cat test1.cpp
struct Base {
  virtual void operator()() {}
};

template<class T>
struct Derived final : Base {
  void operator()() override {}
};

Derived<int> *d;

int main() {
  if (d)
    (*d)();
  return 0;
}

rdar://problem/33195657

Differential Revision: https://reviews.llvm.org/D34301

llvm-svn: 307883
2017-07-13 06:08:27 +00:00
Piotr Padlewski d3b1cbd17f Emit available_externally vtables opportunistically
Summary:
We can emit vtable definition having inline function
if they are all emitted.

Reviewers: rjmccall, rsmith

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D33437

llvm-svn: 304394
2017-06-01 08:04:05 +00:00
Chandler Carruth 93786da2cb Make '-disable-llvm-optzns' an alias for '-disable-llvm-passes'.
Much to my surprise, '-disable-llvm-optzns' which I thought was the
magical flag I wanted to get at the raw LLVM IR coming out of Clang
deosn't do that. It still runs some passes over the IR. I don't want
that, I really want the *raw* IR coming out of Clang and I strongly
suspect everyone else using it is in the same camp.

There is actually a flag that does what I want that I didn't know about
called '-disable-llvm-passes'. I suspect many others don't know about it
either. It both does what I want and is much simpler.

This removes the confusing version and makes that spelling of the flag
an alias for '-disable-llvm-passes'. I've also moved everything in Clang
to use the 'passes' spelling as it seems both more accurate (*all* LLVM
passes are disabled, not just optimizations) and much easier to remember
and spell correctly.

This is part of simplifying how Clang drives LLVM to make it cleaner to
wire up to the new pass manager.

Differential Revision: https://reviews.llvm.org/D28047

llvm-svn: 290392
2016-12-23 00:23:01 +00:00
Piotr Padlewski d679d7e924 Generating assumption loads of vptr after ctor call (fixed)
Generating call assume(icmp %vtable, %global_vtable) after constructor
call for devirtualization purposes.

For more info go to:
http://lists.llvm.org/pipermail/cfe-dev/2015-July/044227.html

Edit:
Fixed version because of PR24479 and other bug caused in chrome.
After this patch got reverted because of ScalarEvolution bug (D12719)
Merged after John McCall big patch (Added Address).

http://reviews.llvm.org/D11859
http://reviews.llvm.org/D12865

llvm-svn: 247646
2015-09-15 00:37:06 +00:00
Piotr Padlewski 4bed31b9bf Revert "Generating assumption loads of vptr after ctor call (fixed)"
It seems that there is small bug, and we can't generate assume loads
when some virtual functions have internal visibiliy
This reverts commit 982bb7d966947812d216489b3c519c9825cacbf2.

llvm-svn: 247332
2015-09-10 20:18:30 +00:00
Piotr Padlewski 255652e828 Generating assumption loads of vptr after ctor call (fixed)
Generating call assume(icmp %vtable, %global_vtable) after constructor
call for devirtualization purposes.

For more info go to:
http://lists.llvm.org/pipermail/cfe-dev/2015-July/044227.html

Edit:
Fixed version because of PR24479.
After this patch got reverted because of ScalarEvolution bug (D12719)
Merged after John McCall big patch (Added Address).

http://reviews.llvm.org/D11859

llvm-svn: 247199
2015-09-09 22:20:28 +00:00
Steven Wu 5528da76ef Revert r246214 and r246213
These two commits causes llvm LTO bootstrap to hang in ScalarEvolution.

llvm-svn: 246282
2015-08-28 07:14:10 +00:00
Piotr Padlewski 81461a4350 Assume loads fix #2
There was linker problem, and it turns out that it is not always safe
to refer to vtable. If the vtable is used, then we can refer to it
without any problem, but because we don't know when it will be used or
not, we can only check if vtable is external or it is safe to to emit it
speculativly (when class it doesn't have any inline virtual functions).
It should be fixed in the future.

http://reviews.llvm.org/D12385

llvm-svn: 246214
2015-08-27 21:35:41 +00:00
Piotr Padlewski 525f746710 Generating assumption loads of vptr after ctor call (fixed)
Generating call assume(icmp %vtable, %global_vtable) after constructor
call for devirtualization purposes.

For more info go to:
http://lists.llvm.org/pipermail/cfe-dev/2015-July/044227.html

Edit:
Fixed version because of PR24479.

http://reviews.llvm.org/D11859

llvm-svn: 246213
2015-08-27 21:35:37 +00:00
Piotr Padlewski fa0e11efdd Revert "Generating assumption loads of vptr after ctor call (fixed)"
Reverting because of 245721

This reverts commit 552658e2b60543c928030b09cc9b5dfcb40c3f28.

llvm-svn: 245727
2015-08-21 19:49:41 +00:00
Piotr Padlewski 910a059e42 Generating assumption loads of vptr after ctor call (fixed)
Generating call assume(icmp %vtable, %global_vtable) after constructor
call for devirtualization purposes.

For more info go to:
http://lists.llvm.org/pipermail/cfe-dev/2015-July/044227.html

Edit:
Fixed version because of PR24479.

http://reviews.llvm.org/D11859

llvm-svn: 245721
2015-08-21 18:28:00 +00:00
Piotr Padlewski 1d02f681a9 Generating available_externally vtables bugfix
Bugfix revealed in r245264.

http://reviews.llvm.org/D12128

llvm-svn: 245489
2015-08-19 20:09:09 +00:00
Justin Bogner 3c32c83daa Revert "Generating assumption loads of vptr after ctor call (fixed)"
Bootstrap bots were failing:

http://lab.llvm.org:8080/green/job/clang-stage2-configure-Rlto_build/6382/
http://bb.pgr.jp/builders/clang-3stage-i686-linux/builds/2969

This reverts r245264.

llvm-svn: 245267
2015-08-18 05:40:20 +00:00
Piotr Padlewski bc7497abbb Generating assumption loads of vptr after ctor call (fixed)
Generating call assume(icmp %vtable, %global_vtable) after constructor
call for devirtualization purposes.

For more info go to:
http://lists.llvm.org/pipermail/cfe-dev/2015-July/044227.html

Edit:
Fixed version because of PR24479.

http://reviews.llvm.org/D11859

llvm-svn: 245264
2015-08-18 03:52:00 +00:00
Hans Wennborg 386e442d1d Revert r245257 "Generating assumption loads of vptr after ctor call"
It caused PR24479

llvm-svn: 245260
2015-08-18 00:17:58 +00:00
Piotr Padlewski a3f6f9477b Generating assumption loads of vptr after ctor call
Generating call assume(icmp %vtable, %global_vtable) after constructor
call for devirtualization purposes.

For more info go to:
http://lists.llvm.org/pipermail/cfe-dev/2015-July/044227.html

http://reviews.llvm.org/D11859

llvm-svn: 245257
2015-08-17 23:33:49 +00:00
Piotr Padlewski a68a78751f Generating available_externally vtables for outline virtual functions
Generating available_externally vtables for optimizations purposes.
Unfortunatelly ItaniumABI doesn't guarantee that we will be able to
refer to virtual inline method by name.
But when we don't have any inline virtual methods, and key function is
not defined in this TU, we can generate that there will be vtable and
mark it as available_externally.

This is patch will help devirtualize better.
Differential Revision: http://reviews.llvm.org/D11441

llvm-svn: 243090
2015-07-24 04:04:49 +00:00
John McCall 57420b320c type_info objects are not unnamed_addr: the ABI requires us to
unique them and permits the implementation of dynamic_cast (and
anything else which knows it's working with a complete class
type) to compare their addresses directly.

rdar://16005328

llvm-svn: 201020
2014-02-08 03:26:05 +00:00
Rafael Espindola ff7cea8c1a Don't pass -O0 to clang_cc1, it is the default.
llvm-svn: 189910
2013-09-04 04:12:25 +00:00
Rafael Espindola b8e430d695 Use -O0 in this test too.
llvm-svn: 189884
2013-09-03 23:31:28 +00:00
Rafael Espindola ee6aa0c62e Don't emit an available_externally vtable pointing to linkonce_odr funcs.
This fixes pr13124.

From the discussion at
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2012-June/022606.html
we know that we cannot make funcions in a weak_odr vtable also weak_odr. They
should remain linkonce_odr.

The side effect is that we cannot emit a available_externally vtable unless we
also emit a copy of the function. This also has an issue: If codegen is going
to output a function, sema has to mark it used. Given llvm.org/pr9114, it looks
like sema cannot be more aggressive at marking functions used because
of vtables.

This leaves us with a few unpleasant options:

* Marking functions in vtables used if possible. This sounds a bit sloppy, so
  we should avoid it.
* Producing available_externally vtables only when all the functions in it are
  already used or weak_odr. This would cover cases like

--------------------
struct foo {
  virtual ~foo();
};
struct bar : public foo {
  virtual void zed();
};
void f() {
  foo *x(new bar);
  delete x;
}
void g(bar *x) {
  x->~bar(); // force the destructor to be used
}
--------------------------

and

----------------------------------
template<typename T>
struct bar {
  virtual ~bar();
};
template<typename T>
bar<T>::~bar() {
}

// make the destructor weak_odr instead of linkonce_odr
extern template class bar<int>;

void f() {
  bar<int> *x(new bar<int>);
  delete x;
}
----------------------------

These look like corner cases, so it is unclear if it is worth it.

* And finally: Just nuke this optimization. That is what this patch implements.

llvm-svn: 189852
2013-09-03 21:05:13 +00:00
Stephen Lin 4362261b00 CHECK-LABEL-ify some code gen tests to improve diagnostic experience when tests fail.
llvm-svn: 188447
2013-08-15 06:47:53 +00:00
John McCall 6bd2a89d5a The standard ARM C++ ABI dictates that inline functions are
never key functions.  We did not implement that rule for the
iOS ABI, which was driven by what was implemented in gcc-4.2.
However, implement it now for other ARM-based platforms.

llvm-svn: 173515
2013-01-25 22:31:03 +00:00
Anders Carlsson 43760c3d42 Add another test that we can fully devirtualize now.
llvm-svn: 124988
2011-02-06 20:16:20 +00:00
Anders Carlsson 73f97534b0 Pass a 'ForVTable' flag to GetAddrOfThunk and pass it along to GetOrCreateLLVMFunction so that we
won't assert when building a thunk for an implicit virtual member function that is not marked used.

llvm-svn: 124967
2011-02-05 18:48:55 +00:00
Anders Carlsson 3c23948481 Re-land r124768, with a fix for PR9130.
We now emit everything except unused implicit virtual member functions when building the vtable.

llvm-svn: 124935
2011-02-05 04:35:53 +00:00
Rafael Espindola af5b92e8f7 Revert 124768.
This reopens PR99114, but that one at least can be avoided with an #include.
PR9130 cannot.

llvm-svn: 124780
2011-02-03 06:30:58 +00:00
Anders Carlsson bac84bef65 Don't try to mark virtual members referenced for classes where the key function
is not defined in the current translation unit. Doing so lead to compile errors
such as PR9114.

Instead, when CodeGen is building the vtable, don't try to emit a definition
for functions that aren't marked used in the current translation unit.
Fixes PR9114.

llvm-svn: 124768
2011-02-03 02:08:44 +00:00
Anders Carlsson a03f3a85cb When building with optimizations, emit vtables where the key is not in the
current translation unit as available_externally. 

This helps devirtualize the second example in PR3100, comment 18:

struct S { S() {}; virtual void xyzzy(); };
inline void foo(S *s) { s->xyzzy(); }
void bar() { S s; foo(&s); }

This involved four major changes:

1. In DefineUsedVTables, always mark virtual member functions as referenced for
   non-template classes and class template specializations.
2. In CodeGenVTables::ShouldEmitVTableInThisTU return true if optimizations are
   enabled, even if the key function is not implemented in this translation 
   unit. We don't ever do this for code compiled with -fapple-kext, because we
   don't ever want to devirtualize virtual member function calls in that case.
3. Give the correct linkage for vtables where the key function is not defined.
4. Update the linkage for RTTI structures when necessary.

llvm-svn: 124565
2011-01-30 20:45:54 +00:00