Commit Graph

177523 Commits

Author SHA1 Message Date
David Majnemer d905da4a5f MS ABI: Reference MSVC RTTI from the VFTable
The pointer for a class's RTTI data comes right before the VFTable but
has no name.  To be properly compatible with this, we do the following:
* Create a single GlobalVariable which holds the contents of the VFTable
  _and_ the pointer to the RTTI data.
* Create a GlobalAlias, with appropriate linkage/visibility, that points
  just after the RTTI data pointer.  This ensures that the VFTable
  symbol will always refer to VFTable data.
* Create a Comdat with a "Largest" SelectionKind and stick the private
  GlobalVariable in it.  By transitivity, the GlobalAlias will be a
  member of the Comdat group.  Using "Largest" ensures that foreign
  definitions without an RTTI data pointer will _not_ be chosen in the
  final linked image.

Whether or not we emit RTTI data depends on several things:
* The -fno-rtti flag implies that we should never not emit a pointer to
  RTTI data before the VFTable.
* __declspec(dllimport) brings in the VFTable from a remote DLL. Use an
  available_externally GlobalVariable to provide a local definition of
  the VFTable.  This means that we won't have any available_externally
  definitions of things like complete object locators.  This is
  acceptable because they are never directly referenced.

To my knowledge, this completes the implementation of MSVC RTTI code
generation.

Further semantic work should be done to properly support /GR-.

llvm-svn: 212125
2014-07-01 20:30:31 +00:00
Eric Christopher 5234995e80 Move the subtarget dependent features from SystemZTargetMachine
down to the subtarget. Add an initialization routine to assist.

llvm-svn: 212124
2014-07-01 20:19:02 +00:00
Eric Christopher f1bd22dfa4 Remove the use and initialization of the target machine and subtarget
from SystemZFrameLowering.

llvm-svn: 212123
2014-07-01 20:18:59 +00:00
David Blaikie 6876b3bcff DebugInfo: Provide a utility for building a mapping from llvm::Function*s to llvm::DISubprograms
Update DeadArgumentElimintation to use this, with the intent of reusing
the functionality for ArgumentPromotion as well.

llvm-svn: 212122
2014-07-01 20:05:26 +00:00
Alexey Samsonov e3a401a12b [MSan] Fixup r212082: enable tests for _mm_ intrinsics if and only if the
unit test source file is compiled with Clang.

llvm-svn: 212121
2014-07-01 19:58:41 +00:00
Tim Northover 21feb2e1d2 AArch64: fix comment typo
llvm-svn: 212120
2014-07-01 19:47:09 +00:00
Tim Northover 277066ab43 X86: expand atomics in IR instead of as MachineInstrs.
The logic for expanding atomics that aren't natively supported in
terms of cmpxchg loops is much simpler to express at the IR level. It
also allows the normal optimisations and CodeGen improvements to help
out with atomics, instead of using a limited set of possible
instructions..

rdar://problem/13496295

llvm-svn: 212119
2014-07-01 18:53:31 +00:00
Reid Kleckner 3ed22c4d4e clang-cl: Ignore /Zc:inline and /Zc:rvalueCast
These flags enable behavior in MSVC that Clang has by default.

/Zc:inline essentially marks all COMDATs as discardable.  In LLVM
parlance, this means using linkonce_odr linkage, which is what we
already do.

llvm-svn: 212117
2014-07-01 18:27:02 +00:00
Sean Silva 9ab8899f5c [docs] Fix a mangled sentence.
Fixes PR20169

llvm-svn: 212116
2014-07-01 18:22:32 +00:00
Sean Silva ff6a7d6d32 [docs] Remove stray HTML tag.
Fixes PR20167

llvm-svn: 212115
2014-07-01 18:15:00 +00:00
Adam Nemet 16de2486cb [X86] AVX512: Allow writemasks with vpcmp
For now I only updated the _alt variants.  The main variants are used by
codegen and that will need a bit more work to trigger.

<rdar://problem/17492620>

llvm-svn: 212114
2014-07-01 18:03:45 +00:00
Adam Nemet 1efcb90fcd [X86] AVX512: Factor generating the AsmString into avx512_icmp_cc
Adding a writemask variant would require a third asm string to be passed to
the template.  Generate the AsmString in the template instead.

No change in X86.td.expanded.

llvm-svn: 212113
2014-07-01 18:03:43 +00:00
Alexey Samsonov 06ff6cbf4d [TSan] Equalize the behavior of __tsan_get_allocated_size and user_alloc_usable_size.
The former used to crash with a null deref if it was given a not owned pointer,
while the latter returned 0. Now they both return 0. This is still not the best possible
behavior: it is better to print an error report with a stack trace, pointing
to the error in user code, as we do in ASan.

llvm-svn: 212112
2014-07-01 18:01:20 +00:00
Deepak Panickal 9b35cf52d2 This creates a valid Python API for Windows, pending some issues. The changes included are -
- Ported the SWIG wrapper shell scripts to Python so that they would work on Windows too along with other platforms
 - Updated CMake handling to fix SWIG errors and manage sym-linking on Windows to liblldb.dll
 - More build fixes for Windows

The pending issues are that two Python modules, termios and pexpect are not available on Windows.
These are currently required for the Python command interpreter to be used from within LLDB.

llvm-svn: 212111
2014-07-01 17:57:19 +00:00
Sylvestre Ledru 91f380a499 GCC compatibility: Ignore -finput_charset=UTF-8 argument. It is the default in Clang.
Currently, we fail with an error.

Reviewers: rafael

Reviewed By: rafael

Subscribers: rnk, cfe-commits

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

llvm-svn: 212110
2014-07-01 17:24:27 +00:00
Chad Rosier f575a73751 Revert "MachineScheduler: better book-keeping for asserts."
This reverts commit r212088, which is causing a number of spec
failures.  Will provide reduced test cases shortly.
PR20057

llvm-svn: 212109
2014-07-01 17:23:11 +00:00
Kevin Enderby afef4c99dc Add the -arch flag support to llvm-size like what was done to llvm-nm
to select the slice out of a Mach-O universal file.  This also includes
support for -arch all, selecting the host architecture by default from
a universal file and checking if -arch is used with a standard Mach-O
it matches that architecture.

llvm-svn: 212108
2014-07-01 17:19:10 +00:00
Todd Fiala 9be5049a01 Use native ::pid_t in Linux ProcessMonitor (local debugging).
There were a few places where we were not catching the possibility of negative
error codes in waitpid() calls.  This change fixes those remaining after
the llgs branch fixes to ProcessMonitor.

Change by Shawn Best.

llvm-svn: 212107
2014-07-01 16:30:53 +00:00
Quentin Colombet 6d590d538f [PeepholeOptimzer] Fix a typo in a comment.
Spotted by Amara Emerson.

llvm-svn: 212106
2014-07-01 16:23:44 +00:00
Benjamin Kramer f2c4baf01b Remove unused typedef. GCC warns about this.
llvm-svn: 212105
2014-07-01 15:39:32 +00:00
David Majnemer 5c92115972 GlobalOpt: Don't swap private for internal linkage
There were transforms whose *intent* was to downgrade the linkage of
external objects to have internal linkage.

However, it fired on things with private linkage as well.

llvm-svn: 212104
2014-07-01 15:26:50 +00:00
David Majnemer 9797abb0bf GlobalOpt: FileCheck-ize test
No functionality change.

llvm-svn: 212103
2014-07-01 15:26:47 +00:00
Benjamin Kramer 0e18484696 Rephrase loop so it doesn't leave unused bools around in Release mode.
llvm-svn: 212102
2014-07-01 14:46:44 +00:00
Rafael Espindola 83120cdf68 Avoid revocations when possible.
This is a small targeted fix for pr20119. The code needs quiet a bit of
refactoring and I added some FIXMEs about it, but I want to get the testcase
passing first.

llvm-svn: 212101
2014-07-01 14:34:30 +00:00
Quentin Colombet 1111e6fe84 [PeepholeOptimizer] Advanced rewriting of copies to avoid cross register banks
copies.

This patch extends the peephole optimization introduced in r190713 to produce
register-coalescer friendly copies when possible.

This extension taught the existing cross-bank copy optimization how to deal
with the instructions that generate cross-bank copies, i.e., insert_subreg,
extract_subreg, reg_sequence, and subreg_to_reg.
E.g.
b = insert_subreg e, A, sub0 <-- cross-bank copy
...
C = copy b.sub0 <-- cross-bank copy

Would produce the following code:
b = insert_subreg e, A, sub0 <-- cross-bank copy
...
C = copy A <-- same-bank copy

This patch also introduces a new helper class for that: ValueTracker.
This class implements the logic to look through the copy related instructions
and get the related source.

For now, the advanced rewriting is disabled by default as we are lacking the
semantic on target specific instructions to catch the motivating examples.

Related to <rdar://problem/12702965>.

llvm-svn: 212100
2014-07-01 14:33:36 +00:00
Quentin Colombet e1a36634b7 [RegAllocGreedy] Provide a flag to disable the local reassignment heuristic.
By default, no functionality change.

Before evicting a local variable, this heuristic tries to find another (set of)
local(s) that can be reassigned to a free color.

In some extreme cases (large basic blocks with tons of local variables), the
compilation time is dominated by the local interference checks that this
heuristic must perform, with no code gen gain.
E.g., the motivating example takes 4 minutes to compile with this heuristic, 12
seconds without.

Improving the situation will likely require to make drastic changes to the
register allocator and/or the interference check framework.

For now, provide this flag to better understand the impact of that heuristic.

<rdar://problem/17444599>

llvm-svn: 212099
2014-07-01 14:08:37 +00:00
Logan Chien e9c8ccbf8f Remove CleanupHackLevel from CGException.
This patch removes the dead code, and refines the
getEHResumeBlock() slightly.

The CleanupHackLevel was a hack to the old exception
handling intrinsics, which have several issues with function
inliner.

Since LLVM 3.0, the new landingpad and resume instructions
are added to LLVM IR.  With the new exception handling
mechanism, most of the issues are fixed now.  We should
always use these instructions to implement the exception
handling code nowadays, and we don't need the hack any more.

Besides, the `CleanupHackLevel` is a compile-time constant,
thus other cases have been considered as dead code for a while.

llvm-svn: 212097
2014-07-01 11:47:10 +00:00
Simon Atanasyan ad80595b60 [Driver][Mips] MIPS ABI names "32" and "64" used as arguments of the "-mabi"
command line option only. Internally we convert them to the "o32" and "n64"
respectively. So we do not need to refer them anywhere after that conversion.

No functional changes.

llvm-svn: 212096
2014-07-01 10:59:09 +00:00
Alp Toker 1a9ea52edb Remove obsolete function TargetRegistry::getClosestTargetForJIT()
This was kept around "for compatibility through 2.6" in 2009 and is not used or
tested.

llvm-svn: 212095
2014-07-01 10:47:13 +00:00
Tim Northover 9bdf90e5c2 [mach-o]: make the default dylib install-name the output filename.
llvm-svn: 212094
2014-07-01 08:41:45 +00:00
Tim Northover 301c4e690a [mach-o] add representation for LC_ID_DYLIB to MachONormalizedFile
It still needs to be tied into BinaryReader, but this allows reasonably
sensible creation of SharedLibrary atoms on MachO.

llvm-svn: 212093
2014-07-01 08:15:41 +00:00
Gerolf Hoflehner 012dff0b23 Enable test/CodeGen/indirect-goto.c in 64b for local arrays
In 32b mode the reference count for block addresses
is not zero. This prevents inlining and constant
folding and causes the test to fail. Changing
the triple allows runnning the test in 64b mode.

The array in foo2 is now local instead of static until
at lower optimization levels the interprocedural constant
propagator is invoked before the global optimizer.

llvm-svn: 212092
2014-07-01 05:10:06 +00:00
Bob Wilson 84941b92e6 Temporarily disable the indirect-goto.c test.
llvm r212077 causes this test to fail. We need to reorder some passes and
possibly make other changes to reenable the optimization being tested here.

llvm-svn: 212091
2014-07-01 04:56:06 +00:00
Nikola Smiljanic 3fe1e09a6e PR15677 - Crash in template diffing. Check that expression is evaluatable before evaluating it.
llvm-svn: 212090
2014-07-01 04:17:53 +00:00
David Blaikie c8caa1702a Revert "DebugInfo: Ensure that all debug location scope chains from instructions within a function, lead to the function itself."
This reverts commit r212085.

This breaks the sanitizer bot... & I thought I'd tried pretty hard not
to do that. Guess I need to try harder.

llvm-svn: 212089
2014-07-01 04:11:45 +00:00
Andrew Trick f1b307bcb0 MachineScheduler: better book-keeping for asserts.
Fixes another test case under PR20057.

llvm-svn: 212088
2014-07-01 03:23:13 +00:00
Alp Toker 60c88cbf7f clang-interpreter: use LLVM interpreter if JIT is unavailable
Update the strategy in r212083 to try JIT first and otherwise fall back to the
interpreter. This gives the best of both worlds and still builds fine with no
targets enabled.

Requires supporting changes from LLVM r212086.

llvm-svn: 212087
2014-07-01 03:19:50 +00:00
Alp Toker 568c31f236 ExecutionEngine::create(): fix interpreter fallback when JIT is unavailable
ForceInterpreter=false shouldn't disable the interpreter completely because it
can still be necessary to interpret if the target doesn't support JIT.

No obvious way to test this in LLVM, but this matches what
LLVMCreateExecutionEngineForModule() does and fixes the clang-interpreter
example in the clang source tree which uses the ExecutionEngine.

llvm-svn: 212086
2014-07-01 03:18:49 +00:00
David Blaikie b89e6d93d9 DebugInfo: Ensure that all debug location scope chains from instructions within a function, lead to the function itself.
Originally committed in r211723, reverted in r211724 due to failure
cases found and fixed (ArgumentPromotion: r211872, Inlining: r212065),
and I now believe the invariant actually holds for some reasonable
amount of code (but I'll keep an eye on the buildbots and see what
happens... ).

Original commit message:

PR20038: DebugInfo: Inlined call sites where the caller has debug info
but the call itself has no debug location.

This situation does bad things when inlined, so I've fixed Clang not to
produce inlinable call sites without locations when the caller has debug
info (in the one case where I could find that this occurred). This
updates the PR20038 test case to be what clang now produces, and readds
the assertion that had to be removed due to this bug.

I've also beefed up the debug info verifier to help diagnose these
issues in the future, and I hope to add checks to the inliner to just
assert-fail if it encounters this situation. If, in the future, we
decide we have to cope with this situation, the right thing to do is
probably to just remove all the DebugLocs from the inlined instructions.

llvm-svn: 212085
2014-07-01 03:11:59 +00:00
Alp Toker e8aa4b90f9 driver: add link dependency on CodeGen
Fix the build when no targets are enabled. This dependency is incurred by two
unfortunate entries in LinkAllPasses.h included from cc1_main.cpp:

  llvm::createJumpInstrTablesPass();
  llvm::createCodeGenPreparePass();

llvm-svn: 212084
2014-07-01 02:42:02 +00:00
Alp Toker 475f282b5d clang-interpreter: interpret instead of JITing
Fixes the build when no targets are selected, or no native target is built.

This also better matches up with the description/title of the example and
demonstrates how clang can be used to run C++ on constrained environments
without file IO or executable memory permissions (e.g. iOS apps).

A comment is added explaining how to extend the demo with JIT support as
needed.

llvm-svn: 212083
2014-07-01 02:41:55 +00:00
Alexey Samsonov c0fda339e2 Add the way to disable MSan unit tests for _mm_* intrinsics
llvm-svn: 212082
2014-07-01 01:38:52 +00:00
Reid Kleckner b5dd9452b4 Fix .seh_stackalloc 0
seh_stackalloc 0 is not representable in Win64 SEH info, so emitting it
is a bug.

Reviewers: rnk

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

Patch by Vadim Chugunov!

llvm-svn: 212081
2014-07-01 00:42:47 +00:00
Johannes Doerfert 9890a05287 [FIX] Don't consider reductions which are partially outside the SCoP
+ Test case

llvm-svn: 212080
2014-07-01 00:32:29 +00:00
David Majnemer 0e2cc2a519 GlobalOpt: Handle non-zero offsets for aliases
An alias with an aliasee of a non-zero GEP is not trivially replacable
with it's aliasee.

llvm-svn: 212079
2014-07-01 00:30:56 +00:00
David Majnemer 5bfe75cf61 IR: Add a helper to check for LinkOnceODRLinkage
llvm-svn: 212078
2014-07-01 00:30:52 +00:00
Gerolf Hoflehner 734f4c8984 Suppress inlining when the block address is taken
Inlining functions with block addresses can cause many problem and requires a
rich infrastructure to support including escape analysis.  At this point the
safest approach to address these problems is by blocking inlining from
happening.

Background:
There have been reports on Ruby segmentation faults triggered by inlining
functions with block addresses like

//Ruby code snippet
vm_exec_core() {
    finish_insn_seq_0 = &&INSN_LABEL_finish;
    INSN_LABEL_finish:
      ;
}

This kind of scenario can also happen when LLVM picks a subset of blocks for
inlining, which is the case with the actual code in the Ruby environment.

LLVM suppresses inlining for such functions when there is an indirect branch.
The attached patch does so even when there is no indirect branch.  Note that
user code like above would not make much sense: using the global for jumping
across function boundaries would be illegal.

Why was there a segfault:

In the snipped above the block with the label is recognized as dead So it is
eliminated. Instead of a block address the cloner stores a constant (sic!) into
the global resulting in the segfault (when the global is used in a goto).

Why had it worked in the past then:

By luck. In older versions vm_exec_core was also inlined but the label address
used was the block label address in vm_exec_core.  So the global jump ended up
in the original function rather than in the caller which accidentally happened
to work.

Test case ./tools/clang/test/CodeGen/indirect-goto.c will fail as a result
of this commit.

rdar://17245966

llvm-svn: 212077
2014-07-01 00:19:34 +00:00
Zachary Turner 0ec7baa9f4 Fix Windows build after llgs upstream.
With _HAS_EXCEPTIONS=0, Windows' version of <thread> will fail to
compile because it calls __uncaught_exception(), which is compiled
out due to _HAS_EXCEPTIONS=0.  This just creates a stub version
of __uncaught_exception() which always fails.

llvm-svn: 212076
2014-07-01 00:18:46 +00:00
Duncan P. N. Exon Smith 4f5e9f8207 AArch64: Follow-up to r212073
In r212073 I missed a call of `use_begin()` that assumed the wrong
semantics.  It's not clear to me at all what this code does without the
fix, so I'm not sure how to write a testcase.

llvm-svn: 212075
2014-07-01 00:05:37 +00:00
Todd Fiala 2850b1be2e Fixup Windows build breaks for the llgs upstream.
Also moves NativeRegisterContextLinux* files into the Linux directory.
These, like NativeProcessLinux, should only be built on Linux or a cross
compiler with proper headers.

llvm-svn: 212074
2014-06-30 23:51:35 +00:00