Transform: add SymbolRewriter pass

This introduces the symbol rewriter. This is an IR->IR transformation that is
implemented as a CodeGenPrepare pass. This allows for the transparent
adjustment of the symbols during compilation.

It provides a clean, simple, elegant solution for symbol inter-positioning. This
technique is often used, such as in the various sanitizers and performance
analysis.

The control of this is via a custom YAML syntax map file that indicates source
to destination mapping, so as to avoid having the compiler to know the exact
details of the source to destination transformations.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221548 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Saleem Abdulrasool
2014-11-07 21:32:08 +00:00
parent 049368273b
commit 35c163020a
10 changed files with 822 additions and 2 deletions

View File

@ -371,8 +371,11 @@ public:
/// does not exist, return null. If AllowInternal is set to true, this
/// function will return types that have InternalLinkage. By default, these
/// types are not returned.
const GlobalVariable *getGlobalVariable(StringRef Name,
bool AllowInternal = false) const {
GlobalVariable *getGlobalVariable(StringRef Name) const {
return getGlobalVariable(Name, false);
}
GlobalVariable *getGlobalVariable(StringRef Name, bool AllowInternal) const {
return const_cast<Module *>(this)->getGlobalVariable(Name, AllowInternal);
}
@ -564,6 +567,13 @@ public:
size_t size() const { return FunctionList.size(); }
bool empty() const { return FunctionList.empty(); }
iterator_range<iterator> functions() {
return iterator_range<iterator>(begin(), end());
}
iterator_range<const_iterator> functions() const {
return iterator_range<const_iterator>(begin(), end());
}
/// @}
/// @name Alias Iteration
/// @{