summaryrefslogtreecommitdiff
path: root/unittests/ExecutionEngine
diff options
context:
space:
mode:
authorDaniel Malea <daniel.malea@intel.com>2013-06-28 20:37:20 +0000
committerDaniel Malea <daniel.malea@intel.com>2013-06-28 20:37:20 +0000
commit5fa8186b8dcc0be77f4ab64b1ef46ad919315b54 (patch)
tree22b3d235e9173e85d46a31943ff2bce28a6613f7 /unittests/ExecutionEngine
parent74cf767093d3dd46dc3c7cf5666060e8c1ee0be0 (diff)
downloadllvm-5fa8186b8dcc0be77f4ab64b1ef46ad919315b54.tar.gz
llvm-5fa8186b8dcc0be77f4ab64b1ef46ad919315b54.tar.bz2
llvm-5fa8186b8dcc0be77f4ab64b1ef46ad919315b54.tar.xz
Adding tests for DebugIR pass
- lit tests verify that each line of input LLVM IR gets a !dbg node and a corresponding entry of metadata that contains the line number - unit tests verify that DebugIR works as advertised in the interface - refactored some useful IR generation functionality from the MCJIT unit tests so it can be reused git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185212 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/ExecutionEngine')
-rw-r--r--unittests/ExecutionEngine/MCJIT/MCJITTestBase.h77
1 files changed, 43 insertions, 34 deletions
diff --git a/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h b/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h
index 8edc12a14f..9766a79ae5 100644
--- a/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h
+++ b/unittests/ExecutionEngine/MCJIT/MCJITTestBase.h
@@ -30,42 +30,19 @@
namespace llvm {
-class MCJITTestBase : public MCJITTestAPICommon {
+/// Helper class that can build very simple Modules
+class TrivialModuleBuilder {
protected:
+ LLVMContext Context;
+ IRBuilder<> Builder;
+ std::string BuilderTriple;
- MCJITTestBase()
- : OptLevel(CodeGenOpt::None)
- , RelocModel(Reloc::Default)
- , CodeModel(CodeModel::Default)
- , MArch("")
- , Builder(Context)
- , MM(new SectionMemoryManager)
- {
- // The architectures below are known to be compatible with MCJIT as they
- // are copied from test/ExecutionEngine/MCJIT/lit.local.cfg and should be
- // kept in sync.
- SupportedArchs.push_back(Triple::aarch64);
- SupportedArchs.push_back(Triple::arm);
- SupportedArchs.push_back(Triple::x86);
- SupportedArchs.push_back(Triple::x86_64);
-
- // Some architectures have sub-architectures in which tests will fail, like
- // ARM. These two vectors will define if they do have sub-archs (to avoid
- // extra work for those who don't), and if so, if they are listed to work
- HasSubArchs.push_back(Triple::arm);
- SupportedSubArchs.push_back("armv6");
- SupportedSubArchs.push_back("armv7");
-
- // The operating systems below are known to be incompatible with MCJIT as
- // they are copied from the test/ExecutionEngine/MCJIT/lit.local.cfg and
- // should be kept in sync.
- UnsupportedOSs.push_back(Triple::Cygwin);
- UnsupportedOSs.push_back(Triple::Darwin);
- }
+ TrivialModuleBuilder(const std::string &Triple)
+ : Builder(Context), BuilderTriple(Triple) {}
- Module *createEmptyModule(StringRef Name) {
+ Module *createEmptyModule(StringRef Name = StringRef()) {
Module * M = new Module(Name, Context);
- M->setTargetTriple(Triple::normalize(HostTriple));
+ M->setTargetTriple(Triple::normalize(BuilderTriple));
return M;
}
@@ -161,6 +138,40 @@ protected:
name);
return Global;
}
+};
+
+class MCJITTestBase : public MCJITTestAPICommon, public TrivialModuleBuilder {
+protected:
+
+ MCJITTestBase()
+ : TrivialModuleBuilder(HostTriple)
+ , OptLevel(CodeGenOpt::None)
+ , RelocModel(Reloc::Default)
+ , CodeModel(CodeModel::Default)
+ , MArch("")
+ , MM(new SectionMemoryManager)
+ {
+ // The architectures below are known to be compatible with MCJIT as they
+ // are copied from test/ExecutionEngine/MCJIT/lit.local.cfg and should be
+ // kept in sync.
+ SupportedArchs.push_back(Triple::aarch64);
+ SupportedArchs.push_back(Triple::arm);
+ SupportedArchs.push_back(Triple::x86);
+ SupportedArchs.push_back(Triple::x86_64);
+
+ // Some architectures have sub-architectures in which tests will fail, like
+ // ARM. These two vectors will define if they do have sub-archs (to avoid
+ // extra work for those who don't), and if so, if they are listed to work
+ HasSubArchs.push_back(Triple::arm);
+ SupportedSubArchs.push_back("armv6");
+ SupportedSubArchs.push_back("armv7");
+
+ // The operating systems below are known to be incompatible with MCJIT as
+ // they are copied from the test/ExecutionEngine/MCJIT/lit.local.cfg and
+ // should be kept in sync.
+ UnsupportedOSs.push_back(Triple::Cygwin);
+ UnsupportedOSs.push_back(Triple::Darwin);
+ }
void createJIT(Module *M) {
@@ -186,14 +197,12 @@ protected:
assert(TheJIT.get() != NULL && "error creating MCJIT with EngineBuilder");
}
- LLVMContext Context;
CodeGenOpt::Level OptLevel;
Reloc::Model RelocModel;
CodeModel::Model CodeModel;
StringRef MArch;
SmallVector<std::string, 1> MAttrs;
OwningPtr<ExecutionEngine> TheJIT;
- IRBuilder<> Builder;
RTDyldMemoryManager *MM;
OwningPtr<Module> M;