1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00
Commit Graph

125 Commits

Author SHA1 Message Date
Yaron Keren
8537a3f54c Pass EC by reference to MemoryBufferMMapFile to return error code.
Patch by Kim Grasman!

llvm-svn: 224159
2014-12-12 22:27:53 +00:00
Rafael Espindola
a4ea055f1a Remove a convoluted way of calling close by moving the call to the only caller.
As a bonus we can actually check the return value.

llvm-svn: 224046
2014-12-11 20:12:55 +00:00
Rafael Espindola
ba5f108739 Remove dead code. NFC.
This interface was added 2 years ago but users never developed.

llvm-svn: 223368
2014-12-04 16:59:36 +00:00
Nick Kledzik
8ae11e4491 [Support] Add MemoryBuffer::getFileSlice()
mach-o supports "fat" files which are a header/table-of-contents followed by a
concatenation of mach-o files built for different architectures. Currently, 
MemoryBuffer has no easy way to map a subrange (slice) of a file which lld
will need to select a mach-o slice of a fat file. The new function provides 
an easy way to map a slice of a file into a MemoryBuffer. Test case included.

llvm-svn: 219260
2014-10-08 00:22:18 +00:00
Rafael Espindola
0ca90603b7 Remove the IsVolatileSize parameter of getOpenFileSlice.
getOpenFileSlice gets passed the map size, so it makes no sense to say that
the size is volatile. The code will not even compute the size.

llvm-svn: 219226
2014-10-07 19:09:05 +00:00
Rafael Espindola
9b4288f80d Be consistent about using "const Twine &" for filenames.
On this file we had a mix of
* Twine
* const char *
* StringRef

The two that make sense are
* const Twine & (caller convenience)
* consc char * (that is what will eventually be passed to open.

Given that sys::fs::openFileForRead takes a "const Twine &", I picked that.

llvm-svn: 219224
2014-10-07 18:58:55 +00:00
Rafael Espindola
edb6051959 Return a std::unique_ptr when creating a new MemoryBuffer.
llvm-svn: 216583
2014-08-27 20:03:13 +00:00
Rafael Espindola
225cf75bef Pass a MemoryBufferRef when we can avoid taking ownership.
The attached patch simplifies a few interfaces that don't need to take
ownership of a buffer.

For example, both parseAssembly and parseBitcodeFile will parse the
entire buffer before returning. There is no need to take ownership.

Using a MemoryBufferRef makes it obvious in the type signature that
there is no ownership transfer.

llvm-svn: 216488
2014-08-26 21:49:01 +00:00
Rafael Espindola
08aa78de63 Don't own the buffer in object::Binary.
Owning the buffer is somewhat inflexible. Some Binaries have sub Binaries
(like Archive) and we had to create dummy buffers just to handle that. It is
also a bad fit for IRObjectFile where the Module wants to own the buffer too.

Keeping this ownership would make supporting IR inside native objects
particularly painful.

This patch focuses in lib/Object. If something elsewhere used to own an Binary,
now it also owns a MemoryBuffer.

This patch introduces a few new types.

* MemoryBufferRef. This is just a pair of StringRefs for the data and name.
  This is to MemoryBuffer as StringRef is to std::string.
* OwningBinary. A combination of Binary and a MemoryBuffer. This is needed
  for convenience functions that take a filename and return both the
  buffer and the Binary using that buffer.

The C api now uses OwningBinary to avoid any change in semantics. I will start
a new thread to see if we want to change it and how.

llvm-svn: 216002
2014-08-19 18:44:46 +00:00
Eric Christopher
638a0643ee Fix typo.
llvm-svn: 215266
2014-08-09 00:26:27 +00:00
Eric Christopher
ca5efa5bef Reword comment slightly.
llvm-svn: 215248
2014-08-08 22:09:00 +00:00
Yaron Keren
baaa4b7845 getNewMemBuffer memsets the buffer to zeros,
the caller don't have to initialize it.

llvm-svn: 214994
2014-08-06 20:59:09 +00:00
NAKAMURA Takumi
9474954f12 MemoryBuffer: Don't use mmap when FileSize is multiple of 4k on Cygwin.
On Cygwin, getpagesize() returns 64k(AllocationGranularity).

In r214580, the size of X86GenInstrInfo.inc became 1499136.

FIXME: We should reorganize again getPageSize() on Win32.
MapFile allocates address along AllocationGranularity but view is mapped by physical page.

llvm-svn: 214681
2014-08-04 01:43:37 +00:00
Rafael Espindola
858b9e1423 Update the MemoryBuffer API to use ErrorOr.
llvm-svn: 212405
2014-07-06 17:43:13 +00:00
Rafael Espindola
0df15fc77a Finishing touch for the std::error_code transition.
While std::error_code itself seems to work OK in all platforms, there
are few annoying differences with regards to the std::errc enumeration.

This patch adds a simple llvm enumeration, which will hopefully avoid build
breakages in other platforms and surprises as we get more uses of
std::error_code.

llvm-svn: 210920
2014-06-13 17:20:48 +00:00
Rafael Espindola
251ce700f0 Fix build on windows.
llvm-svn: 210873
2014-06-13 02:36:09 +00:00
Rafael Espindola
98710599c1 Remove 'using std::errro_code' from lib.
llvm-svn: 210871
2014-06-13 02:24:39 +00:00
Rafael Espindola
e0e308ff6d Don't use 'using std::error_code' in include/llvm.
This should make sure that most new uses use the std prefix.

llvm-svn: 210835
2014-06-12 21:46:39 +00:00
Rafael Espindola
38dc624425 Remove system_error.h.
This is a minimal change to remove the header. I will remove the occurrences
of "using std::error_code" in a followup patch.

llvm-svn: 210803
2014-06-12 17:38:55 +00:00
Rafael Espindola
d004f0c75f Don't import make_error_code into the llvm namespace.
llvm-svn: 210772
2014-06-12 11:58:49 +00:00
Rafael Espindola
6c13f4b607 Don't put generic_category in the llvm namespace.
llvm-svn: 210737
2014-06-12 02:00:39 +00:00
Rafael Espindola
cb080681ac Use std::error_code instead of llvm::error_code.
The idea of this patch is to turn llvm/Support/system_error.h into a
transitional header that just brings in the erorr_code api to the llvm
namespace. I will remove it shortly afterwards.

The cases where the general idea needed some tweaking:

* std::errc is a namespace in msvc, so we cannot use "using std::errc". I could
add an #ifdef, but there were not that many uses, so I just added std:: to
them in this patch.

* Template specialization had to be moved to the std namespace in this
patch set already.

* The msvc implementation of default_error_condition doesn't seem to
provide the same transformations as we need. Not too surprising since
the standard doesn't actually say what "equivalent" means. I fixed the
problem by keeping our old mapping and using it at error_code
construction time.

Despite these shortcomings I think this is still a good thing. Some reasons:

* The different implementations of system_error might improve over time.
* It removes 925 lines of code from llvm already.
* It removes 6313 bytes from the text segment of the clang binary when
it is built with gcc and 2816 bytes when building with clang and
libstdc++.

llvm-svn: 210687
2014-06-11 19:05:50 +00:00
Rafael Espindola
c056dd8e2e There is no posix_category in std, use generic_category.
llvm-svn: 210630
2014-06-11 03:49:13 +00:00
Rafael Espindola
c86cc04638 Use error_code() instead of error_code::succes()
There is no std::error_code::success, so this removes much of the noise
in transitioning to std::error_code.

llvm-svn: 209952
2014-05-31 01:37:45 +00:00
Alp Toker
458db09b36 MemoryBuffer: Use GetNativeSystemInfo()
Removes old 4096 byte workaround. This functionality has been available since
Windows XP.

llvm-svn: 209137
2014-05-19 16:13:28 +00:00
Craig Topper
cbd5e36c2e Remove last uses of OwningPtr from llvm. As far as I can tell these method versions are not used by lldb, lld, or clang.
llvm-svn: 209103
2014-05-18 21:55:38 +00:00
Alp Toker
ece806e295 MemoryBuffer: don't force mmap when stat fails
Fix error handling introduced in r127426 that could result in MemoryBuffers not
having null termination.

llvm-svn: 208396
2014-05-09 08:57:32 +00:00
Alp Toker
0c76c7e110 MemoryBuffer: remove unusued definitions
These were made redundant back in r186560.

llvm-svn: 208395
2014-05-09 08:57:06 +00:00
Argyrios Kyrtzidis
e529889ad4 [Support/MemoryBuffer] Remove the assertion that the file size did not shrink.
This can happen in practice with the user changing files and we can recover from it.

llvm-svn: 208143
2014-05-06 23:30:56 +00:00
Argyrios Kyrtzidis
99abb688e5 [Support/MemoryBuffer] Rename IsVolatile -> IsVolatileSize and add a comment about the use case for the new parameter.
llvm-svn: 208026
2014-05-06 01:03:52 +00:00
Argyrios Kyrtzidis
4c9d588352 [Support/MemoryBuffer] Move the IsVolatile check inside shouldUseMmap() and make sure to zero-initialize the rest
of the buffer if we unexpectedly reach end-of-file while reading.

llvm-svn: 208021
2014-05-06 00:51:45 +00:00
Argyrios Kyrtzidis
81db8ad5a3 [Support/MemoryBuffer] Introduce a boolean parameter (false by default) 'IsVolatile' for the open file functions.
This provides a hint that the file may be changing often so mmap is avoided.

llvm-svn: 208007
2014-05-05 21:55:51 +00:00
Craig Topper
ee78063a54 [C++11] Make use of 'nullptr' in the Support library.
llvm-svn: 205697
2014-04-07 04:17:22 +00:00
Craig Topper
813f30aa7e [C++11] Remove 'virtual' keyword from methods marked with 'override' keyword.
llvm-svn: 203442
2014-03-10 03:53:12 +00:00
Ahmed Charles
afa05d8aeb [C++11] Add overloads for externally used OwningPtr functions.
This will allow external callers of these functions to switch over time
rather than forcing a breaking change all a once. These particular
functions were determined by building clang/lld/lldb.

llvm-svn: 202959
2014-03-05 10:27:34 +00:00
Craig Topper
b0056a4ca7 Switch all uses of LLVM_OVERRIDE to just use 'override' directly.
llvm-svn: 202621
2014-03-02 09:09:27 +00:00
Reid Kleckner
90e91bce3c MemoryBuffer: Increase the alignment of small file buffers to 16
This was manifesting as an LLVM_ASSUME_ALIGNED() failure in an ELF debug
info test when building LLVM with clang in the Microsoft C++ ABI.

llvm-svn: 197401
2013-12-16 18:18:12 +00:00
Rafael Espindola
1587321957 Change MemoryBuffer::getFile to take a Twine.
llvm-svn: 193429
2013-10-25 19:06:52 +00:00
Matt Arsenault
b0f1ee38b1 Fix typo
llvm-svn: 190424
2013-09-10 19:54:54 +00:00
NAKAMURA Takumi
edaf5b018a MemoryBuffer.cpp: Don't peek the next page if file is multiple of *physical* pagesize(4k) but is not multiple of AllocationGranularity(64k), when a null terminator is required, on cygwin and win32.
For example, r189780's SparcISelLowering.cpp has the size 98304. It crashed clang to touch a null terminator on cygwin.

FIXME: It's not good to hardcode 4096 here. dwPageSize shows 4096.
llvm-svn: 189939
2013-09-04 14:12:19 +00:00
NAKAMURA Takumi
54def2fa6a Whitespace.
llvm-svn: 189938
2013-09-04 14:12:12 +00:00
NAKAMURA Takumi
6cb92d92f5 MemoryBuffer.cpp: Consider if PageSize were not 4096 in shouldUseMmap(). Follow-up to r188903.
The AllocationGranularity can be 65536 on Win32, even on Cygwin.

llvm-svn: 188998
2013-08-22 10:23:52 +00:00
Rafael Espindola
f3a9f67eee Split getOpenFile into getOpenFile and getOpenFileSlice.
The main observation is that we never need both the filesize and the map size.
When mapping a slice of a file, it doesn't make sense to request a null
terminator and that would be the only case where the filesize would be used.

There are other cleanups that should be done in this area:

* A client should not have to pass the size (even an explicit -1) to say if
  it wants a null terminator or not, so we should probably swap the argument
  order.
* The default should be to not require a null terminator. Very few clients
  require this, but many end up asking for it just because it is the default.

llvm-svn: 186984
2013-07-23 20:25:01 +00:00
Rafael Espindola
2b878ea43e Convert two uses if fstat with sys::fs::status.
llvm-svn: 186560
2013-07-18 03:04:20 +00:00
Rafael Espindola
2a9326a78f Add a wrapper for open.
This centralizes the handling of O_BINARY and opens the way for hiding more
differences (like how open behaves with directories).

llvm-svn: 186447
2013-07-16 19:44:17 +00:00
Rafael Espindola
c2b60523ef Remove an extra is_directory call.
I checked that opening a directory on windows does fail, so this saves a "stat".

llvm-svn: 186345
2013-07-15 20:52:01 +00:00
Rafael Espindola
35fe018057 keep only the StringRef version of getFileOrSTDIN.
llvm-svn: 184826
2013-06-25 05:28:34 +00:00
Rafael Espindola
5b921b1aa1 Remove the program class.
It was only used to implement ExecuteAndWait and ExecuteNoWait. Expose just
those two functions and make Execute and Wait implementations details.

llvm-svn: 183864
2013-06-12 20:58:35 +00:00
Rafael Espindola
528e53f9f1 Remove the old file memory mapping functions.
llvm-svn: 183828
2013-06-12 14:11:15 +00:00
Benjamin Kramer
19e3b89136 Put private class into an anonmyous namespace.
llvm-svn: 178420
2013-03-30 15:23:08 +00:00