diff --git a/builtins.cpp b/builtins.cpp index 56b69447..87c5b55e 100644 --- a/builtins.cpp +++ b/builtins.cpp @@ -66,7 +66,7 @@ #include #include #endif -#if defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ #include #else #include @@ -705,7 +705,8 @@ AddBitcodeToModule(const unsigned char *bitcode, int length, llvm::Module *module, SymbolTable *symbolTable) { llvm::StringRef sb = llvm::StringRef((char *)bitcode, length); llvm::MemoryBuffer *bcBuf = llvm::MemoryBuffer::getMemBuffer(sb); -#if defined(LLVM_3_5) || defined(LLVM_3_6) + +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ llvm::ErrorOr ModuleOrErr = llvm::parseBitcodeFile(bcBuf, *g->ctx); if (std::error_code EC = ModuleOrErr.getError()) Error(SourcePos(), "Error parsing stdlib bitcode: %s", EC.message().c_str()); @@ -762,7 +763,7 @@ AddBitcodeToModule(const unsigned char *bitcode, int length, // architecture and investigate what happened. // Generally we allow library DataLayout to be subset of module // DataLayout or library DataLayout to be empty. -#if defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ if (!VerifyDataLayoutCompatibility(module->getDataLayoutStr(), bcModule->getDataLayoutStr())) { Warning(SourcePos(), "Module DataLayout is incompatible with " diff --git a/ctx.cpp b/ctx.cpp index b6d0d2c5..eb681d4c 100644 --- a/ctx.cpp +++ b/ctx.cpp @@ -1546,7 +1546,7 @@ FunctionEmitContext::StartScope() { llvm::DILexicalBlock lexicalBlock = m->diBuilder->createLexicalBlock(parentScope, diFile, currentPos.first_line, -#if defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ // Revision 202736 in LLVM adds support of DWARF discriminator // to the last argument and revision 202737 in clang adds 0 // for the last argument by default. diff --git a/ctx.h b/ctx.h index 288b9af3..5df2e23c 100644 --- a/ctx.h +++ b/ctx.h @@ -47,7 +47,7 @@ #include #include #endif -#if defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ #include #include #else diff --git a/expr.cpp b/expr.cpp index 8a82a1f8..80398ab5 100644 --- a/expr.cpp +++ b/expr.cpp @@ -74,7 +74,7 @@ #include #endif #include -#if defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ #include #else #include diff --git a/func.cpp b/func.cpp index fb3a75b2..7412c560 100644 --- a/func.cpp +++ b/func.cpp @@ -69,7 +69,7 @@ #include #include #include -#if defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ #include #include #include @@ -476,7 +476,8 @@ Function::GenerateIR() { } if (m->errorCount == 0) { -#if defined (LLVM_3_5) || defined(LLVM_3_6) + +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ if (llvm::verifyFunction(*function) == true) { #else if (llvm::verifyFunction(*function, llvm::ReturnStatusAction) == true) { @@ -523,7 +524,8 @@ Function::GenerateIR() { emitCode(&ec, appFunction, firstStmtPos); if (m->errorCount == 0) { sym->exportedFunction = appFunction; -#if defined(LLVM_3_5) || defined(LLVM_3_6) + +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ if (llvm::verifyFunction(*appFunction) == true) { #else if (llvm::verifyFunction(*appFunction, diff --git a/ispc.cpp b/ispc.cpp index 593b1452..b6d7b00a 100644 --- a/ispc.cpp +++ b/ispc.cpp @@ -57,7 +57,7 @@ #include #include #endif -#if defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ #include #include #else diff --git a/main.cpp b/main.cpp index 256b5f4a..3510d548 100644 --- a/main.cpp +++ b/main.cpp @@ -166,7 +166,8 @@ devUsage(int ret) { printf(" disable-uniform-memory-optimizations\tDisable uniform-based coherent memory access\n"); printf(" [--yydebug]\t\t\t\tPrint debugging information during parsing\n"); printf(" [--debug-phase=]\t\tSet optimization phases to dump. --debug-phase=first,210:220,300,305,310:last\n"); -#if defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6) + +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) // LLVM 3.4+ printf(" [--debug-ir=]\t\tSet optimization phase to generate debugIR after it\n"); #endif printf(" [--off-phase=]\t\tSwitch off optimization phases. --off-phase=first,210:220,300,305,310:last\n"); @@ -549,7 +550,8 @@ int main(int Argc, char *Argv[]) { "away or introduce the new ones.\n"); g->debug_stages = ParsingPhases(argv[i] + strlen("--debug-phase=")); } -#if defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6) + +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) // LLVM 3.4+ else if (strncmp(argv[i], "--debug-ir=", 11) == 0) { g->debugIR = ParsingPhaseName(argv[i] + strlen("--debug-ir=")); } diff --git a/module.cpp b/module.cpp index e76c0c7c..a60a1490 100644 --- a/module.cpp +++ b/module.cpp @@ -93,7 +93,7 @@ #include #include #endif -#if defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ #include #include #include @@ -939,7 +939,7 @@ Module::writeOutput(OutputType outputType, const char *outFileName, lStripUnusedDebugInfo(module); } -#if defined (LLVM_3_4) || defined (LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) // LLVM 3.4+ // In LLVM_3_4 after r195494 and r195504 revisions we should pass // "Debug Info Version" constant to the module. LLVM will ignore // our Debug Info metadata without it. @@ -1096,7 +1096,7 @@ Module::writeObjectFileOrAssembly(llvm::TargetMachine *targetMachine, } llvm::PassManager pm; -#if defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ pm.add(new llvm::DataLayoutPass(*g->target->getDataLayout())); #else pm.add(new llvm::DataLayout(*g->target->getDataLayout())); @@ -2093,7 +2093,8 @@ Module::execPreprocessor(const char *infilename, llvm::raw_string_ostream *ostre } inst.getLangOpts().LineComment = 1; -#if defined(LLVM_3_5) || defined(LLVM_3_6) + +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ inst.createPreprocessor(clang::TU_Complete); #else inst.createPreprocessor(); diff --git a/module.h b/module.h index 04bc3e52..ad5f5a2e 100644 --- a/module.h +++ b/module.h @@ -44,7 +44,7 @@ #if defined(LLVM_3_4) #include #endif -#if defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ #include #endif diff --git a/opt.cpp b/opt.cpp index 8e0b2c7e..a9f96a00 100644 --- a/opt.cpp +++ b/opt.cpp @@ -63,12 +63,12 @@ #include #include #endif -#if defined (LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) // LLVM 3.4+ #include #endif #include #include -#if defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ #include #include #include @@ -444,7 +444,8 @@ DebugPassManager::add(llvm::Pass * P, int stage = -1) { number, P->getPassName()); PM.add(CreateDebugPass(buf)); } -#if defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6) + +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) // LLVM 3.4+ if (g->debugIR == number) { // adding generating of LLVM IR debug after optimization char buf[100]; @@ -469,7 +470,7 @@ Optimize(llvm::Module *module, int optLevel) { new llvm::TargetLibraryInfo(llvm::Triple(module->getTargetTriple())); optPM.add(targetLibraryInfo); -#if defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ optPM.add(new llvm::DataLayoutPass(*g->target->getDataLayout())); #else optPM.add(new llvm::DataLayout(*g->target->getDataLayout())); diff --git a/type.cpp b/type.cpp index eaa85dba..456a9520 100644 --- a/type.cpp +++ b/type.cpp @@ -50,7 +50,7 @@ #include #include #endif -#if defined(LLVM_3_5) || defined(LLVM_3_6) +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+ #include #include #else @@ -2981,14 +2981,16 @@ FunctionType::GetDIType(llvm::DIDescriptor scope) const { for (int i = 0; i < GetNumParameters(); ++i) { const Type *t = GetParameterType(i); if (t == NULL) -#if defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6) + +#if !defined(LLVM_3_2) && !defined(LLVM_3_3)// LLVM 3.4+ return llvm::DICompositeType(); #else return llvm::DIType(); #endif retArgTypes.push_back(t->GetDIType(scope)); } -#if defined(LLVM_3_6) + +#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5) // LLVM 3.6+ llvm::DITypeArray retArgTypesArray = m->diBuilder->getOrCreateTypeArray(llvm::ArrayRef(retArgTypes)); #else