Richard Smith [Mon, 20 Oct 2014 23:26:58 +0000 (23:26 +0000)]
Switch C compilations to C11 by default.
This is long-since overdue, and matches GCC 5.0. This should also be
backwards-compatible, because we already supported all of C11 as an extension
in C99 mode.
llvm-svn: 220244
Hans Wennborg [Mon, 20 Oct 2014 23:26:03 +0000 (23:26 +0000)]
Revert "Improve Windows toolchain support for non-standard environments." (r220226)
In environments where PATH was set to point to the VS installation, Clang would
override that by looking in the registry and finding the latest VS installation.
If the environment is set up to point to a VS installation, that should take
precedence.
Reverting this until we can fix it.
llvm-svn: 220243
Quentin Colombet [Mon, 20 Oct 2014 23:13:30 +0000 (23:13 +0000)]
[X86] Fix a bug in the lowering of the mask of VSELECT.
X86 code to lower VSELECT messed a bit with the bits set in the mask of VSELECT
when it knows it can be lowered into BLEND. Indeed, only the high bits need to be
set for those and it optimizes those accordingly.
However, when the mask is a compile time constant, the lowering will be handled
by the generic optimizer and those modifications will generate bad code in the
generic optimizer.
This patch fixes that by preventing the optimization if the VSELECT will be
handled by the generic optimizer.
<rdar://problem/
18675020>
llvm-svn: 220242
Justin Bogner [Mon, 20 Oct 2014 22:47:23 +0000 (22:47 +0000)]
Driver: Consolidate the logic for naming the module crashdump cache
List the module cache we use for crashdumps as a tempfile. This
simplifies how we pick up this directory when generating the actual
crash diagnostic and removes some duplicate logic.
llvm-svn: 220241
Philip Reames [Mon, 20 Oct 2014 22:40:55 +0000 (22:40 +0000)]
Introduce a 'nonnull' metadata on Load instructions.
The newly introduced 'nonnull' metadata is analogous to existing 'nonnull' attributes, but applies to load instructions rather than call arguments or returns. Long term, it would be nice to combine these into a single construct. The value of the load is allowed to vary between successive loads, but null is not a valid value to be loaded by any load marked nonnull.
Reviewed by: Hal Finkel
Differential Revision: http://reviews.llvm.org/D5220
llvm-svn: 220240
Simon Pilgrim [Mon, 20 Oct 2014 22:14:22 +0000 (22:14 +0000)]
[X86] Memory folding for commutative instructions (updated)
This patch improves support for commutative instructions in the x86 memory folding implementation by attempting to fold a commuted version of the instruction if the original folding fails - if that folding fails as well the instruction is 're-commuted' back to its original order before returning.
Updated version of r219584 (reverted in r219595) - the commutation attempt now explicitly ensures that neither of the commuted source operands are tied to the destination operand / register, which was the source of all the regressions that occurred with the original patch attempt.
Added additional regression test case provided by Joerg Sonnenberger.
Differential Revision: http://reviews.llvm.org/D5818
llvm-svn: 220239
Justin Bogner [Mon, 20 Oct 2014 21:47:56 +0000 (21:47 +0000)]
Driver: Name crashdump scripts after the first temp file
In practice there's only ever one temporary output file when
generating a crashdump, but even if there were many iterating over
each and creating a duplicate run script for each one wouldn't make
very much sense.
This updates the behaviour to only generate the script once, based on
the first filename.
This should make it more reasonable to generate extra output files to
include in the crashdump going forward, so I've also added a FIXME to
look into doing just that with the extra module crashdump files.
llvm-svn: 220238
Rafael Espindola [Mon, 20 Oct 2014 21:37:38 +0000 (21:37 +0000)]
Explain why we don't always use --gc-sections.
llvm-svn: 220237
Tim Northover [Mon, 20 Oct 2014 21:28:41 +0000 (21:28 +0000)]
ARM: rework Thumb1 frame index rewriting
The previous code had a few problems, motivating the choices here.
1. It could create instructions clobbering CPSR, but the incoming MachineInstr
didn't reflect this. A potential source of corruption. This is why the patch
has a new PseudoInst for before lowering.
2. Similarly, there was some code to handle the incoming instruction not being
ARMCC::AL, but this would have caused massive problems if it was actually
invoked when a complex offset needing more than one instruction was requested.
3. It wasn't designed to handle unaligned pointers (or offsets). These should
probably be minimised anyway, but the code needs to deal with them properly
regardless.
4. It had some rather dubious ad-hoc code to avoid calling
emitThumbRegPlusImmediate, a function which should be designed to do precisely
this job.
We seem to cover the common cases correctly now, and hopefully can enhance
emitThumbRegPlusImmediate to handle any extra optimisations we need to add in
future.
llvm-svn: 220236
Justin Bogner [Mon, 20 Oct 2014 21:20:27 +0000 (21:20 +0000)]
Driver: Use an early return instead of a long if condition (NFC)
This just flattens an if block by returning early on the "else"
condition.
llvm-svn: 220235
Justin Bogner [Mon, 20 Oct 2014 21:02:05 +0000 (21:02 +0000)]
Driver: Make FailingCommand mandatory for generateCompilationDiagnostics
We currently use a null FailingCommand when generating crash reports
as an indication that the cause is FORCE_CLANG_DIAGNOSTICS_CRASH, the
environment variable that exists to test crash dumps. This means that
our tests don't actually cover real crashes at all, and adds a more
complicated code path that's only used in the tests.
Instead, we can have the driver synthesize that every command failed
and just call generateCompilationDiagnostics normally.
llvm-svn: 220234
Alexey Samsonov [Mon, 20 Oct 2014 20:41:21 +0000 (20:41 +0000)]
Try to fix GCC error about invalid use of const_cast in const version of ErrorOr::get()
llvm-svn: 220233
Alexey Samsonov [Mon, 20 Oct 2014 20:33:20 +0000 (20:33 +0000)]
Constify getELFDynamicSymbolIterators standalone function. NFC.
llvm-svn: 220232
Alexey Samsonov [Mon, 20 Oct 2014 20:32:47 +0000 (20:32 +0000)]
Add const version of OwningBinary::getBinary
llvm-svn: 220231
Alexey Samsonov [Mon, 20 Oct 2014 20:30:57 +0000 (20:30 +0000)]
Be more specific about return type of MachOUniversalBinary::getObjectForArch
llvm-svn: 220230
David Blaikie [Mon, 20 Oct 2014 20:29:35 +0000 (20:29 +0000)]
Fix whitespace introduced in r220221
Post commit review feedback from Yaron Keren.
llvm-svn: 220229
Alexey Samsonov [Mon, 20 Oct 2014 20:28:51 +0000 (20:28 +0000)]
Constify input argument of RelocVisitor and DWARFContext constructors. NFC.
llvm-svn: 220228
Dan Liew [Mon, 20 Oct 2014 20:14:28 +0000 (20:14 +0000)]
Teach Lit to catch OSError exceptions when creating a process during the
execution of a shell command. This can happen for example if the
``RUN:`` line calls a python script which can work correctly under
Linux/OSX but will not work under Windows. A more useful error message
is now shown rather than an unhelpful backtrace.
llvm-svn: 220227
Zachary Turner [Mon, 20 Oct 2014 20:08:04 +0000 (20:08 +0000)]
Improve Windows toolchain support for non-standard environments.
Typically clang finds Visual Studio by the user explicitly setting
up a Visual Studio environment via vcvarsall. But we still try to
behave intelligently and fallback to different methods of finding
Visual Studio when this is not done. This patch improves various
fallback codepaths to make Visual Studio locating more robust.
Specifically, this patch:
* Adds support for searching environment variables for VS 12.0
* Correctly locates include folders for Windows SDK 8.x (this was
previously broken, and would cause clang to error)
* Prefers locating link.exe in the same location as cl.exe. This
is helpful in case another link.exe is in the path earlier than
Visual Studio (e.g. GnuWin32)
* Minor cleanup in the registry reading code to make it more
robust in the presence of long pathnames.
llvm-svn: 220226
Robert Khasanov [Mon, 20 Oct 2014 19:25:05 +0000 (19:25 +0000)]
Moved out IIT_V64 from common values section.
Thanks Juergen Ributzka for notice.
llvm-svn: 220224
David Blaikie [Mon, 20 Oct 2014 18:56:54 +0000 (18:56 +0000)]
PR21312: Fix a regression in non-type template parameters of function type that are static member functions.
llvm-svn: 220221
Sean Callanan [Mon, 20 Oct 2014 18:36:58 +0000 (18:36 +0000)]
Don't allow the expression parser to magically
look through 'self' at its ivars. It produces
surprising results.
<rdar://problem/
18698760>
llvm-svn: 220220
Ed Maste [Mon, 20 Oct 2014 18:12:46 +0000 (18:12 +0000)]
Skip dsym test on !Darwin
r219978 fixed this test to work on Darwin, and removed the expected
failure decorator, but it then started running (and failing) on FreeBSD.
I'd think @dsym_test should skip the test on all non-Darwin operating
systems. It seems not to be the case, so for now skip it the same way as
done for other @dsym_test tests.
llvm-svn: 220219
Zachary Turner [Mon, 20 Oct 2014 17:46:56 +0000 (17:46 +0000)]
Don't use mkstemp, as it doesn't exist on Windows.
Differential Revision: http://reviews.llvm.org/D5849
Reviewed by: Jason Molenda
llvm-svn: 220218
Zachary Turner [Mon, 20 Oct 2014 17:46:43 +0000 (17:46 +0000)]
Remove LLDB_DEFAULT_SHELL #define, and determine this at runtime.
Differential Revision: http://reviews.llvm.org/D5805
Reviewed by: Greg Clayton
llvm-svn: 220217
David Blaikie [Mon, 20 Oct 2014 17:42:23 +0000 (17:42 +0000)]
Fix indentation.
llvm-svn: 220216
Hal Finkel [Mon, 20 Oct 2014 17:32:04 +0000 (17:32 +0000)]
Add RestrictQualifierLoc to DeclaratorChunk::FunctionTypeInfo
Clang supports __restrict__ as a function qualifier, but
DeclaratorChunk::FunctionTypeInfo lacked a field to track the qualifier's
source location (as we do with volatile, etc.). This was the subject of a FIXME
in GetFullTypeForDeclarator (in SemaType.cpp). This should also prove useful as
we add more warnings regarding questionable uses of the restrict qualifier.
There is no significant functional change (except for an improved source range
associated with the err_invalid_qualified_function_type diagnostic fixit
generated by GetFullTypeForDeclarator).
llvm-svn: 220215
Ben Langmuir [Mon, 20 Oct 2014 16:27:32 +0000 (16:27 +0000)]
Revert most of r215810, which is no longer needed
Now that we no longer add mappings when there are no local entities,
there is no need to always bump the size of the tables that correspond
to ContinuousRangeMaps.
llvm-svn: 220208
Ben Langmuir [Mon, 20 Oct 2014 16:27:30 +0000 (16:27 +0000)]
Don't add ID mappings for offsets with no entities in a module
This is a better fix for 'duplicate key' problems in module continuous
range maps (vs what I added in r215810) by not adding any mappings at
all when there are no local entities. Now it also covers selectors,
which were not always being bumped because the record SELECTOR_OFFSET is
not always emitted. I'll back out most of r215810 in a future commit,
since it should no longer be needed.
llvm-svn: 220207
Gerolf Hoflehner [Mon, 20 Oct 2014 16:08:33 +0000 (16:08 +0000)]
[AArch64] test case for compfail fixed by r219748
llvm-svn: 220206
Steven Wu [Mon, 20 Oct 2014 15:47:24 +0000 (15:47 +0000)]
Fix Intrinsic::getType not working with vararg
VarArg Intrinsic functions are encoded with "void" type as the last
argument. Now Intrinsic::getType can correctly return all the intrinsic
function type.
llvm-svn: 220205
Oliver Stannard [Mon, 20 Oct 2014 15:37:35 +0000 (15:37 +0000)]
[Thumb2] RFE, SRS and "SUBS pc, lr" are undefined on v7M
These instructions are related to the v7[AR] exception model, and are
not defined on v7M.
llvm-svn: 220204
Dan Albert [Mon, 20 Oct 2014 15:35:01 +0000 (15:35 +0000)]
Fix checks for Android.
__ANDROID__ is a define that comes from the toolchain when building
for Android targets. ANDROID has a different meaning. ANDROID is
defined for _every_ Android build, including those done for host
modules. For host modules, we want to build the regular Linux
sanitizers and builtins, not the one for Android devices. This hasn't
been a problem until now because we only just started building the
sanitizers for the host.
llvm-svn: 220203
Daniel Jasper [Mon, 20 Oct 2014 13:56:30 +0000 (13:56 +0000)]
clang-format: Fix overloaded operator edge case.
Before:
template <class F>
void Call(F f) {
f.template operator() <int>();
}
After:
template <class F>
void Call(F f) {
f.template operator()<int>();
}
llvm-svn: 220202
Artyom Skrobov [Mon, 20 Oct 2014 13:48:19 +0000 (13:48 +0000)]
D5823: Fix typo in Clang test arm-cortex-cpus.c; patch by Gabor Ballabas!
llvm-svn: 220201
Sid Manning [Mon, 20 Oct 2014 13:08:19 +0000 (13:08 +0000)]
Remove unnecessary else.
llvm-svn: 220200
Alexander Kornienko [Mon, 20 Oct 2014 12:29:15 +0000 (12:29 +0000)]
[clang-tidy] Add support for custom configuration file names/formats.
Summary: We're using different clang-tidy frontends (command-line, batch analysis jobs, code review integration), some of which are limited in the choice of configuration format. In order to avoid duplication of configuration information, we need to support the same configuration format in the command-line tool. This patch adds an extension point to make this possible without rewriting FileOptionsProvider.
Reviewers: djasper
Reviewed By: djasper
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D5821
llvm-svn: 220199
NAKAMURA Takumi [Mon, 20 Oct 2014 12:12:21 +0000 (12:12 +0000)]
Revert r220174, "Always use -Wl,-gc-sections on our build."
It dropped required functions for plugins with gnu ld 2.20 and 2.21.
Failing Tests (1):
LLVM :: Feature/load_module.ll
Hello: bin/opt: symbol lookup error: lib/LLVMHello.so: undefined symbol: _ZN4llvm11raw_ostream13write_escapedENS_9StringRefEb
Failing Tests (1):
Clang :: Frontend/plugins.c
error: unable to load plugin 'lib/PrintFunctionNames.so': 'lib/PrintFunctionNames.so: undefined symbol: _ZN5clang15PluginASTAction6anchorEv'
I think we should inspect linker's version or behavior to introduce --gc-sections for --export-dynamic.
llvm-svn: 220198
Daniel Jasper [Mon, 20 Oct 2014 12:01:45 +0000 (12:01 +0000)]
clang-format: [ObjC] Fix using selector names as macro arguments.
Before:
[self aaaaa:MACRO(a, b :, c :)];
After:
[self aaaaa:MACRO(a, b:, c:)];
llvm-svn: 220197
Oliver Stannard [Mon, 20 Oct 2014 11:30:35 +0000 (11:30 +0000)]
[ARM] Do not select SMULW[BT] or SMLAW[BT]
The current instruction selection patterns for SMULW[BT] and SMLAW[BT]
are incorrect. These instructions multiply a 32-bit and a 16-bit value
(both signed) and return the top 32 bits of the 48-bit result. This
preserves the 16 bits of overflow, whereas the patterns they currently
match truncate the result to 16 bits then sign extend.
To select these instructions, we would need to match an ISD::SMUL_LOHI,
a sign extend, two shifts and an or. There is no way to match SMUL_LOHI
in an instruction pattern as it defines multiple values, so this would
have to be done in C++. I have raised
http://llvm.org/bugs/show_bug.cgi?id=21297 to cover allowing correct
selection of these instructions.
This fixes http://llvm.org/bugs/show_bug.cgi?id=19396
llvm-svn: 220196
Daniel Jasper [Mon, 20 Oct 2014 11:12:51 +0000 (11:12 +0000)]
clang-format: Fix indentation of struct definitions with array init.
Before:
struct {
int x;
int y;
} points[] = {
{1, 2}, {2, 3},
};
After:
struct {
int x;
int y;
} points[] = {
{1, 2}, {2, 3},
};
llvm-svn: 220195
Oliver Stannard [Mon, 20 Oct 2014 11:00:18 +0000 (11:00 +0000)]
[Thumb] Fix crash in Thumb1RegisterInfo::rewriteFrameIndex
This function can, for some offsets from the SP, split one instruction
into two. Since it re-uses the original instruction as the first
instruction of the result, we need ensure its result register is not
marked as dead before we use it in the second instruction.
llvm-svn: 220194
Chandler Carruth [Mon, 20 Oct 2014 10:41:29 +0000 (10:41 +0000)]
Switch the default DataLayout to be little endian, and make the variable
be BigEndian so the default can continue to be zero-initialized.
This is one of the prerequisites to making DataLayout a constant and
always available part of every module.
llvm-svn: 220193
Chandler Carruth [Mon, 20 Oct 2014 10:35:11 +0000 (10:35 +0000)]
Remove some completely superfluous trailing comments and clang-format
this header to remove numerous formatting inconsistencies that impede
making simple changes here without large diffs.
llvm-svn: 220192
Chandler Carruth [Mon, 20 Oct 2014 10:27:53 +0000 (10:27 +0000)]
Clean up the comments and doxygen for DataLayout.
llvm-svn: 220191
Chandler Carruth [Mon, 20 Oct 2014 10:03:01 +0000 (10:03 +0000)]
Fix a miscompile introduced in r220178.
The original code had an implicit assumption that if the test for
allocas or globals was reached, the two pointers were not equal. With my
changes to make the pointer analysis more powerful here, I also had to
guard against circumstances where the results weren't useful. That in
turn violated the assumption and gave rise to a circumstance in which we
could have a store with both the queried pointer and stored pointer
rooted at *the same* alloca. Clearly, we cannot ignore such a store.
There are other things we might do in this code to better handle the
case of both pointers ending up at the same alloca or global, but it
seems best to at least make the test explicit in what it intends to
check.
I've added tests for both the alloca and global case here.
llvm-svn: 220190
Evgeny Astigeevich [Mon, 20 Oct 2014 09:15:05 +0000 (09:15 +0000)]
Commit to test commit access
llvm-svn: 220189
David Majnemer [Mon, 20 Oct 2014 06:13:36 +0000 (06:13 +0000)]
CodeGen: Update for LLVM API change
Callers of DataLayout::RoundUpAlignment should switch to
RoundUpToAlignment.
llvm-svn: 220188
David Majnemer [Mon, 20 Oct 2014 06:13:33 +0000 (06:13 +0000)]
IR: Replace DataLayout::RoundUpAlignment with RoundUpToAlignment
No functional change intended, just cleaning up some code.
llvm-svn: 220187
Chandler Carruth [Mon, 20 Oct 2014 05:34:36 +0000 (05:34 +0000)]
Fix a somewhat subtle pair of issues with JumpThreading I introduced in
r220178. First, the creation routine doesn't insert prior to the
terminator of the basic block provided, but really at the end of the
basic block. Instead, get the terminator and insert before that. The
next issue was that we need to ensure multiple PHI node entries for
a single predecessor re-use the same cast instruction rather than
creating new ones.
All of the logic here was without tests previously. I've reduced and
added a test case from the test suite that crashed without both of these
fixes.
llvm-svn: 220186
Shankar Easwaran [Mon, 20 Oct 2014 05:33:42 +0000 (05:33 +0000)]
[ELF] Add demangle test to XFAIL
This test is failing for some reason on freebsd.
Not sure why it should fail, need to investigate.
llvm-svn: 220185
Shankar Easwaran [Mon, 20 Oct 2014 05:04:53 +0000 (05:04 +0000)]
[ELF] Implement demangle.
This adds functionality in the GNU flavor to demangle symbols when
undefined symbols are displayed to the user.
llvm-svn: 220184
Lang Hames [Mon, 20 Oct 2014 04:26:23 +0000 (04:26 +0000)]
[PBQP] Use DenseSet rather than std::set for PBQP's PoolCostAllocator
implementation.
This is good for a ~6% reduction in total compile time on the nightly test suite
when running with -regalloc=pbqp.
llvm-svn: 220183
Shankar Easwaran [Mon, 20 Oct 2014 04:00:26 +0000 (04:00 +0000)]
[ELF] Check for target architecture.
The canParse function for all the ELF subtargets check if the input files match
the subtarget.
There were few mismatches in the input files that didnt match the subtarget for
which the link was being invoked, which also acts as a test for this change.
llvm-svn: 220182
Todd Fiala [Mon, 20 Oct 2014 03:56:46 +0000 (03:56 +0000)]
Fix 4 failing llgs-related tests on a stock Ubuntu 14.04 x86_64 system./
This fix addresses a requirement on some Linux kernels that limits
a PTRACER to be an ancestor of the ptraced process. The fix in this
case is to have the inferior test exe explicitly allow any ptracer
to attach.
This fixes several ptrace-related issues that I did not see on a modified
kernel we used internally on my team.
See http://reviews.llvm.org/D5846 for details.
This fixes these previously failing tests on stock Ubuntu systems:
FAIL: LLDB (suite) :: TestGdbRemoteProcessInfo.py (Linux vagrant 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 x86_64 x86_64)
FAIL: LLDB (suite) :: TestGdbRemoteAttach.py (Linux vagrant 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 x86_64 x86_64)
FAIL: LLDB (suite) :: TestLldbGdbServer.py (Linux vagrant 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 x86_64 x86_64)
FAIL: LLDB (suite) :: TestGdbRemoteKill.py (Linux vagrant 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 x86_64 x86_64)
llvm-svn: 220181
Shankar Easwaran [Mon, 20 Oct 2014 03:03:43 +0000 (03:03 +0000)]
[ELF] Make updateReferenceForMergeStringAccess virtual.
The ELF subtargets would usually want to override the function
updateReferenceForMergeStringAccess. Allow this by making it virtual.
llvm-svn: 220180
Shankar Easwaran [Mon, 20 Oct 2014 02:59:06 +0000 (02:59 +0000)]
[ELF] Fix functionality of merging similar strings.
For PC relative accesses, negative addends were to be ignored. The linker was
not ignoring it and would fail with an assert. This fixes the issue and is able
to get Helloworld working.
llvm-svn: 220179
Chandler Carruth [Mon, 20 Oct 2014 00:24:14 +0000 (00:24 +0000)]
Teach the load analysis driving core instcombine logic and other bits of
logic to look through pointer casts, making them trivially stronger in
the face of loads and stores with intervening pointer casts.
I've included a few test cases that demonstrate the kind of folding
instcombine can do without pointer casts and then variations which
obfuscate the logic through bitcasts. Without this patch, the variations
all fail to optimize fully.
This is more important now than it has been in the past as I've started
moving the load canonicialization to more closely follow the value type
requirements rather than the pointer type requirements and thus this
needs to be prepared for more pointer casts. When I made the same change
to stores several test cases regressed without logic along these lines
so I wanted to systematically improve matters first.
llvm-svn: 220178
Richard Smith [Mon, 20 Oct 2014 00:15:49 +0000 (00:15 +0000)]
[modules] Add support for #include_next.
#include_next interacts poorly with modules: it depends on where in the list of
include paths the current file was found. Files covered by module maps are not
found in include search paths when building the module (and are not found in
include search paths when @importing the module either), so this isn't really
meaningful. Instead, we fake up the result that #include_next *should* have
given: find the first path that would have resulted in the given file being
picked, and search from there onwards.
llvm-svn: 220177
Chandler Carruth [Mon, 20 Oct 2014 00:11:31 +0000 (00:11 +0000)]
Add a datalayout string to this test so that it exercises the full gamut
of InstCombine rather than just the bits enabled when datalayout is
optional.
The primary fixes here are because now things are little endian.
In good news, silliness like this seems like it will be going away as
we've got pretty stong consensus on dropping optional datalayout
entirely.
llvm-svn: 220176
David Majnemer [Sun, 19 Oct 2014 23:40:06 +0000 (23:40 +0000)]
CodeGen: ConstStructBuilder must verify packed constraints after padding
This reverts commit r220169 which reverted r220153. However, it also
contains additional changes:
- We may need to add padding *after* we've packed the struct. This
occurs when the aligned next field offset is greater than the new
field's offset. When this occurs, we make the struct packed.
*However*, once packed the next field offset might be less than the
new feild's offset. It is in this case that we might further pad the
struct.
- We would pad structs which were perfectly sized! This behavior is
immensely old. This behavior came from blindly subtracting
NextFieldOffsetInChars from RecordSize. This doesn't take into
account the fact that the struct might have a greater overall
alignment than the last field.
llvm-svn: 220175
Rafael Espindola [Sun, 19 Oct 2014 23:24:46 +0000 (23:24 +0000)]
Always use -Wl,-gc-sections on our build.
Both bfd ld and gold correctly handle --export-dynamic, so gc-sections is safe even for binaries
that support plugins.
llvm-svn: 220174
Bill Schmidt [Sun, 19 Oct 2014 21:29:21 +0000 (21:29 +0000)]
[PowerPC] Clean up -mattr=+vsx tests to always specify -mcpu
We recently discovered an issue that reinforces what a good idea it is
to always specify -mcpu in our code generation tests, particularly for
-mattr=+vsx. This patch ensures that all tests that specify
-mattr=+vsx also specify -mcpu=pwr7 or -mcpu=pwr8, as appropriate.
Some of the uses of -mattr=+vsx added recently don't make much sense
(when specified for -mtriple=powerpc-apple-darwin8 or -march=ppc32,
for example). For cases like this I've just removed the extra VSX
test commands; there's enough coverage without them.
llvm-svn: 220173
Bill Schmidt [Sun, 19 Oct 2014 20:48:47 +0000 (20:48 +0000)]
[PowerPC] Temporarily disable VSX for PowerPC fast-isel tests
Patch by Bill Seurer; some comment formatting changes by me.
There are a few PowerPC test cases for FastISel support that currently
fail with VSX support enabled. The temporary workaround under
discussion in http://reviews.llvm.org/D5362 helps, but the tests still
fail because they specify -fast-isel-abort, and the VSX workaround
punts back to SelectionDAG. We have plans to fix FastISel permanently
for VSX, but until that's in place these tests are preventing us from
enabling VSX by default. Therefore we are adding -mattr=-vsx to these
tests until the full support is ready.
llvm-svn: 220172
Bill Schmidt [Sun, 19 Oct 2014 20:27:56 +0000 (20:27 +0000)]
[PowerPC] Re-enable VSX test line for fma.ll with -mcpu=pwr7
The VSX testing variant in test/CodeGen/PowerPC/fma.ll had to be
disabled because of unexpected behavior on many of the builders. I
tracked this down to a situation that occurs when the VSX attribute is
enabled for a target that disables the MI early scheduling pass. This
patch adds -mcpu=pwr7 to make this predictable. The other issue will
be addressed separately.
llvm-svn: 220171
NAKAMURA Takumi [Sun, 19 Oct 2014 19:58:33 +0000 (19:58 +0000)]
Preprocessor.h: Suppress a warning in SkipMainFilePreamble. [-Wsign-compare]
llvm-svn: 220170
Chandler Carruth [Sun, 19 Oct 2014 19:41:46 +0000 (19:41 +0000)]
Revert r220153: "CodeGen: ConstStructBuilder must verify packed constraints after padding"
This commit caused two tests in LNT to regress. I'm able to reproduce on
any platform and will send reproduction steps to the original commit
log. This should restore the LNT bots that have been failing.
llvm-svn: 220169
Lang Hames [Sun, 19 Oct 2014 19:36:33 +0000 (19:36 +0000)]
[ADT] Add a 'find_as' operation to DenseSet.
This operation is analogous to its counterpart in DenseMap: It allows lookup
via cheap-to-construct keys (provided that getHashValue and isEqual are
implemented for the cheap key-type in the DenseMapInfo specialization).
Thanks to Chandler for the review.
llvm-svn: 220168
Chandler Carruth [Sun, 19 Oct 2014 19:13:49 +0000 (19:13 +0000)]
[complex] Teach the complex math IR gen to emit direct math and
a NaN-test prior to the call to the library function.
This should automatically make fastmath (including just non-NaNs) able to avoid
the expensive libcalls and also open the door to more advanced folding in LLVM
based on the rules for complex math.
Two important notes to remember: first is that this isn't yet a proper
limited range mode, it's still just improving the unlimited range mode.
Also, it isn't really perfecet w.r.t. what an unlimited range mode
should be doing because it isn't quite handling the flags produced by
all the operations in the way desirable for that mode, but then neither
is compiler-rt's libcall. When the compiler-rt libcall is improved to
carefully manage flags, the code emitted here should be improved
correspondingly. And it is still a long-term desirable thing to add
a limited range mode to Clang that would be able to use direct math
without library calls here.
Special thanks to Steve Canon for the careful review on this patch and
teaching me about these issues. =D
Differential Revision: http://reviews.llvm.org/D5756
llvm-svn: 220167
NAKAMURA Takumi [Sun, 19 Oct 2014 18:45:13 +0000 (18:45 +0000)]
clang/test/Layout/itanium-union-bitfield.cpp: Appease i686.
llvm-svn: 220166
Chandler Carruth [Sun, 19 Oct 2014 10:46:46 +0000 (10:46 +0000)]
Do a better and more complete job of preserving metadata when combining
loads.
This handles many more cases than just the AA metadata, some of them
suggested by Hal in his review of the AA metadata handling patch. I've
tried to test this behavior where tractable to do so.
I'll point out that I have specifically *not* included a test for
debuginfo because it was going to require 2 or 3 times as much work to
craft some input which would survive the "helpful" stripping of debug
info metadata that doesn't match the desired schema. This is another
good example of why the current state of write-ability for our debug
info metadata is unacceptable. I spent over 30 minutes trying to conjure
some test case that would survive, even copying from other debug info
tests, but it always failed to survive with no explanation of why or how
I might fix it. =[
llvm-svn: 220165
Chandler Carruth [Sun, 19 Oct 2014 09:06:56 +0000 (09:06 +0000)]
Move previously dead code to handle computing the known bits of an alias
up to where it actually works as intended. The problem is that
a GlobalAlias isa GlobalValue and so the prior block handled all of the
cases.
This allows us to constant fold based on the actual constant expression
in the global alias. As an example, see the last function in the newly
added test case which explicitly aligns an unaligned pointer using
constant expression math. Without this change, we fail to see that and
fold an alignment test to zero.
llvm-svn: 220164
David Majnemer [Sun, 19 Oct 2014 08:32:32 +0000 (08:32 +0000)]
InstCombine: (sub (or A B) (xor A B)) --> (and A B)
The following implements the transformation:
(sub (or A B) (xor A B)) --> (and A B).
Patch by Ankur Garg!
Differential Revision: http://reviews.llvm.org/D5719
llvm-svn: 220163
David Majnemer [Sun, 19 Oct 2014 08:23:08 +0000 (08:23 +0000)]
InstCombine: Optimize icmp eq/ne (shl Const2, A), Const1
The following implements the optimization for sequences of the form:
icmp eq/ne (shl Const2, A), Const1
Such sequences can be transformed to:
icmp eq/ne A, (TrailingZeros(Const1) - TrailingZeros(Const2))
This handles only the equality operators for now. Other operators need
to be handled.
Patch by Ankur Garg!
llvm-svn: 220162
Chandler Carruth [Sun, 19 Oct 2014 08:17:50 +0000 (08:17 +0000)]
Fix a long-standing miscompile in the load analysis that was uncovered
by my refactoring of this code.
The method isSafeToLoadUnconditionally assumes that the load will
proceed with the preferred type alignment. Given that, it has to ensure
that the alloca or global is at least that aligned. It has always done
this historically when a datalayout is present, but has never checked it
when the datalayout is absent. When I refactored the code in r220156,
I exposed this path when datalayout was present and that turned the
latent bug into a patent bug.
This fixes the issue by just removing the special case which allows
folding things without datalayout. This isn't worth the complexity of
trying to tease apart when it is or isn't safe without actually knowing
the preferred alignment.
llvm-svn: 220161
Ted Kremenek [Sun, 19 Oct 2014 07:30:55 +0000 (07:30 +0000)]
[analyzer] Tweak MallocSizeOfChecker to not warn when using sizeof(void*) to allocate a bunch of any pointer type.
This suppresses a common false positive when analyzing libc++.
Along the way, introduce some tests to show this checker actually
works with C++ static_cast<>.
llvm-svn: 220160
Shankar Easwaran [Sun, 19 Oct 2014 03:28:13 +0000 (03:28 +0000)]
[ELF][Cleanup] Remove unused code.
The old code was used as a workaround to fix how relocations are calculated for
sections with SHF_MERGE|SHF_STRINGS attribute. This patch removes the erroneous
code.
llvm-svn: 220159
Bob Wilson [Sun, 19 Oct 2014 02:19:27 +0000 (02:19 +0000)]
Use the triple's isiOS() method instead of checking the value directly. NFC.
llvm-svn: 220158
Eric Fiselier [Sun, 19 Oct 2014 00:42:41 +0000 (00:42 +0000)]
[libcxx] Redo adding support for building and testing with an ABI library not along linker paths
Summary:
This is the second attempt at allowing for the use of libraries that the linker cannot find. The first attempt used `CMAKE_LIBRARY_PATH` and `find_library` to select which ABI library should be used. There were a number of problems with this approach:
- `find_library` didn't work with cmake targets (ie in-tree libcxxabi build)
- It wasn't always possible to determine where `find_library` actually found your library.
- `target_link_libraries` inserted the path of the ABI library into libc++'s RPATH when `find_library` was used.
- Linking libc++ and it's ABI library is a special case. It's a lot easier to keep it simple.
After discussion with @cbergstrum a new approach was decided upon.
This patch achieve the same ends by simply using `LIBCXX_CXX_ABI_LIBRARY_PATH` to specify where to find the library (if the linker won't find it). When this variable is defined it is simply added as a library search path when linking libc++. It is a lot easier to duplicate this behavior in LIT. It also prevents libc++ from being linked with an RPATH.
Reviewers: mclow.lists, cbergstrom, chandlerc, danalbert
Reviewed By: chandlerc, danalbert
Subscribers: chandlerc, cfe-commits
Differential Revision: http://reviews.llvm.org/D5860
llvm-svn: 220157
Chandler Carruth [Sun, 19 Oct 2014 00:42:16 +0000 (00:42 +0000)]
Switch how the datalayout availability test is handled in this code to
make much more sense and in theory be more correct.
If you trace the code alllll the way back to when it was first
introduced, the comments make it slightly more clear what was going on
here. At that time, the only way Base != V was if DL (then TD) was
non-null. As a consequence, if DL *was* null, that meant we were loading
directly from the alloca or global found above the test. After
refactoring, this has become at least terribly subtle and potentially
incorrect. There are many forms of pointer manipulation that can be
traversed without DataLayout, and some of them would in fact change the
size of object being loaded vs. allocated.
Rather than this subtlety, I've hoisted the actual 'return true' bits
into the code which actually found an alloca or global and based them on
the loaded pointer being that alloca or global. This is both more clear
and safer. I've also added comments about exactly why this set of
predicates is used.
I've also corrected a misleading comment about globals -- if overridden
they may not just have a different size, they may be null and completely
unsafe to load from!
Hopefully this confuses the next reader a bit less. I don't have any
test cases or anything, the patch is motivated strictly to improve the
readability of the code.
llvm-svn: 220156
Bob Wilson [Sun, 19 Oct 2014 00:39:30 +0000 (00:39 +0000)]
Use triple predicate functions instead of checking values directly. NFC.
llvm-svn: 220155
Eric Fiselier [Sun, 19 Oct 2014 00:10:15 +0000 (00:10 +0000)]
Fix unused variables in tests to placate scan-build. Patch from Steve MacKenzie.
llvm-svn: 220154
David Majnemer [Sun, 19 Oct 2014 00:03:10 +0000 (00:03 +0000)]
CodeGen: ConstStructBuilder must verify packed constraints after padding
Before, ConstStructBuilder::AppendBytes would check packed constraints
prior to padding being added before the field's offset. However, adding
this padding might force our struct to be packed. Because we wouldn't
check *after* adding padding, ConstStructBuilder would be in an
inconsistent state leading to a crash.
This fixes PR21300.
llvm-svn: 220153
Filipe Cabecinhas [Sat, 18 Oct 2014 23:47:59 +0000 (23:47 +0000)]
New round of fixes for "Always compile debuginfo-tests for the host triple"
clang tests were breaking, at least when compiling clang only, from an
installed llvm. Make the lit.cfg script deal with the case when we don't
have a host_triple available.
llvm-svn: 220152
Chandler Carruth [Sat, 18 Oct 2014 23:47:22 +0000 (23:47 +0000)]
Rename 'TD' to 'DL' in this function as the argument is now a DataLayout
argument.
llvm-svn: 220151
Chandler Carruth [Sat, 18 Oct 2014 23:46:17 +0000 (23:46 +0000)]
Fix the other comment to use modern doxygen style and be a bit more
direct. Notably, comment on the fact that the loaded type is significant
in that it determines how wide of an access must be safe.
llvm-svn: 220150
Chandler Carruth [Sat, 18 Oct 2014 23:41:25 +0000 (23:41 +0000)]
More formatting cleanup brought to you by clang-format.
llvm-svn: 220149
Filipe Cabecinhas [Sat, 18 Oct 2014 23:36:12 +0000 (23:36 +0000)]
New round of fixes for "Always compile debuginfo-tests for the host triple"
clang tests were breaking, at least when compiling clang only, from an
installed llvm. Make the lit.cfg script deal with the case when we don't
have a host_triple available.
llvm-svn: 220148
Chandler Carruth [Sat, 18 Oct 2014 23:31:55 +0000 (23:31 +0000)]
Clean up doxygen syntax and reword comments to flow better, have a brief
section, and not have unfinished sentence fragments.
llvm-svn: 220147
Chandler Carruth [Sat, 18 Oct 2014 23:19:03 +0000 (23:19 +0000)]
Clean up the formatting and trailing whitespace of a routine before
editting it.
llvm-svn: 220146
Lang Hames [Sat, 18 Oct 2014 22:23:55 +0000 (22:23 +0000)]
[PBQP] Move register-allocation specific PBQP code into RegAllocPBQP.h.
Just clean-up - no functional change.
llvm-svn: 220145
Shankar Easwaran [Sat, 18 Oct 2014 20:36:35 +0000 (20:36 +0000)]
Fix display of files processed by the linker.
This fixes the way archive members are displayed when the linker is used with a
flag to show all the files that it processes.
When an archive file member is read, we need to show the archive filename and
the member.
llvm-svn: 220144
Lang Hames [Sat, 18 Oct 2014 17:26:07 +0000 (17:26 +0000)]
[PBQP] Replace the interference-constraints algorithm with a faster version
loosely based on linear scan.
On x86-64 this is good for a ~2% drop in compile time on the nightly test suite.
llvm-svn: 220143
Marshall Clow [Sat, 18 Oct 2014 11:03:33 +0000 (11:03 +0000)]
Whitespace maintenance. Remove a bunch of tabs that snuck in. No functionality change
llvm-svn: 220142
Chandler Carruth [Sat, 18 Oct 2014 11:00:12 +0000 (11:00 +0000)]
Preserve AA metadata when combining (cast (load (...))) -> (load (cast
(...))).
llvm-svn: 220141
Benjamin Kramer [Sat, 18 Oct 2014 10:43:51 +0000 (10:43 +0000)]
Use non-member begin/end for a slight readability improvement.
llvm-svn: 220140
Chandler Carruth [Sat, 18 Oct 2014 06:36:22 +0000 (06:36 +0000)]
[InstCombine] Do an about-face on how LLVM canonicalizes (cast (load
...)) and (load (cast ...)): canonicalize toward the former.
Historically, we've tried to load using the type of the *pointer*, and
tried to match that type as closely as possible removing as many pointer
casts as we could and trading them for bitcasts of the loaded value.
This is deeply and fundamentally wrong.
Repeat after me: memory does not have a type! This was a hard lesson for
me to learn working on SROA.
There is only one thing that should actually drive the type used for
a pointer, and that is the type which we need to use to load from that
pointer. Matching up pointer types to the loaded value types is very
useful because it minimizes the physical size of the IR required for
no-op casts. Similarly, the only thing that should drive the type used
for a loaded value is *how that value is used*! Again, this minimizes
casts. And in fact, the *only* thing motivating types in any part of
LLVM's IR are the types used by the operations in the IR. We should
match them as closely as possible.
I've ended up removing some tests here as they were testing bugs or
behavior that is no longer present. Mostly though, this is just cleanup
to let the tests continue to function as intended.
The only fallout I've found so far from this change was SROA and I have
fixed it to not be impeded by the different type of load. If you find
more places where this change causes optimizations not to fire, those
too are likely bugs where we are assuming that the type of pointers is
"significant" for optimization purposes.
llvm-svn: 220138
Chandler Carruth [Sat, 18 Oct 2014 06:36:18 +0000 (06:36 +0000)]
Remove a test that was ported from the old llvm-gcc frontend test suite.
This test is pretty awesome. It is claiming to test devirtualization.
However, the code in question is not in fact devirtualized by LLVM. If
you take the original C++ test case and run it through Clang at -O3 we
fail to devirtualize it completely. It also isn't a sufficiently focused
test case.
The *reason* we fail to devirtualize it isn't because of any missing
instcombine though. Instead, it is because we fail to emit an available
externally vtable and thus the vtable is just an external and completely
opaque. If I cause the vtable to be emitted, we successfully
devirtualize things.
Anyways, I'm just removing it because it is providing negative value at
this point: it isn't representative of the output of Clang really, LLVM
isn't doing the transform it claims to be testing, LLVM's failure to do
the transform isn't actually an LLVM bug at all and we shouldn't be
testing for it here, and finally the test is written in such a way that
it will trivially pass even when the point of the test is failing.
llvm-svn: 220137
Argyrios Kyrtzidis [Sat, 18 Oct 2014 06:23:50 +0000 (06:23 +0000)]
[libclang] If the code-completion point is inside the preamble, adjust the position at the beginning of the file after the preamble.
Otherwise we will not hit the code-completion point.
llvm-svn: 220136
Argyrios Kyrtzidis [Sat, 18 Oct 2014 06:19:36 +0000 (06:19 +0000)]
[libclang] Allow code-completion when pointing at the end-of-file.
llvm-svn: 220135