Commit Graph

70 Commits

Author SHA1 Message Date
Alex Lorenz
3f1b2bdf5d AsmParser: Require a terminating null character when creating memory buffer.
This commit modifies the memory buffer creation in the AsmParser library so 
that it requires a terminating null character. The LLLexer in the AsmParser
library checks for EOF only when it sees a null character, thus it would
be best to require it when creating a memory buffer so that the memory
buffer constructor can verify that a terminating null character is indeed
present.

Reviewers: Duncan P. N. Exon Smith, Matthias Braun

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237833 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-20 20:41:27 +00:00
Justin Bogner
ff966308e1 InstrProf: Add some unit tests for CoverageMapping
The llvm-level tests for coverage mapping need a binary input file,
which means they're hard to understand, hard to update, and it's
difficult to add new ones. By adding some unit tests that build up the
coverage data structures in C++, we can write more meaningful and
targeted tests.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228084 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-04 00:15:12 +00:00
Chandler Carruth
7c150bae21 [cmake] Start making LLVM_LIBDIR_SUFFIX effective by adding it to
*numerous* places where it was missing in the CMake build. The primary
change here is that the suffix is now actually used for all of the lib
directories in the LLVM project's CMake. The various subprojects still
need similar treatment.

This is the first of a series of commits to try to make LLVM's cmake
effective in a multilib Linux installation. I don't think many people
are seriously using this variable so I'm hoping the fallout will be
minimal. A somewhat unfortunate consequence of the nature of these
commits is that until I land all of them, they will in part make the
brokenness of our multilib support more apparant. At the end, things
should actually work.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224919 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-29 11:16:19 +00:00
Rafael Espindola
7413fefb8b Invert the MC -> Object dependency.
Now that we have a lib/MC/MCAnalysis, the dependency was there just because
of two helper classes. Move the two over to MC.

This will allow IRObjectFile to parse inline assembly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212248 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-03 02:01:39 +00:00
NAKAMURA Takumi
d294b68e28 [CMake] Enable llvm/unittests/LinkerTests. It had not been enabled since r199354.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207536 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-29 15:52:36 +00:00
Rafael Espindola
128237d0c7 Correctly set rpath for unittests.
This lets us run the unittest from the command line without setting
LD_LIBRARY_PATH.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202509 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-28 16:11:03 +00:00
Peter Collingbourne
cb6684b63b Introduce line editor library.
This library will be used by clang-query. I can imagine LLDB becoming another
client of this library, so I think LLVM is a sensible place for it to live.
It wraps libedit, and adds tab completion support.

The code is loosely based on the line editor bits in LLDB, with a few
improvements:

 - Polymorphism for retrieving the list of tab completions, based on
   the concept pattern from the new pass manager.

 - Tab completion doesn't corrupt terminal output if the input covers
   multiple lines. Unfortunately this can only be done in a truly horrible
   way, as far as I can tell. But since the alternative is to implement our
   own line editor (which I don't think LLVM should be in the business of
   doing, at least for now) I think it may be acceptable.

 - Includes a fallback for the case where the user doesn't have libedit
   installed.

Note that this uses C stdio, mainly because libedit also uses C stdio.

Differential Revision: http://llvm-reviews.chandlerc.com/D2200

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200595 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-31 23:46:14 +00:00
Rafael Espindola
2ad4cf54ee No point in having a "#if 0"ed unittest.
It is also not clear what the value of the test was. The API is used from
existing tools and can (and is) tested with lit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197654 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-19 03:44:13 +00:00
NAKAMURA Takumi
2fcb0c34b3 ArchiveFileDescriptorTests: Resurrect part of r197600, but make it invalidated, to appease buildbots.
Please revert this several hours later ;)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197635 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-19 00:41:03 +00:00
Owen Anderson
4fc184584c Revert r197600 while I sort out why it's failing on Windows.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197602 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-18 19:25:51 +00:00
Owen Anderson
04946d54db Add a unit test for loading an object file via a file descriptor. Patch by Pete Cooper.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197600 91177308-0d34-0410-b5e6-96231b3b80d8
2013-12-18 19:20:29 +00:00
Rafael Espindola
49978e6125 Fix MCDataAtom never calling remap when adding data.
This patch fixes a small mistake in MCDataAtom::addData() where it doesn't ever
call remap():

-  if (Data.size() > Begin - End - 1)
+  if (Data.size() > End + 1 - Begin)
     remap(Begin, End + 1);

This is currently not visible because of another bug is the disassembler, so
the patch includes a unit test.

Patch by Stephen Checkoway.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192823 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-16 18:26:16 +00:00
Eric Christopher
800a876128 Add a hashing routine that handles hashing types. Add a test for
hashing the contents of DW_FORM_data1 on top of a type with attributes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189862 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-03 21:57:57 +00:00
Eric Christopher
9f59ffcb54 Alphabetize.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189848 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-03 20:51:14 +00:00
Sean Silva
845e196a52 Make BinaryRef output correctly in case of empty data.
Previously, it would simply output nothing, but it should output an
empty string `""`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185894 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-09 00:54:46 +00:00
Alexey Samsonov
cd61455798 Create a stub for DWARF parser unittests
Moves one DWARF-specific header to include/llvm/DebugInfo from lib/.
Add a short unittest for r179095.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179678 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-17 08:29:02 +00:00
Chandler Carruth
c779e96158 Rename the VMCore unittest tree to IR. Somehow was missed when doing the
library rename.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171747 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-07 15:35:46 +00:00
Michael J. Spencer
96a564f2be Copy clang/Driver/<Option parsing stuff> to llvm.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169344 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-05 00:29:32 +00:00
Chandler Carruth
7c888eee47 Completely refactor the structuring of unittest CMake files to match the
Makefiles, the CMake files in every other part of the LLVM tree, and
sanity.

This should also restore the output tree structure of all the unit
tests, sorry for breaking that, and thanks for letting me know.

The fundamental change is to put a CMakeLists.txt file in the unittest
directory, with a single test binary produced from it. This has several
advantages:

- No more weird directory stripping in the unittest macro, allowing it
  to be used more readily in other projects.
- No more directory prefixes on all the source files.
- Allows correct and precise use of LLVM's per-directory dependency
  system.
- Allows use of the checking logic for source files that have not been
  added to the CMake build. This uncovered a file being skipped with
  CMake in LLVM and one in Clang's unit tests.
- Makes Specifying conditional compilation or other custom logic for JIT
  tests easier.

It did require adding the concept of an explicit 'optional' source file
to the CMake build so that the missing-file check can skip cases where
the file is *supposed* to be missing. =]

This is another chunk of refactoring the CMake build in order to make it
usable for other clients like CompilerRT / ASan / TSan.

Note that this is interdependent with a Clang CMake change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158909 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-21 09:51:26 +00:00
Chandler Carruth
b60182e99b Factor the logic for setting up a GoogleTest unit test executable into
a helper function in CMake. This will allow us to share all of this
logic with Clang, and eventually CompilerRT.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158896 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-21 05:16:58 +00:00
Chandler Carruth
b1081af7a2 Simplify the naming pattern in the unittests' CMake file
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158893 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-21 02:02:48 +00:00
Chandler Carruth
45df6f9e04 Remove one of the LLVM-specific CMake hacks in favor of standard CMake
facilities.

This was only used in one place in LLVM, and was used pervasively (but
with different code!) in Clang. It has no advantages over the standard
CMake facilities and in some cases disadvantages.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158889 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-21 01:35:09 +00:00
Benjamin Kramer
044de9c6f7 Add missing unittest files to the cmake build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158647 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-17 14:42:49 +00:00
Benjamin Kramer
f4e4c30de0 Update CMake build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158601 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-16 10:53:58 +00:00
Chandler Carruth
585de7a1b1 Add support to the alignment support header for conjuring a character
array of a suitable size and alignment for any of a number of different
types to be stored into the character array.

The mechanisms for producing an explicitly aligned type are fairly
complex because this operation is poorly supported on all compilers.
We've spent a fairly significant amount of time experimenting with
different implementations inside of Google, and the one using explicitly
expanded templates has been the most robust.

Credit goes to Nick Lewycky for writing the first 20 versions or so of
this logic we had inside of Google. I based this on the only one to
actually survive. In case anyone is worried, yes we are both explicitly
re-contributing and re-licensing it for LLVM. =]

Once the issues with actually specifying the alignment are finished, it
turns out that most compilers don't in turn align anything the way they
are instructed. Testing of this logic against both Clang and GCC
indicate that the alignment constraints are largely ignored by both
compilers! I've come up with and used a work-around by wrapping each
alignment-hinted type directly in a struct, and using that struct to
align the character array through a union. This elaborate hackery is
terrifying, but I've included testing that caught a terrifying number of
bugs in every other technique I've tried.

All of this in order to implement a poor C++98 programmers emulation of
C++11 unrestricted unions in classes such as SmallDenseMap.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158597 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-16 08:52:57 +00:00
Justin Holewinski
c82fd37bcf Fix gtest build issue on Visual Studio 2012 RC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@158046 91177308-0d34-0410-b5e6-96231b3b80d8
2012-06-06 03:11:20 +00:00
Manuel Klimek
61c3d30015 Goodbye, JSONParser...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154930 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-17 17:21:17 +00:00
Michael J. Spencer
93210e847a Add YAML parser to Support.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153977 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-03 23:09:22 +00:00
Rafael Espindola
092c5ccf5b Handle unreachable code in the dominates functions. This changes users when
needed for correctness, but still doesn't clean up code that now unnecessary
checks for reachability.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153755 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-30 16:46:21 +00:00
Eli Bendersky
f963cd3e02 Follow-up to r152620: restore JIT event listener tests to unittest/ExecutionEngine/JIT
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152780 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-15 06:49:31 +00:00
Eli Bendersky
61b1851a20 Add profiling support for Intel Parallel Amplifier XE (VTune) for JITted code in LLVM.
Also refactor the existing OProfile profiling code to reuse the same interfaces with the VTune profiling code.
In addition, unit tests for the profiling interfaces were added.

This patch was prepared by Andrew Kaylor and Daniel Malea, and reviewed in the llvm-commits list by Jim Grosbach



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152620 91177308-0d34-0410-b5e6-96231b3b80d8
2012-03-13 08:33:15 +00:00
Jakob Stoklund Olesen
62588622d4 Add a Briggs and Torczon sparse set implementation.
For objects that can be identified by small unsigned keys, SparseSet
provides constant time clear() and fast deterministic iteration. Insert,
erase, and find operations are typically faster than hash tables.

SparseSet is useful for keeping information about physical registers,
virtual registers, or numbered basic blocks.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151110 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-22 00:56:08 +00:00
Talin
1a4b19ef9b Hashing.h - utilities for hashing various data types.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150890 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-18 21:00:49 +00:00
Manuel Klimek
41aa108f74 RefCountedBaseVPTR needs the IntrusiveRefCntPtrInfo as friend,
now that this handles the release / retain calls.

Adds a regression test for that bug (which is a compile-time
regression) and for the last two changes to the IntrusiveRefCntPtr,
especially tests for the memory leak due to copy construction of the
ref-counted object and ensuring that the traits are used for release /
retain calls.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149411 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-31 19:58:34 +00:00
Chandler Carruth
972cc0d54a Undo the hack in r147427 and move this unittest to a better home. This
is testing the bitcode reader's functionality, not VMCore's. Add the
what is a hope sufficient build system mojo to build and run a new
unittest.

Also clean up some of the test's naming. The goal for the file should be
to unittest the Bitcode Reader, and this is just one particular test
among potentially many in the future. Also, reverse my position and
relegate the PR# to a comment, but stash the comment on the same line as
the test name so it doesn't get lost. This makes the code more
self-documenting hopefully w/o losing track of the PR number.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147431 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-02 09:19:48 +00:00
Rafael Espindola
47f79bb58e Materialize functions whose basic blocks are used by global variables. Fixes
PR11677.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147425 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-02 07:49:53 +00:00
Manuel Klimek
76f13017fc Adds a JSON parser and a benchmark (json-bench) to catch performance regressions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146735 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-16 13:09:10 +00:00
Chandler Carruth
d916ce3c8e Add a generic collection of class templates to ADT for building
variadic-like functions in C++98. See the comments in the header file
for a more detailed description of how these work. We plan to use these
extensively in the AST matching library. This code and idea were
originally authored by Zhanyong Wan. I've condensed it using macros
to reduce repeatition and adjusted it to fit better with LLVM's ADT.

Thanks to both David Blaikie and Doug Gregor for the review!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146729 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-16 08:58:59 +00:00
NAKAMURA Takumi
de0cfe81b4 Tweak CMake build on Cygwin.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146725 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-16 06:21:08 +00:00
Chris Lattner
1afcace3a3 Land the long talked about "type system rewrite" patch. This
patch brings numerous advantages to LLVM.  One way to look at it
is through diffstat:
 109 files changed, 3005 insertions(+), 5906 deletions(-)

Removing almost 3K lines of code is a good thing.  Other advantages
include:

1. Value::getType() is a simple load that can be CSE'd, not a mutating
   union-find operation.
2. Types a uniqued and never move once created, defining away PATypeHolder.
3. Structs can be "named" now, and their name is part of the identity that
   uniques them.  This means that the compiler doesn't merge them structurally
   which makes the IR much less confusing.
4. Now that there is no way to get a cycle in a type graph without a named
   struct type, "upreferences" go away.
5. Type refinement is completely gone, which should make LTO much MUCH faster
   in some common cases with C++ code.
6. Types are now generally immutable, so we can use "Type *" instead 
   "const Type *" everywhere.

Downsides of this patch are that it removes some functions from the C API,
so people using those will have to upgrade to (not yet added) new API.  
"LLVM 3.0" is the right time to do this.

There are still some cleanups pending after this, this patch is large enough
as-is.




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134829 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-09 17:41:24 +00:00
Argyrios Kyrtzidis
0f5b687075 Add unit tests for ADT/PackedVector
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133075 91177308-0d34-0410-b5e6-96231b3b80d8
2011-06-15 19:19:09 +00:00
Oscar Fuentes
104e99256d Handle gcc-compatible compilers (such as clang) the same way we handle
gcc.

Fixes PR9886.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@131181 91177308-0d34-0410-b5e6-96231b3b80d8
2011-05-11 13:53:08 +00:00
Oscar Fuentes
0b85d07d46 Put targets on folders, if the IDE supports the feature.
Requires CMake 2.8.3 or newer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126092 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-20 22:06:10 +00:00
Oscar Fuentes
3bf2279411 Disable RTTI when building unit tests. This avoids errors at link time.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123377 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-13 15:31:45 +00:00
Jakob Stoklund Olesen
2a6899c539 Add ADT/IntEqClasses.h as a light-weight implementation of EquivalenceClasses.h.
This implementation already exists as ConnectedVNInfoEqClasses in
LiveInterval.cpp, and it seems to be generally useful to have a light-weight way
of forming equivalence classes of small integers.

IntEqClasses doesn't allow enumeration of the elements in a class.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122293 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-21 00:04:46 +00:00
Frits van Bommel
729b2949d7 CMake: Fix warning in gtest header used by unit tests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121127 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-07 10:22:07 +00:00
NAKAMURA Takumi
b3d37e3097 unittests/CMakeLists.txt: Tweak unittests' layout to be identical to GNU build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@121117 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-07 07:41:23 +00:00
Michael J. Spencer
013d15a677 unittests: Merge SystemTests back into SupportTests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120330 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-29 22:29:04 +00:00
Michael J. Spencer
1f6efa3996 Merge System into Support.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120298 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-29 18:16:10 +00:00
NAKAMURA Takumi
b9dec1f928 unittests/JITTests: Don't use --export-dynamic but --export-all-symbols on cygming.
GNU ld/PECOFF accepts but ignores them below;
  --version-script
  --export-dynamic
  --rpath

FIXME: autoconf should be aware of them.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120179 91177308-0d34-0410-b5e6-96231b3b80d8
2010-11-26 09:32:02 +00:00