Commit Graph

4109 Commits

Author SHA1 Message Date
Saleem Abdulrasool
ce9c73a84d Support: chunk writing on Linux
This is a workaround for large file writes.  It has been witnessed that
write(2) failing with EINVAL (22) due to a large value (>2G).  Thanks to
James Knight for the help with coming up with a sane test case.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305846 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-20 20:51:51 +00:00
Craig Topper
4f1962c363 [APFloat] Move the integerPartWidth constant into APFloatBase. Remove integerPart typedef at file scope and just use the one in APFloatBase everywhere. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305652 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-18 18:15:41 +00:00
Kamil Rytarowski
32639e60f1 Implement AllocateRWX and ReleaseRWX for NetBSD
Summary:
NetBSD ships with PaX MPROTECT disallowing RWX mappings.
There is a solution to bypass this restriction with double mapping
RX (code) and RW (data) using mremap(2) MAP_REMAPDUP.
The initial mapping must be mmap(2)ed with protection:
PROT_MPROTECT(PROT_EXEC).

This functionality to bypass PaX MPROTECT appeared in NetBSD-7.99.72.

This patch fixes 20 failing tests:
-    LLVM :: DebugInfo/debuglineinfo-macho.test
-    LLVM :: DebugInfo/debuglineinfo.test
-    LLVM :: ExecutionEngine/RuntimeDyld/Mips/ELF_Mips64r2N64_PIC_relocations.s
-    LLVM :: ExecutionEngine/RuntimeDyld/Mips/ELF_N32_relocations.s
-    LLVM :: ExecutionEngine/RuntimeDyld/Mips/ELF_N64R6_relocations.s
-    LLVM :: ExecutionEngine/RuntimeDyld/Mips/ELF_O32R6_relocations.s
-    LLVM :: ExecutionEngine/RuntimeDyld/Mips/ELF_O32_PIC_relocations.s
-    LLVM :: ExecutionEngine/RuntimeDyld/X86/COFF_i386.s
-    LLVM :: ExecutionEngine/RuntimeDyld/X86/COFF_x86_64.s
-    LLVM :: ExecutionEngine/RuntimeDyld/X86/ELF-relaxed.s
-    LLVM :: ExecutionEngine/RuntimeDyld/X86/ELF_STT_FILE.s
-    LLVM :: ExecutionEngine/RuntimeDyld/X86/ELF_x64-64_PC8_relocations.s
-    LLVM :: ExecutionEngine/RuntimeDyld/X86/ELF_x64-64_PIC_relocations.s
-    LLVM :: ExecutionEngine/RuntimeDyld/X86/ELF_x86-64_PIC-small-relocations.s
-    LLVM :: ExecutionEngine/RuntimeDyld/X86/ELF_x86-64_debug_frame.s
-    LLVM :: ExecutionEngine/RuntimeDyld/X86/ELF_x86_64_StubBuf.s
-    LLVM :: ExecutionEngine/RuntimeDyld/X86/MachO_empty_ehframe.s
-    LLVM :: ExecutionEngine/RuntimeDyld/X86/MachO_i386_DynNoPIC_relocations.s
-    LLVM :: ExecutionEngine/RuntimeDyld/X86/MachO_i386_eh_frame.s
-    LLVM :: ExecutionEngine/RuntimeDyld/X86/MachO_x86-64_PIC_relocations.s

Sponsored by <The NetBSD Foundation>

Reviewers: joerg, lhames

Reviewed By: joerg

Subscribers: sdardis, llvm-commits, arichardson

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305650 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-18 16:52:32 +00:00
NAKAMURA Takumi
b903fddc56 [CMake] Introduce LLVM_TARGET_TRIPLE_ENV as an option to override LLVM_DEFAULT_TARGET_TRIPLE at runtime.
No behavior is changed if LLVM_TARGET_TRIPLE_ENV is blank or undefined.

If LLVM_TARGET_TRIPLE_ENV is "TEST_TARGET_TRIPLE" and $TEST_TARGET_TRIPLE is not blank,
llvm::sys::getDefaultTargetTriple() returns $TEST_TARGET_TRIPLE.
Lit resets config.target_triple and config.environment[LLVM_TARGET_TRIPLE_ENV] to change the default target.

Without changing LLVM_DEFAULT_TARGET_TRIPLE nor rebuilding, lit can be run;

  TEST_TARGET_TRIPLE=i686-pc-win32 bin/llvm-lit -sv path/to/test/
  TEST_TARGET_TRIPLE=i686-pc-win32 ninja check-clang-tools

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305632 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-17 03:19:08 +00:00
Rui Ueyama
9a18969a66 Fix buildbots.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305542 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-16 02:42:33 +00:00
Rui Ueyama
04c012651f Fix msan buildbot.
This patch should fix sanitizer-x86_64-linux-fast bot.

The problem was that the contents of this stream are aligned to 4 byte,
and the paddings were created just by incrementing `Offset`, so paddings
had undefined values. When the entire stream is written to an output,
it triggered msan.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305541 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-16 02:17:35 +00:00
Frederich Munch
e49b209a9e Hide dbgs() stream for when built with -fmodules.
Summary: Make DebugCounter::print and dump methods to be const correct.

Reviewers: aprantl

Reviewed By: aprantl

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305408 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-14 19:16:22 +00:00
Peter Collingbourne
08c98a90f5 Support: Remove MSVC 2013 workarounds in ThreadPool class.
I have confirmed that these are no longer needed with MSVC 2015.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305347 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-14 00:36:21 +00:00
David Blaikie
a17d9bc6ed Support: Don't set RLIMIT_AS on child processes when applying a memory limit
It doesn't seem relevant to set an address space limit - this isn't
important in any sense that I'm aware & it gets in the way of things
that use a lot of address space, like llvm-symbolizer.

This came up when I realized that bugpoint regression tests were much
slower with -gsplit-dwarf than plain -g. Turned out that bugpoint
subprocesses (opt, etc) were crashing and doing symbolization - but
bugpoint runs those subprocesses with a 400MB memory limit. So with
plain -g, mmaping the opt binary would exceed the memory limit, fail,
and thus be really fast - no symbolization occurred. Whereas with
-gsplit-dwarf, comically, having less to map in, it would succeed and
then spend lots of time symbolizing.

I've fixed at least the critical part of bugpoint's perf problem there
by adding an option to allow bugpoint to disable symbolization. Thus
improving the perfromance for -gsplit-dwarf and making the -g-esque
speed available without this quirk/accidental benefit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305242 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-12 22:16:49 +00:00
George Burgess IV
4d6bb2d890 [ADT] Reduce duplication between {Contextual,}FoldingSet; NFC
This is a precursor to another change (coming soon) that aims to make
FoldingSet's API more type-safe. Without this, the type-safety change
would just duplicate 4 more public methods between the already very
similar classes.

This renames FoldingSetImpl to FoldingSetBase so it's consistent with
the FooBase -> FooImpl<T> -> Foo<T> convention we seem to have with
other containers.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305231 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-12 20:52:53 +00:00
David Blaikie
5dc796dd9c bugpoint: disabling symbolication of bugpoint-executed programs
Initial implementation - needs similar work/testing for other tools
bugpoint invokes (llc, lli I think, maybe more).

Alternatively (as suggested by chandlerc@) an environment variable could
be used. This would allow the option to pass transparently through user
scripts, pass to compilers if they happened to be LLVM-ish, etc.

I worry a bit about using cl::opt in the crash handling code - LLVM
might crash early, perhaps before the cl::opt is properly initialized?
Or at least before arguments have been parsed?

 - should be OK since it defaults to "pretty", so if the crash is very
 early in opt parsing, etc, then crash reports will still be symbolized.

I shyed away from doing this with an environment variable when I
realized that would require copying the existing environment and
appending the env variable of interest. But it seems there's no existing
LLVM API for accessing the environment (even the Support tests for
process launching have their own ifdefs for getting the environment). It
could be added, but seemed like a higher bar/untested codepath to
actually add environment variables.

Most importantly, this reduces the runtime of test/BugPoint/metadata.ll
in a split-dwarf Debug build from 1m34s to 6.5s by avoiding a lot of
symbolication. (this wasn't a problem for non-split-dwarf builds only
because the executable was too large to map into memory (due to bugpoint
setting a 400MB memory (including address space - not sure why? Going to
remove that) limit on the child process) so symbolication would fail
fast & wouldn't spend all that time parsing DWARF, etc)

Reviewers: chandlerc, dannyb

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305056 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-09 07:29:03 +00:00
Florian Hahn
4d6ca73334 [Linker] Remove warning when linking ARM and Thumb IR modules.
Summary:
This patch updates Triple::isCompatibleWith to make armxx and thumbxx
triples compatible, as long as the subarch, vendor, os, envorionment and
object format match. Thumb/ARM code generation should be controlled
using the thumb-mode per-function target feature rather than by the
triple to allow mixing Thumb and ARM functions.

D33448 updates Clang's codegen to add thumb-mode for all functions with
armxx or thumbxx triples.

Reviewers: echristo, t.p.northover, rafael, kristof.beyls, rengolin, tejohnson

Reviewed By: tejohnson

Subscribers: rinon, eugenis, pcc, srhines, aemerson, mehdi_amini, javed.absar, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304884 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-07 09:17:01 +00:00
Zachary Turner
19ca2b0f9d Move Object format code to lib/BinaryFormat.
This creates a new library called BinaryFormat that has all of
the headers from llvm/Support containing structure and layout
definitions for various types of binary formats like dwarf, coff,
elf, etc as well as the code for identifying a file from its
magic.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304864 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-07 03:48:56 +00:00
Dimitry Andric
4a03a9f089 Allow VersionPrinter to print to arbitrary raw_ostreams
Summary:
I would like to add printing of registered targets to clang's version
information.  For this to work correctly, the VersionPrinter logic in
CommandLine.cpp should support printing to arbitrary raw_ostreams,
instead of always defaulting to outs().

Add a raw_ostream& parameter to the function pointer type used for
VersionPrinter, and while doing so, introduce a typedef for convenience.

Note that VersionPrinter::print() will still default to using outs(),
the clang part will necessarily go into a separate review.

Reviewers: beanz, chandlerc, dberris, mehdi_amini, zturner

Reviewed By: mehdi_amini

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304835 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-06 21:54:04 +00:00
Konstantin Zhuravlyov
2c18fa1f9c AMDGPU/NFC: Move amdgpu code object metadata to support
Differential Revision: https://reviews.llvm.org/D31437


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304812 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-06 18:35:50 +00:00
Chandler Carruth
6721342b90 Fix another ordering constraint with windows.h and comment about
a revers constraint that we got right (by chance).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304792 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-06 12:43:20 +00:00
Chandler Carruth
1edfb2c819 Fix one place where I missed a commented requirement for a particular
include ordering.

I've changed the structure so that clang-format will preserve this going
forward.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304788 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-06 12:11:24 +00:00
Chandler Carruth
e3e43d9d57 Sort the remaining #include lines in include/... and lib/....
I did this a long time ago with a janky python script, but now
clang-format has built-in support for this. I fed clang-format every
line with a #include and let it re-sort things according to the precise
LLVM rules for include ordering baked into clang-format these days.

I've reverted a number of files where the results of sorting includes
isn't healthy. Either places where we have legacy code relying on
particular include ordering (where possible, I'll fix these separately)
or where we have particular formatting around #include lines that
I didn't want to disturb in this patch.

This patch is *entirely* mechanical. If you get merge conflicts or
anything, just ignore the changes in this patch and run clang-format
over your #include lines in the files.

Sorry for any noise here, but it is important to keep these things
stable. I was seeing an increasing number of patches with irrelevant
re-ordering of #include lines because clang-format was used. This patch
at least isolates that churn, makes it easy to skip when resolving
conflicts, and gets us to a clean baseline (again).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304787 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-06 11:49:48 +00:00
Frederich Munch
908f18379e Close DynamicLibraries in reverse order they were opened.
Summary: Matches C++ destruction ordering better and fixes possible problems of loaded libraries having inter-dependencies.

Reviewers: efriedma, v.g.vassilev, chapuni

Reviewed By: efriedma

Subscribers: mgorny, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304720 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-05 16:26:58 +00:00
Dimitry Andric
d1690d7c87 Fix building DynamicLibrary.cpp with musl libc
Summary:
The workaround added in rL301240 for stderr/out/in symbols being both
macros and globals is only necessary for glibc, and it does not compile
with musl libc. Alpine Linux has had the following fix for it:

https://git.alpinelinux.org/cgit/aports/plain/main/llvm4/llvm-fix-DynamicLibrary-to-build-with-musl-libc.patch

Adapt the fix in our DynamicLibrary.inc for Unix.

Reviewers: marsupial, chandlerc, krytarowski

Reviewed By: krytarowski

Subscribers: srhines, krytarowski, llvm-commits

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304707 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-05 11:22:18 +00:00
Saleem Abdulrasool
61a5551f88 ADT: handle special case of ARM environment for SUSE
SUSE treats "gnueabi" as "gnueabihf" so make sure that we normalise the
environment.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304670 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-03 22:31:06 +00:00
Jacob Gravelle
fd4a49bbfc Revert r304117 - WebAssembly object format isn't ready to be the default
Summary: Wasm object format has some functionality regressions from the ELF format, and doesn't play nicely with the rest of the toolchain. It should eventually be the default, but not yet.

Reviewers: sunfish, sbc100

Subscribers: jfb, dschuff, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304512 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-02 01:26:17 +00:00
Kamil Rytarowski
571304b386 [Solaris] Fix PR33228 - llvm::sys::fs::is_local_impl done right
Summary:
Solaris-specific implementation for llvm::sys::fs::is_local_impl.
FStype pattern matching might be a bit unreliable, but at least it fixes the build failure.



Reviewers: mgorny, nlopes, llvm-commits, krytarowski

Reviewed By: krytarowski

Subscribers: voskresensky.vladimir, krytarowski

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304412 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-01 12:57:00 +00:00
Eric Beckmann
1f0488cec7 Adding parsing ability for .res file.
Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304225 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-30 18:19:06 +00:00
Galina Kistanova
38012725da Added LLVM_FALLTHROUGH to address warning: this statement may fall through. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304187 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-30 03:30:34 +00:00
Benjamin Kramer
e005fa57be [ManagedStatic] Avoid putting function pointers in template args.
This is super awkward, but GCC doesn't let us have template visible when
an argument is an inline function and -fvisibility-inlines-hidden is
used.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304175 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-29 20:56:27 +00:00
Benjamin Kramer
107c8c925e Try to work around MSVC being buggy. Attempt #1.
error C2971: 'llvm::ManagedStatic': template parameter 'Creator': 'CreateDefaultTimerGroup': a variable with non-static storage duration cannot be used as a non-type argument

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304157 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-29 14:28:04 +00:00
Benjamin Kramer
6d432cf813 [Timer] Move DefaultTimerGroup into a ManagedStatic.
This used to be just leaked. r295370 made it use magic statics. This adds
a global destructor, which is something we'd like to avoid. It also creates
a weird situation where the mutex used by TimerGroup is re-created during
global shutdown and leaked.

Using a ManagedStatic here is also subtle as it relies on the mutex
inside of ManagedStatic to be recursive. I've added a test for that
in a previous change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304156 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-29 14:05:29 +00:00
Nikolai Bozhenov
404324ef9b [Nios2] Target registration
Reviewers: craig.topper, hfinkel, joerg, lattner, zvi

Reviewed By: craig.topper

Subscribers: oren_ben_simhon, igorb, belickim, tvvikram, mgorny, llvm-commits, pavel.v.chupin, DavidKreitzer

Differential Revision: https://reviews.llvm.org/D32669
Patch by AndreiGrischenko <andrei.l.grischenko@intel.com>


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304144 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-29 09:48:30 +00:00
Galina Kistanova
800305e39a Disabled implicit-fallthrough warnings for ConvertUTF.cpp.
ConvertUTF.cpp has a little dependency on LLVM, and since the code extensively uses fall-through switches,
I prefer disabling the warning for the whole file, rather than adding attributes for each case.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304120 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-29 01:34:26 +00:00
Saleem Abdulrasool
9ad104d71d Support: adjust the default obj format for wasm
WebAssemly uses a custom object file format.  For the wasm targets,
default to the `Wasm` object file format.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304117 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-29 00:14:57 +00:00
Oren Ben Simhon
3a87b52179 [X86] Fixing VPOPCNTDQ feature set lookup.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304086 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-28 11:26:11 +00:00
Benjamin Kramer
a0f27f968e Make helper functions static. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304029 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-26 20:09:00 +00:00
Frederich Munch
b0d2323300 Fix the ManagedStatic list ordering when using DynamicLibrary::addPermanentLibrary.
Summary:
r295737 included a fix for leaking libraries loaded via. DynamicLibrary::addPermanentLibrary.
This created a problem where static constructors in a library could insert llvm::ManagedStatic objects before DynamicLibrary would register it's own ManagedStatic, meaning a crash could occur at shutdown.

r301562 exasperated this problem by cleaning up the DynamicLibrary ManagedStatic during llvm_shutdown.

Reviewers: v.g.vassilev, lhames, efriedma

Reviewed By: efriedma

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304027 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-26 19:43:23 +00:00
Zachary Turner
7814846d2d Make BinaryStreamReader::readCString a bit faster.
Previously it would do a character by character search for a null
terminator, to account for the fact that an arbitrary stream need not
store its data contiguously so you couldn't just do a memchr. However, the
stream API has a function which will return the longest contiguous chunk
without doing a copy, and by using this function we can do a memchr on the
individual chunks. For certain types of streams like data from object
files etc, this is guaranteed to find the null terminator with only a
single memchr, but even with discontiguous streams such as
MappedBlockStream, it's rare that any given string will cross a block
boundary, so even those will almost always be satisfied with a single
memchr.

This optimization is worth a 10-12% reduction in link time (4.2 seconds ->
3.75 seconds)

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303918 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-25 21:12:27 +00:00
Oren Ben Simhon
f3cb5d6f7f [X86] Adding vpopcntd and vpopcntq instructions
AVX512_VPOPCNTDQ is a new feature set that was published by Intel.
The patch represents the LLVM side of the addition of two new intrinsic based instructions (vpopcntd and vpopcntq).

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303858 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-25 13:45:23 +00:00
Craig Topper
9b5a22370e [APInt] Use std::end to avoid mentioning the size of a local buffer repeatedly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303726 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-24 07:00:55 +00:00
Galina Kistanova
83d2f07814 Added LLVM_FALLTHROUGH to address gcc warning: this statement may fall through.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303597 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-23 01:20:52 +00:00
Galina Kistanova
b11f3d3884 Added LLVM_FALLTHROUGH to address gcc warning: this statement may fall through.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303595 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-23 01:07:19 +00:00
Galina Kistanova
21282be93c Added LLVM_FALLTHROUGH to address gcc warning: this statement may fall through.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303585 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-22 22:46:31 +00:00
Galina Kistanova
e5180ba874 Added LLVM_FALLTHROUGH to address gcc warning: this statement may fall through.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303457 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-19 21:08:28 +00:00
Craig Topper
47c969db7e [APInt] Add support for dividing or remainder by a uint64_t or int64_t.
Summary:
This patch adds udiv/sdiv/urem/srem/udivrem/sdivrem methods that can divide by a uint64_t. This makes division consistent with all the other arithmetic operations.

This modifies the interface of the divide helper method to work on raw arrays instead of APInts. This way we can pass the uint64_t in for the RHS without wrapping it in an APInt. This required moving all the Quotient and Remainder allocation handling up to the callers. For udiv/urem this was as simple as just creating the Quotient/Remainder with the right size when they were declared. For udivrem we have to rely on reallocate not changing the contents of the variable LHS or RHS is aliased with the Quotient or Remainder APInts. We also have to zero the upper bits of Remainder and Quotient that divide doesn't write to if lhsWords/rhsWords is smaller than the width.

I've update the toString method to use the new udivrem.

Reviewers: hans, dblaikie, RKSimon

Reviewed By: RKSimon

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303431 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-19 16:43:54 +00:00
Akira Hatanaka
343e535d9c [ThinLTO] Do not assert when adding a module with a different but
compatible target triple

Currently, an assertion fails in ThinLTOCodeGenerator::addModule when
the target triple of the module being added doesn't match that of the
one stored in TMBuilder. This patch relaxes the constraint and makes
changes to allow target triples that only differ in their version
numbers on Apple platforms, similarly to what r228999 did.

rdar://problem/30133904

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303326 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-18 03:52:29 +00:00
Zachary Turner
f0bbaf15bf Add some helpers for manipulating BinaryStreamRefs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303297 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-17 20:42:52 +00:00
Zachary Turner
2e0acd15bb [BinaryStream] Reduce the amount of boiler plate needed to use.
Often you have an array and you just want to use it.  With the current
design, you have to first construct a `BinaryByteStream`, and then create
a `BinaryStreamRef` from it.  Worse, the `BinaryStreamRef` holds a pointer
to the `BinaryByteStream`, so you can't just create a temporary one to
appease the compiler, you have to actually hold onto both the `ArrayRef`
as well as the `BinaryByteStream` *AND* the `BinaryStreamReader` on top of
that.  This makes for very cumbersome code, often requiring one to store a
`BinaryByteStream` in a class just to circumvent this.

At the cost of some added complexity (not exposed to users, but internal
to the library), we can do better than this.  This patch allows us to
construct `BinaryStreamReaders` and `BinaryStreamWriters` directly from
source data (e.g. `StringRef`, `MutableArrayRef<uint8_t>`, etc).  Not only
does this reduce the amount of code you have to type and make it more
obvious how to use it, but it solves real lifetime issues when it's
inconvenient to hold onto a `BinaryByteStream` for a long time.

The additional complexity is in the form of an added layer of indirection.
Whereas before we simply stored a `BinaryStream*` in the ref, we now store
both a `BinaryStream*` **and** a `std::shared_ptr<BinaryStream>`.  When
the user wants to construct a `BinaryStreamRef` directly from an
`ArrayRef` etc, we allocate an internal object that holds ownership over a
`BinaryByteStream` and forwards all calls, and store this in the
`shared_ptr<>`.  This also maintains the ref semantics, as you can copy it
by value and references refer to the same underlying stream -- the one
being held in the object stored in the `shared_ptr`.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303294 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-17 20:23:31 +00:00
Dimitry Andric
ba93e02f25 Revert r303015, because it has the unintended side effect of breaking
driver-mode recognition in clang (this is because the sysctl method
always returns one and only one executable path, even for an executable
with multiple links):

Fix DynamicLibraryTest.cpp on FreeBSD and NetBSD

Summary:

After rL301562, on FreeBSD the DynamicLibrary unittests fail, because
the test uses getMainExecutable("DynamicLibraryTests", Ptr), and since
the path does not contain any slashes, retrieving the main executable
will not work.

Reimplement getMainExecutable() for FreeBSD and NetBSD using sysctl(3),
which is more reliable than fiddling with relative or absolute paths.

Also add retrieval of the original argv[] from the GoogleTest framework,
to use as a fallback for other OSes.

Reviewers: emaste, marsupial, hans, krytarowski

Reviewed By: krytarowski

Subscribers: krytarowski, llvm-commits

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303285 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-17 19:33:10 +00:00
Reid Kleckner
aabc86087d Re-land r303274: "[CrashRecovery] Use SEH __try instead of VEH when available"
We have to check gCrashRecoveryEnabled before using __try.

In other words, SEH works too well and we ended up recovering from
crashes in implicit module builds that we weren't supposed to. Only
libclang is supposed to enable CrashRecoveryContext to allow implicit
module builds to crash.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303279 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-17 18:16:17 +00:00
Reid Kleckner
0f42e5be40 Revert "[CrashRecovery] Use SEH __try instead of VEH when available"
This reverts commit r303274, it appears to break some clang tests.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303275 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-17 17:15:00 +00:00
Reid Kleckner
8d2c1f540e [CrashRecovery] Use SEH __try instead of VEH when available
Summary:
It avoids problems when other libraries raise exceptions. In particular,
OutputDebugString raises an exception that the debugger is supposed to
catch and suppress. VEH kicks in first right now, and that is entirely
incorrect.

Unfortunately, GCC does not support SEH, so I've kept the old buggy VEH
codepath around. We could fix it with SetUnhandledExceptionFilter, but
that is not per-thread, so a well-behaved library shouldn't set it.

Reviewers: zturner

Subscribers: llvm-commits, mgorny

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303274 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-17 17:02:16 +00:00
Zachary Turner
e9eda65f4b Workaround for incorrect Win32 header on GCC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303272 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-17 16:39:33 +00:00