Prologue support
authorPeter Collingbourne <peter@pcc.me.uk>
Wed, 3 Dec 2014 02:08:38 +0000 (02:08 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Wed, 3 Dec 2014 02:08:38 +0000 (02:08 +0000)
commitbb660fc192c341012f5f1686b6792be807a6d38b
tree440eba4cfbe3ff6a3dedcc49d203c2e68392ce0b
parent8cc929ea00078e2bd71945ce0e34775f6a38d170
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223189 91177308-0d34-0410-b5e6-96231b3b80d8
24 files changed:
docs/BitCodeFormat.rst
docs/LangRef.rst
docs/ReleaseNotes.rst
include/llvm/IR/Function.h
lib/AsmParser/LLLexer.cpp
lib/AsmParser/LLParser.cpp
lib/AsmParser/LLToken.h
lib/Bitcode/Reader/BitcodeReader.cpp
lib/Bitcode/Reader/BitcodeReader.h
lib/Bitcode/Writer/BitcodeWriter.cpp
lib/Bitcode/Writer/ValueEnumerator.cpp
lib/CodeGen/AsmPrinter/AsmPrinter.cpp
lib/IR/AsmWriter.cpp
lib/IR/Function.cpp
lib/IR/LLVMContextImpl.h
lib/IR/TypeFinder.cpp
lib/Linker/LinkModules.cpp
lib/Transforms/IPO/GlobalDCE.cpp
test/CodeGen/X86/prefixdata.ll
test/CodeGen/X86/prologuedata.ll [new file with mode: 0644]
test/Feature/prologuedata.ll [new file with mode: 0644]
test/Linker/prefixdata.ll [deleted file]
test/Linker/prologuedata.ll [new file with mode: 0644]
tools/verify-uselistorder/verify-uselistorder.cpp