f2da5f7cb7
They are usually provided by clang's BackendUtil - which we don't use and which has no support for incremental ("streaming") compilation but runs the passes on the whole module the whole time, and does end-of-TU cleanup (e.g. "dead" code removal) that we cannot use because subsequent transactions might create new uses - think force_inline functions that must stay. Instead BackendPass wraps what's in clang's BackendUtil into a TransactionTransformer. It gets added to the IR transformers. In the future this should only transform the delta of one Transaction instead of the whole Module. This fixes the libc++ issue we worked around by templates' symbols are not exported anymore and cause missing symbols with XCode 5.1. We include ObjC passes even though this blows up the list of linked libraries to make it easier to port cling to ObjC(++).
78 lines
2.5 KiB
C++
78 lines
2.5 KiB
C++
//--------------------------------------------------------------------*- C++ -*-
|
|
// CLING - the C++ LLVM-based InterpreterG :)
|
|
// author: Vassil Vassilev <vvasilev@cern.ch>
|
|
//
|
|
// This file is dual-licensed: you can choose to license it under the University
|
|
// of Illinois Open Source License or the GNU Lesser General Public License. See
|
|
// LICENSE.TXT for details.
|
|
//------------------------------------------------------------------------------
|
|
|
|
#ifndef CLING_TRANSACTION_BACKENDPASS_H
|
|
#define CLING_TRANSACTION_BACKENDPASS_H
|
|
|
|
#include "llvm/ADT/OwningPtr.h"
|
|
|
|
#include "TransactionTransformer.h"
|
|
|
|
namespace clang {
|
|
class CodeGenOptions;
|
|
class DiagnosticsEngine;
|
|
class LangOptions;
|
|
class TargetOptions;
|
|
}
|
|
namespace llvm {
|
|
namespace legacy {
|
|
class FunctionPassManager;
|
|
class PassManager;
|
|
}
|
|
using legacy::FunctionPassManager;
|
|
using legacy::PassManager;
|
|
class Module;
|
|
class Target;
|
|
class TargetMachine;
|
|
}
|
|
|
|
namespace cling {
|
|
|
|
///\brief Run the backend passes. A stripped-down, streaming version
|
|
/// of what's used by clang's BackendUtil. Implements no CodeGenPasses and
|
|
/// no PerModulePasses.
|
|
class BackendPass: public TransactionTransformer {
|
|
llvm::Module* m_Module;
|
|
llvm::OwningPtr<llvm::FunctionPassManager> m_PerFunctionPasses;
|
|
llvm::OwningPtr<llvm::PassManager> m_PerModulePasses;
|
|
llvm::OwningPtr<llvm::TargetMachine> m_TM;
|
|
|
|
public:
|
|
///\brief Initializes a new transaction transformer.
|
|
///
|
|
///\param[in] S - The semantic analysis object.
|
|
///
|
|
BackendPass(clang::Sema* S, llvm::Module* M,
|
|
clang::DiagnosticsEngine& Diags,
|
|
const clang::TargetOptions& TOpts,
|
|
const clang::LangOptions& LangOpts,
|
|
const clang::CodeGenOptions& CodeGenOpts);
|
|
virtual ~BackendPass();
|
|
|
|
protected:
|
|
///\brief Transforms the current transaction.
|
|
///
|
|
void Transform() override;
|
|
|
|
void CreatePasses(const clang::LangOptions& LangOpts,
|
|
const clang::CodeGenOptions& CodeGenOpts);
|
|
/// CreateTargetMachine - Generates the TargetMachine.
|
|
/// Returns Null if it is unable to create the target machine.
|
|
llvm::TargetMachine*
|
|
CreateTargetMachine(clang::DiagnosticsEngine& Diags,
|
|
const clang::TargetOptions &TOpts,
|
|
const clang::LangOptions& LangOpts,
|
|
const clang::CodeGenOptions& CodeGenOpts);
|
|
|
|
llvm::FunctionPassManager *getPerFunctionPasses();
|
|
llvm::PassManager *getPerModulePasses();
|
|
};
|
|
} // end namespace cling
|
|
#endif // CLING_TRANSACTION_TRANSFORMER_H
|