//
//===----------------------------------------------------------------------===//
-#include "llvm/Analysis/Verifier.h"
+#include "llvm/IR/Verifier.h"
#include "llvm/ExecutionEngine/MCJIT.h"
#include "llvm/ExecutionEngine/SectionMemoryManager.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/Module.h"
-#include "llvm/PassManager.h"
#include "llvm/Support/Dwarf.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Target/TargetOptions.h"
/// This function is the struct _Unwind_Exception API mandated delete function
/// used by foreign exception handlers when deleting our exception
/// (OurException), instances.
-/// @param reason @link http://mentorembedded.github.com/cxx-abi/abi-eh.html
+/// @param reason See @link http://mentorembedded.github.com/cxx-abi/abi-eh.html
/// @unlink
/// @param expToDelete exception instance to delete
void deleteFromUnwindOurException(_Unwind_Reason_Code reason,
new llvm::GlobalVariable(module,
stringConstant->getType(),
true,
- llvm::GlobalValue::LinkerPrivateLinkage,
+ llvm::GlobalValue::PrivateLinkage,
stringConstant,
"");
}
new llvm::GlobalVariable(module,
stringConstant->getType(),
true,
- llvm::GlobalValue::LinkerPrivateLinkage,
+ llvm::GlobalValue::PrivateLinkage,
stringConstant,
"");
}
return(outerCatchFunct);
}
-
+namespace {
/// Represents our foreign exceptions
class OurCppRunException : public std::runtime_error {
public:
std::runtime_error::operator=(toCopy)));
}
- ~OurCppRunException (void) throw () {}
+ virtual ~OurCppRunException (void) throw () {}
};
-
+} // end anonymous namespace
/// Throws foreign C++ exception.
/// @param ignoreIt unused parameter that allows function to match implied
llvm::IRBuilder<> theBuilder(context);
// Make the module, which holds all the code.
- llvm::Module *module = new llvm::Module("my cool jit", context);
+ std::unique_ptr<llvm::Module> Owner =
+ llvm::make_unique<llvm::Module>("my cool jit", context);
+ llvm::Module *module = Owner.get();
- llvm::RTDyldMemoryManager *MemMgr = new llvm::SectionMemoryManager();
+ std::unique_ptr<llvm::RTDyldMemoryManager> MemMgr(new llvm::SectionMemoryManager());
// Build engine with JIT
- llvm::EngineBuilder factory(module);
+ llvm::EngineBuilder factory(std::move(Owner));
factory.setEngineKind(llvm::EngineKind::JIT);
- factory.setAllocateGVsWithCode(false);
factory.setTargetOptions(Opts);
- factory.setMCJITMemoryManager(MemMgr);
- factory.setUseMCJIT(true);
+ factory.setMCJITMemoryManager(std::move(MemMgr));
llvm::ExecutionEngine *executionEngine = factory.create();
{
// Set up the optimizer pipeline.
// Start with registering info about how the
// target lays out data structures.
- fpm.add(new llvm::DataLayout(*executionEngine->getDataLayout()));
+ module->setDataLayout(executionEngine->getDataLayout());
+ fpm.add(new llvm::DataLayoutPass());
// Optimizations turned on
#ifdef ADD_OPT_PASSES