Commit Graph

23 Commits

Author SHA1 Message Date
David Majnemer 7fddeccb8b Move the personality function from LandingPadInst to Function
The personality routine currently lives in the LandingPadInst.

This isn't desirable because:
- All LandingPadInsts in the same function must have the same
  personality routine.  This means that each LandingPadInst beyond the
  first has an operand which produces no additional information.

- There is ongoing work to introduce EH IR constructs other than
  LandingPadInst.  Moving the personality routine off of any one
  particular Instruction and onto the parent function seems a lot better
  than have N different places a personality function can sneak onto an
  exceptional function.

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

llvm-svn: 239940
2015-06-17 20:52:32 +00:00
Rafael Espindola dcd1dca275 Return a unique_ptr from getLazyBitcodeModule and parseBitcodeFile. NFC.
llvm-svn: 239858
2015-06-16 22:27:55 +00:00
Duncan P. N. Exon Smith c4f0a325a7 uselistorder: Pull the assembly bit up out of the printer
Pull the `-preserve-ll-uselistorder` bit up through all the callers of
`Module::print()`.  I converted callers of `operator<<` to
`Module::print()` where necessary to pull the bit through.

llvm-svn: 234968
2015-04-15 02:12:41 +00:00
Duncan P. N. Exon Smith a052ed6381 uselistorder: Pull the bit through WriteToBitcodFile()
Change the callers of `WriteToBitcodeFile()` to pass `true` or
`shouldPreserveBitcodeUseListOrder()` explicitly.  I left the callers
that want to send `false` alone.

I'll keep pushing the bit higher until hopefully I can delete the global
`cl::opt` entirely.

llvm-svn: 234957
2015-04-15 00:10:50 +00:00
Duncan P. N. Exon Smith d672d73a16 verify-uselistorder: More outs() and errs(), less dbgs()
Change all the normally relevant output in `verify-uselistorder` from
using `dbgs()` to using `outs()` and `errs()`.  Now you don't need
`-debug=uselistorder` to figure out what's going on (or at what stage
verification failed, or to get the paths of the left-behind temporary
files).  This is a debugging tool, so I put the logging messages on
`outs()` and the error messages on `errs()`.

I also adjusted the output to be less ***loud***.  Not sure why I was so
`*`-happy when I first wrote this.

llvm-svn: 234929
2015-04-14 19:04:03 +00:00
Duncan P. N. Exon Smith 8d2aff07da IR: Rename 'use-list-order' options to 'uselistorder'
Rename options to be consistent with the name of `verify-uselistorder`,
and update `DEBUG_TYPE` (etc.) to be consistent.

llvm-svn: 234919
2015-04-14 18:19:27 +00:00
Duncan P. N. Exon Smith 4628282fac tools: Unify how verifyModule() is called
Unify the error messages for the various tools when `verifyModule()`
fails on an input module.  The "brave new way" is:

    lltool: path/to/input.ll: error: input module is broken!

llvm-svn: 233667
2015-03-31 03:07:23 +00:00
Benjamin Kramer 16132e6faa Purge unused includes throughout libSupport.
NFC.

llvm-svn: 232976
2015-03-23 18:07:13 +00:00
Peter Collingbourne 51d2de7b9e Prologue support
Patch by Ben Gamari!

This redefines the `prefix` attribute introduced previously and
introduces a `prologue` attribute.  There are a two primary usecases
that these attributes aim to serve,

  1. Function prologue sigils

  2. Function hot-patching: Enable the user to insert `nop` operations
     at the beginning of the function which can later be safely replaced
     with a call to some instrumentation facility

  3. Runtime metadata: Allow a compiler to insert data for use by the
     runtime during execution. GHC is one example of a compiler that
     needs this functionality for its tables-next-to-code functionality.

Previously `prefix` served cases (1) and (2) quite well by allowing the user
to introduce arbitrary data at the entrypoint but before the function
body. Case (3), however, was poorly handled by this approach as it
required that prefix data was valid executable code.

Here we redefine the notion of prefix data to instead be data which
occurs immediately before the function entrypoint (i.e. the symbol
address). Since prefix data now occurs before the function entrypoint,
there is no need for the data to be valid code.

The previous notion of prefix data now goes under the name "prologue
data" to emphasize its duality with the function epilogue.

The intention here is to handle cases (1) and (2) with prologue data and
case (3) with prefix data.

References
----------

This idea arose out of discussions[1] with Reid Kleckner in response to a
proposal to introduce the notion of symbol offsets to enable handling of
case (3).

[1] http://lists.cs.uiuc.edu/pipermail/llvmdev/2014-May/073235.html

Test Plan: testsuite

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

llvm-svn: 223189
2014-12-03 02:08:38 +00:00
Rafael Espindola d96d553d76 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 d233b06afc Return a std::unique_ptr from the IRReader.h functions. NFC.
llvm-svn: 216466
2014-08-26 17:29:46 +00:00
Rafael Espindola 3fd1e9933f Modernize raw_fd_ostream's constructor a bit.
Take a StringRef instead of a "const char *".
Take a "std::error_code &" instead of a "std::string &" for error.

A create static method would be even better, but this patch is already a bit too
big.

llvm-svn: 216393
2014-08-25 18:16:47 +00:00
Duncan P. N. Exon Smith 0a448fbca3 IR: Implement uselistorder assembly directives
Implement `uselistorder` and `uselistorder_bb` assembly directives,
which allow the use-list order to be recovered when round-tripping to
assembly.

This is the bulk of PR20515.

llvm-svn: 216025
2014-08-19 21:30:15 +00:00
Duncan P. N. Exon Smith c8eccd1147 verify-uselistorder: Force -preserve-bc-use-list-order
llvm-svn: 216022
2014-08-19 21:08:27 +00:00
Rafael Espindola 11c07d7eec Modernize the .ll parsing interface.
* Use StringRef instead of std::string&
* Return a std::unique_ptr<Module> instead of taking an optional module to write
  to (was not really used).
* Use current comment style.
* Use current naming convention.

llvm-svn: 215989
2014-08-19 16:58:54 +00:00
Duncan P. N. Exon Smith 8e3669586b verify-uselistorder: Call verifyModule() and improve output
Call `verifyModule()` after parsing and after every transformation.
Also convert some `DEBUG(dbgs())` to `errs()` to increase visibility
into what's going on.

llvm-svn: 215951
2014-08-18 23:44:14 +00:00
Duncan P. N. Exon Smith a5a8d3f6f2 verify-uselistorder: Reverse use-lists at every verification
Updated `verify-uselistorder` to more than double the number of use-list
orders it checks.

  - Every time it verifies an order, it then reverses the order and
    verifies again.

  - It now verifies the initial order, before running any shuffles.

Changed the default to `-num-shuffles=1`, since this is already four
checks, and after r214584 shuffling is guaranteed to make a new order.

This is part of PR5680.

llvm-svn: 214596
2014-08-01 23:49:41 +00:00
Duncan P. N. Exon Smith 9a2017bfc3 verify-uselistorder: Add missing `static`
llvm-svn: 214595
2014-08-01 23:31:13 +00:00
Duncan P. N. Exon Smith 3da117d272 verify-uselistorder: Move shuffleUseLists() out of lib/IR
`shuffleUseLists()` is only used in `verify-uselistorder`, so move it
there to avoid bloating other executables.  As a drive-by, update some
of the header docs.

This is part of PR5680.

llvm-svn: 214592
2014-08-01 23:03:36 +00:00
Duncan P. N. Exon Smith 36d57a2303 verify-uselistorder: Make the verification logic easier to reuse
llvm-svn: 214587
2014-08-01 22:52:06 +00:00
Rafael Espindola 3f6481d0d3 Remove some calls to std::move.
Instead of moving out the data in a ErrorOr<std::unique_ptr<Foo>>, get
a reference to it.

Thanks to David Blaikie for the suggestion.

llvm-svn: 214516
2014-08-01 14:31:55 +00:00
Duncan P. N. Exon Smith 852e00e3d1 verify-uselistorder: Change the default -num-shuffles=5
Change the default for `-num-shuffles` to 5 and better document the
algorithm in the header docs of `verify-uselistorder`.

llvm-svn: 214419
2014-07-31 18:46:24 +00:00
Duncan P. N. Exon Smith a12e023c8a Rename llvm-uselistorder => verify-uselistorder
llvm-svn: 214318
2014-07-30 17:11:27 +00:00