Commit Graph

210211 Commits

Author SHA1 Message Date
Evgeniy Stepanov 93db40a147 Always_inline codegen rewrite.
Current implementation may end up emitting an undefined reference for
an "inline __attribute__((always_inline))" function by generating an
"available_externally alwaysinline" IR function for it and then failing to
inline all the calls. This happens when a call to such function is in dead
code. As the inliner is an SCC pass, it does not process dead code.

Libc++ relies on the compiler never emitting such undefined reference.

With this patch, we emit a pair of
1. internal alwaysinline definition (called F.alwaysinline)
2a. A stub F() { musttail call F.alwaysinline }
  -- or, depending on the linkage --
2b. A declaration of F.

The frontend ensures that F.inlinefunction is only used for direct
calls, and the stub is used for everything else (taking the address of
the function, really). Declaration (2b) is emitted in the case when
"inline" is meant for inlining only (like __gnu_inline__ and some
other cases).

This approach, among other nice properties, ensures that alwaysinline
functions are always internal, making it impossible for a direct call
to such function to produce an undefined symbol reference.

This patch is based on ideas by Chandler Carruth and Richard Smith.

llvm-svn: 247494
2015-09-12 01:07:37 +00:00
Peter Collingbourne e299bc51b6 ubsan: Disable vptr validation on powerpc64.
Should fix sanitizer-ppc64-linux1 bot.

llvm-svn: 247493
2015-09-12 00:08:28 +00:00
Hal Finkel 62cfd01270 Move asserts from PHINode::addIncoming to PHINode::setIncoming*
We had asserts in PHINode::addIncoming to check that the value types matched
the type of the PHI, and that the associated BB was not null. These did not
catch, however, later uses of setIncomingValue and setIncomingBlock (which are
called by addIncoming as well). Moving the asserts to PHINode::setIncoming*
provides better coverage. NFC.

llvm-svn: 247492
2015-09-12 00:08:21 +00:00
Evgeniy Stepanov 67037ee21e Revert "Specify target triple in alwaysinline tests."
Revert "Always_inline codegen rewrite."

Breaks gdb & lldb tests.
Breaks on Fedora 22 x86_64.

llvm-svn: 247491
2015-09-11 23:48:37 +00:00
Adrian Prantl 67a4fc71df dsymutil: Factor out the relocation handling into a RelocationManager (NFC)
llvm-svn: 247490
2015-09-11 23:45:30 +00:00
Alexander Kornienko 541de378ce [clang-tidy] misc-sizeof-container: whitelist std::bitset<>.
It's fine to use sizeof on std::bitset<>, since it doesn't have any external
storage, everything's inside.

llvm-svn: 247489
2015-09-11 22:54:44 +00:00
Richard Smith c8a7eb5939 Add new test file missing from r247486.
llvm-svn: 247488
2015-09-11 22:54:01 +00:00
Rafael Espindola 4340aad144 Start adding support for creating shared libraries.
They are not fully functional yet, but this implements enough support for lld
itself to read them.

With that, delete the .so binary we were using for tests and start eating our
own dog food.

llvm-svn: 247487
2015-09-11 22:42:45 +00:00
Richard Smith 535ff80354 [modules] When picking one of two template declarations as a lookup result,
it's not sufficient to prefer the declaration with more default arguments, or
the one that's visible; they might both be visible, but one of them might have
a visible default argument where the other has a hidden default argument.

llvm-svn: 247486
2015-09-11 22:39:35 +00:00
Alexander Kornienko 2681e7dcd0 [clang-tidy] Fix minor issues in the testing script.
llvm-svn: 247485
2015-09-11 22:38:26 +00:00
Peter Collingbourne cf303a4d8b ubsan: Implement memory permission validation for vtables.
If the pointer passed to the getVtablePrefix function was read from a freed
object, we may end up following pointers into objects on the heap and
printing bogus dynamic type names in diagnostics. However, we know that
vtable pointers will generally only point into memory mapped from object
files, not objects on the heap.

This change causes us to only follow pointers in a vtable if the vtable
and one of the virtual functions it points to appear to have appropriate
permissions (i.e. non-writable, and maybe executable), which will generally
exclude heap pointers.

Only enabled for Linux; this hasn't been tested on FreeBSD, and vtables are
writable on Mac (PR24782) so this won't work there.

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

llvm-svn: 247484
2015-09-11 22:18:35 +00:00
Davide Italiano 983366ab12 [MC] Fix style bugs introduced in r247471. Reported by Rafael Espindola.
llvm-svn: 247483
2015-09-11 22:04:21 +00:00
John McCall 9c52b28003 When comparing two block captures for layout, don't crash
if they have the same alignment and one was 'this'.

Fixes PR24780.

llvm-svn: 247482
2015-09-11 22:00:51 +00:00
Rafael Espindola 1d12ab3db1 Fix handling of _start being undefined.
We were crashing before.

llvm-svn: 247481
2015-09-11 21:44:55 +00:00
Michael Kruse 9d08009dff Merge TempScop into Scop
Summary:
TempScop is basically a holder for AccFuncMap, the dictionary from BasicBlocks to IRAccess lists. We move the list into polly::Scop and remove the polly::TempScop class.

There is one small change in behavior: If ScopInfo finds that its AssumedContext is impossible, it bails out by deleting the Scop object. The TempScop::print (invoked with opt -polly-scops -analyze) cannot print the AccFuncMap anymore as it would with a separate TempScop.

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

llvm-svn: 247480
2015-09-11 21:41:48 +00:00
Zachary Turner 14181dbb57 Fix a thinko causing test logs for crashes to not get written.
llvm-svn: 247479
2015-09-11 21:27:37 +00:00
Rafael Espindola 92b6c15cce Fix a copy and paste error. Sorry about that.
llvm-svn: 247478
2015-09-11 21:26:42 +00:00
Nico Weber b833fd982d Let selector-expr-lvalue.mm actually test something.
I accidentally introduced a bug locally, and noticed that none of the tests
caught it. No longer!

llvm-svn: 247477
2015-09-11 21:24:40 +00:00
Gabor Horvath 7239a32975 [Static Analyzer] Properly cash the configuration option for lambda support.
llvm-svn: 247476
2015-09-11 21:19:39 +00:00
Rafael Espindola 2e9eac13c7 Implement -rpath.
llvm-svn: 247475
2015-09-11 21:18:56 +00:00
Douglas Katzman ae2f358af5 [Shave]: pass -isystem dirs and "-Wa," args to moviAsm
llvm-svn: 247474
2015-09-11 21:13:46 +00:00
Evgeniy Stepanov 6dbfdaa6ab Specify target triple in alwaysinline tests.
This should fix the tests on Windows (failing due to mangling differencies).

llvm-svn: 247473
2015-09-11 21:10:12 +00:00
David Majnemer b54368c1b8 Simplify logic introduced in r247464.
llvm-svn: 247472
2015-09-11 20:55:29 +00:00
Davide Italiano 63cee81c3c [MC] Don't crash on division by zero.
Differential Revision:	http://reviews.llvm.org/D12776

llvm-svn: 247471
2015-09-11 20:47:35 +00:00
Michael Kruse 84bf8a3bc4 Introspect llvm-config --assertion-mode in cmake out-of-tree builds
When compiling Polly without LLVM sources but with system-installed
LLVM, the build process would not honor the LLVM_ENABLE_ASSERTIONS
setting LLVM was compiled with, but effectively assume that it is
switched off when compiling. During unit-tests llvm-lit would still
query the LLVM_ENABLE_ASSERTIONS flag and enable tests which require
assertions. Even if enabled for LLVM, Polly does not output its debug
info and statistics in this this mode such that 7 tests fail.

To fix, we query llvm-config --assertion-mode and if on, enable
assertions as HandleLLVMOptions.cmake would do.

We cannot reliably use HandleLLVMOptions.cmake itself as the host's
LLVM build might have been built using automake and distributions
change file locations (e.g. Debian to
/usr/share/llvm-${VERSION}/cmake/HandleLLVMOptions.cmake).

llvm-svn: 247470
2015-09-11 20:47:14 +00:00
Oleksiy Vyalov b00792e2dc Add missed import lldbtest.
llvm-svn: 247469
2015-09-11 20:46:46 +00:00
Argyrios Kyrtzidis 74bcd21e34 [tooling] In CompileCommand, Expose the 'file' that was associated with the command.
llvm-svn: 247468
2015-09-11 20:43:05 +00:00
Chris Bieneman 744267765c [CMake] [Darwin] Add support for building bootstrap builds with -flto
When building with LTO the bootstrap builds need to depend on libLTO, llvm-ar, and llvm-ranlib, which all need to be passed into the bootstrap build. This functionality only works on Darwin.

llvm-svn: 247467
2015-09-11 20:42:57 +00:00
Anton Yartsev f54d6796e3 [analyzer] Improve behavior if Clang not found.
- Eliminate 'No such file or directory at scan-build line ...' error if '$RealBin/bin/clang' or '$RealBin/clang' directory does not exist.
- Eliminate 'Use of uninitialized value $Clang in concatenation (.) or string at scan-build line ...' error if help is displayed while $Clang was not found.

llvm-svn: 247466
2015-09-11 20:41:09 +00:00
Evgeniy Stepanov 072e83500e Always_inline codegen rewrite.
Current implementation may end up emitting an undefined reference for
an "inline __attribute__((always_inline))" function by generating an
"available_externally alwaysinline" IR function for it and then failing to
inline all the calls. This happens when a call to such function is in dead
code. As the inliner is an SCC pass, it does not process dead code.

Libc++ relies on the compiler never emitting such undefined reference.

With this patch, we emit a pair of
1. internal alwaysinline definition (called F.alwaysinline)
2a. A stub F() { musttail call F.alwaysinline }
  -- or, depending on the linkage --
2b. A declaration of F.

The frontend ensures that F.inlinefunction is only used for direct
calls, and the stub is used for everything else (taking the address of
the function, really). Declaration (2b) is emitted in the case when
"inline" is meant for inlining only (like __gnu_inline__ and some
other cases).

This approach, among other nice properties, ensures that alwaysinline
functions are always internal, making it impossible for a direct call
to such function to produce an undefined symbol reference.

This patch is based on ideas by Chandler Carruth and Richard Smith.

llvm-svn: 247465
2015-09-11 20:29:07 +00:00
David Majnemer 69c3ddc44a [MS ABI] Select an inheritance model in template arguments
We used to only select an inheritance model if the pointer to member was
nullptr.  Instead, select a model regardless of the member pointer's
value.

N.B.  This bug was exposed by making member pointers report true for
isIncompleteType but has been latent since the member pointer scheme's
inception.

llvm-svn: 247464
2015-09-11 20:18:09 +00:00
Devin Coughlin 0123af994e [analyzer] Add -analyzer-config option for function size the inliner considers as large
Add an option (-analyzer-config min-blocks-for-inline-large=14) to control the function
size the inliner considers as large, in relation to "max-times-inline-large". The option
defaults to the original hard coded behaviour, which I believe should be adjustable with
the other inlining settings.

The analyzer-config test has been modified so that the analyzer will reach the
getMinBlocksForInlineLarge() method and store the result in the ConfigTable, to ensure it
is dumped by the debug checker.

A patch by Sean Eveson!

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

llvm-svn: 247463
2015-09-11 20:14:05 +00:00
Argyrios Kyrtzidis 822e2887b9 [Edit] Fix issue with tracking what macro argument inputs have been edited.
This was not working correctly, leading to erroneously rejecting valid edits.

llvm-svn: 247462
2015-09-11 20:09:11 +00:00
Yunzhong Gao 46261a74db Add a non-exiting diagnostic handler for LTO.
This is in order to give LTO clients a chance to do some clean-up before
terminating the process.

llvm-svn: 247461
2015-09-11 20:01:53 +00:00
Zachary Turner 9c7b08e609 XFAIL miscellaneous tests on windows.
llvm.org/pr24778

llvm-svn: 247460
2015-09-11 20:01:24 +00:00
Zachary Turner 3109990048 XFAIL 2 breakpoint tests on Windows.
llvm.org/pr24777

llvm-svn: 247459
2015-09-11 20:00:39 +00:00
Zachary Turner 0df2865083 XFAIL some more tests related to value api
llvm.org/pr24772

llvm-svn: 247458
2015-09-11 20:00:25 +00:00
Zachary Turner db8201f11c XFAIL TestDisassembleBreakpoint.
This is a trivial issue to fix, just marking it for later.
Windows prints function signatures a bit differently, and the
test expects a specific format.

llvm-svn: 247457
2015-09-11 20:00:09 +00:00
Zachary Turner 608cb82e46 XFAIL tests that try to call a function in the inferior.
llvm.org/pr21765

llvm-svn: 247456
2015-09-11 20:00:00 +00:00
Zachary Turner 6e8cbc0ff2 XFAIL some C++ language specific tests on Windows.
http://llvm.org/pr24764

llvm-svn: 247455
2015-09-11 19:59:39 +00:00
Sanjay Patel 41c739b3fa typo; NFC
llvm-svn: 247454
2015-09-11 19:29:18 +00:00
Rafael Espindola 7174dcfb0f Don't make assumptions about the size of the dynamic string table.
It contains pathnames, so it can be different in each machine.

llvm-svn: 247453
2015-09-11 19:12:37 +00:00
Stephane Sezer 9187e73bda Fix a small typo in ObjectFileELF.cpp.
llvm-svn: 247452
2015-09-11 18:56:59 +00:00
Akira Hatanaka aecca041c9 Record function attribute "stackrealign" instead of using backend option
-force-align-stack.

Also, make changes to the driver so that -mno-stack-realign is no longer
an option exposed to the end-user that disallows stack realignment in
the backend.

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

llvm-svn: 247451
2015-09-11 18:55:09 +00:00
Akira Hatanaka bc497c93f5 Use function attribute "stackrealign" to decide whether stack
realignment should be forced.

With this commit, we can now force stack realignment when doing LTO and
do so on a per-function basis. Also, add a new cl::opt option
"stackrealign" to CommandFlags.h which is used to force stack
realignment via llc's command line.

Out-of-tree projects currently using -force-align-stack to force stack
realignment should make changes to attach the attribute to the functions
in the IR.

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

llvm-svn: 247450
2015-09-11 18:54:38 +00:00
Adrian Prantl 660195a792 Fix a typo and make this test stricter.
llvm-svn: 247449
2015-09-11 18:54:34 +00:00
Adrian Prantl 453cdf08a2 Remove an unnecessary check. NFC
llvm-svn: 247448
2015-09-11 18:54:31 +00:00
Adrian Prantl 5d66c6bbb9 Remove a redundant check from CGDebugInfo::shouldOmitDefinition() (NFC).
llvm-svn: 247447
2015-09-11 18:54:28 +00:00
Rafael Espindola 7010776db7 Implement the -dynamic-linker option.
With this dynamic executables can be executed with just ./t instead of
/lib64/ld-2.20.so ./t

llvm-svn: 247446
2015-09-11 18:49:42 +00:00
Adrian Prantl b67dbced9c Cleanup: Get rid of a bunch of unnecessary invocations of internString()
in CGDebugInfo.cpp: MDString::get() copies its arguments.

llvm-svn: 247445
2015-09-11 18:45:02 +00:00