Remove support for building with LLVM 2.8. Fixes issue #66.

Both 2.9 and top-of-tree generate substantially better code than
LLVM 2.8 did, so it's not worth fixing the 2.8 build.
This commit is contained in:
Matt Pharr
2011-09-17 13:18:59 -07:00
parent de84acfa5d
commit 3607f3e045
9 changed files with 14 additions and 130 deletions

32
ctx.cpp
View File

@@ -153,7 +153,6 @@ FunctionEmitContext::FunctionEmitContext(const Type *rt, llvm::Function *functio
StoreInst(llvm::Constant::getNullValue(ftype), returnValuePtr);
}
#ifndef LLVM_2_8
if (m->diBuilder) {
/* If debugging is enabled, tell the debug information emission
code about this new function */
@@ -174,7 +173,6 @@ FunctionEmitContext::FunctionEmitContext(const Type *rt, llvm::Function *functio
/* And start a scope representing the initial function scope */
StartScope();
}
#endif // LLVM_2_8
launchedTasks = false;
@@ -183,7 +181,6 @@ FunctionEmitContext::FunctionEmitContext(const Type *rt, llvm::Function *functio
assert(maskSymbol != NULL);
maskSymbol->storagePtr = maskPtr;
#ifndef LLVM_2_8
// add debugging info for __mask, programIndex, ...
if (m->diBuilder) {
maskSymbol->pos = funcStartPos;
@@ -208,15 +205,12 @@ FunctionEmitContext::FunctionEmitContext(const Type *rt, llvm::Function *functio
true /* static */,
programCountSymbol->storagePtr);
}
#endif
}
FunctionEmitContext::~FunctionEmitContext() {
assert(controlFlowInfo.size() == 0);
#ifndef LLVM_2_8
assert(debugScopes.size() == (m->diBuilder ? 1 : 0));
#endif
}
@@ -857,7 +851,6 @@ FunctionEmitContext::GetDebugPos() const {
void
FunctionEmitContext::AddDebugPos(llvm::Value *value, const SourcePos *pos,
llvm::DIScope *scope) {
#ifndef LLVM_2_8
llvm::Instruction *inst = llvm::dyn_cast<llvm::Instruction>(value);
if (inst != NULL && m->diBuilder) {
SourcePos p = pos ? *pos : currentPos;
@@ -868,13 +861,11 @@ FunctionEmitContext::AddDebugPos(llvm::Value *value, const SourcePos *pos,
inst->setDebugLoc(llvm::DebugLoc::get(p.first_line, p.first_column,
scope ? *scope : GetDIScope()));
}
#endif
}
void
FunctionEmitContext::StartScope() {
#ifndef LLVM_2_8
if (m->diBuilder != NULL) {
llvm::DIScope parentScope;
if (debugScopes.size() > 0)
@@ -888,18 +879,15 @@ FunctionEmitContext::StartScope() {
currentPos.first_column);
debugScopes.push_back(lexicalBlock);
}
#endif
}
void
FunctionEmitContext::EndScope() {
#ifndef LLVM_2_8
if (m->diBuilder != NULL) {
assert(debugScopes.size() > 0);
debugScopes.pop_back();
}
#endif
}
@@ -912,7 +900,6 @@ FunctionEmitContext::GetDIScope() const {
void
FunctionEmitContext::EmitVariableDebugInfo(Symbol *sym) {
#ifndef LLVM_2_8
if (m->diBuilder == NULL)
return;
@@ -928,13 +915,11 @@ FunctionEmitContext::EmitVariableDebugInfo(Symbol *sym) {
llvm::Instruction *declareInst =
m->diBuilder->insertDeclare(sym->storagePtr, var, bblock);
AddDebugPos(declareInst, &sym->pos, &scope);
#endif
}
void
FunctionEmitContext::EmitFunctionParameterDebugInfo(Symbol *sym) {
#ifndef LLVM_2_8
if (m->diBuilder == NULL)
return;
@@ -950,7 +935,6 @@ FunctionEmitContext::EmitFunctionParameterDebugInfo(Symbol *sym) {
llvm::Instruction *declareInst =
m->diBuilder->insertDeclare(sym->storagePtr, var, bblock);
AddDebugPos(declareInst, &sym->pos, &scope);
#endif
}
@@ -1508,27 +1492,15 @@ FunctionEmitContext::gather(llvm::Value *lvalue, const Type *type,
void
FunctionEmitContext::addGSMetadata(llvm::Instruction *inst, SourcePos pos) {
llvm::Value *str = llvm::MDString::get(*g->ctx, pos.name);
#ifdef LLVM_2_8
llvm::MDNode *md = llvm::MDNode::get(*g->ctx, &str, 1);
#else
llvm::MDNode *md = llvm::MDNode::get(*g->ctx, str);
#endif
inst->setMetadata("filename", md);
llvm::Value *line = LLVMInt32(pos.first_line);
#ifdef LLVM_2_8
md = llvm::MDNode::get(*g->ctx, &line, 1);
#else
md = llvm::MDNode::get(*g->ctx, line);
#endif
inst->setMetadata("line", md);
llvm::Value *column = LLVMInt32(pos.first_column);
#ifdef LLVM_2_8
md = llvm::MDNode::get(*g->ctx, &column, 1);
#else
md = llvm::MDNode::get(*g->ctx, column);
#endif
inst->setMetadata("column", md);
}
@@ -1845,9 +1817,9 @@ llvm::PHINode *
FunctionEmitContext::PhiNode(LLVM_TYPE_CONST llvm::Type *type, int count,
const char *name) {
llvm::PHINode *pn = llvm::PHINode::Create(type,
#if !defined(LLVM_2_8) && !defined(LLVM_2_9)
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
count,
#endif // !LLVM_2_8 && !LLVM_2_9
#endif // LLVM_3_0
name ? name : "phi", bblock);
AddDebugPos(pn);
return pn;

View File

@@ -2569,7 +2569,7 @@ ExprList::GetConstant(const Type *type) const {
}
if (dynamic_cast<const StructType *>(type) != NULL) {
#if defined(LLVM_2_8) || defined(LLVM_2_9)
#if defined(LLVM_2_9)
return llvm::ConstantStruct::get(*g->ctx, cv, false);
#else
LLVM_TYPE_CONST llvm::StructType *llvmStructType =

View File

@@ -46,9 +46,7 @@
#endif
#include <llvm/LLVMContext.h>
#include <llvm/Module.h>
#ifndef LLVM_2_8
#include <llvm/Analysis/DIBuilder.h>
#endif
#include <llvm/Analysis/DebugInfo.h>
#include <llvm/Support/Dwarf.h>
#include <llvm/Target/TargetMachine.h>
@@ -309,13 +307,9 @@ SourcePos::SourcePos(const char *n, int l, int c) {
}
llvm::DIFile SourcePos::GetDIFile() const {
#ifdef LLVM_2_8
return llvm::DIFile();
#else
std::string directory, filename;
GetDirectoryAndFileName(g->currentDirectory, name, &directory, &filename);
return m->diBuilder->createFile(filename, directory);
#endif // LLVM_2_8
}

View File

@@ -81,9 +81,7 @@ extern "C" {
#include <llvm/Support/raw_ostream.h>
#include <llvm/Bitcode/ReaderWriter.h>
#include <llvm/Support/MemoryBuffer.h>
#ifndef LLVM_2_8
#include <llvm/Support/system_error.h>
#endif
bool shouldFail = false;
@@ -145,17 +143,6 @@ double Log(double x) { return log(x); }
static bool lRunTest(const char *fn) {
llvm::LLVMContext *ctx = new llvm::LLVMContext;
#ifdef LLVM_2_8
std::string err;
llvm::MemoryBuffer *buf = llvm::MemoryBuffer::getFileOrSTDIN(fn, &err);
if (!buf) {
fprintf(stderr, "Unable to open file \"%s\": %s\n", fn, err.c_str());
delete ctx;
return false;
}
std::string bcErr;
llvm::Module *module = llvm::ParseBitcodeFile(buf, *ctx, &bcErr);
#else
llvm::OwningPtr<llvm::MemoryBuffer> buf;
llvm::error_code err = llvm::MemoryBuffer::getFileOrSTDIN(fn, buf);
if (err) {
@@ -165,7 +152,6 @@ static bool lRunTest(const char *fn) {
}
std::string bcErr;
llvm::Module *module = llvm::ParseBitcodeFile(buf.get(), *ctx, &bcErr);
#endif
if (!module) {
fprintf(stderr, "Bitcode reader failed for \"%s\": %s\n", fn, bcErr.c_str());

View File

@@ -40,11 +40,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <llvm/Support/PrettyStackTrace.h>
#ifdef LLVM_2_8
#include <llvm/System/Signals.h>
#else
#include <llvm/Support/Signals.h>
#endif
#include <llvm/Support/Signals.h>
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
#include <llvm/Support/TargetRegistry.h>
#include <llvm/Support/TargetSelect.h>

View File

@@ -80,12 +80,8 @@
#include <clang/Frontend/CompilerInstance.h>
#include <clang/Frontend/Utils.h>
#include <clang/Basic/TargetInfo.h>
#ifndef LLVM_2_8
#include <llvm/Support/ToolOutputFile.h>
#include <llvm/Support/Host.h>
#else // !LLVM_2_8
#include <llvm/System/Host.h>
#endif // LLVM_2_8
#include <llvm/Support/ToolOutputFile.h>
#include <llvm/Support/Host.h>
#include <llvm/Assembly/PrintModulePass.h>
#include <llvm/Support/raw_ostream.h>
#include <llvm/Bitcode/ReaderWriter.h>
@@ -106,14 +102,11 @@ Module::Module(const char *fn) {
module->setTargetTriple(g->target.GetTripleString());
#ifndef LLVM_2_8
if (g->generateDebuggingSymbols)
diBuilder = new llvm::DIBuilder(*module);
else
diBuilder = NULL;
#endif // LLVM_2_8
#ifndef LLVM_2_8
// If we're generating debugging symbols, let the DIBuilder know that
// we're starting a new compilation unit.
if (diBuilder != NULL) {
@@ -139,7 +132,6 @@ Module::Module(const char *fn) {
0 /* run time version */);
}
}
#endif // LLVM_2_8
}
@@ -564,7 +556,6 @@ Module::AddGlobal(DeclSpecs *ds, Declarator *decl) {
decl->sym->name.c_str());
m->symbolTable->AddVariable(decl->sym);
#ifndef LLVM_2_8
if (diBuilder && (ds->storageClass != SC_EXTERN)) {
llvm::DIFile file = decl->pos.GetDIFile();
diBuilder->createGlobalVariable(decl->sym->name,
@@ -574,7 +565,6 @@ Module::AddGlobal(DeclSpecs *ds, Declarator *decl) {
(ds->storageClass == SC_STATIC),
decl->sym->storagePtr);
}
#endif // LLVM_2_8
}
}
@@ -931,12 +921,7 @@ Module::WriteOutput(OutputType outputType, const char *outFileName) {
return true;
}
else {
#ifdef LLVM_2_8
fprintf(stderr, "Direct object file emission not supported in this build.\n");
return false;
#else
return writeObjectFileOrAssembly(outputType, outFileName);
#endif // LLVM_2_8
}
}
}

View File

@@ -91,11 +91,8 @@ public:
/** llvm Module object into which globals and functions are added. */
llvm::Module *module;
#ifndef LLVM_2_8
/** The diBuilder manages generating debugging information (only
supported in LLVM 2.9 and beyond...) */
/** The diBuilder manages generating debugging information */
llvm::DIBuilder *diBuilder;
#endif
GatherBuffer *gatherBuffer;

23
opt.cpp
View File

@@ -56,13 +56,11 @@
#include <llvm/Intrinsics.h>
#include <llvm/Constants.h>
#include <llvm/Analysis/ConstantFolding.h>
#ifndef LLVM_2_8
#include <llvm/Target/TargetLibraryInfo.h>
#ifdef LLVM_2_9
#include <llvm/Support/StandardPasses.h>
#else
#include <llvm/Transforms/IPO/PassManagerBuilder.h>
#endif // LLVM_2_9
#include <llvm/Target/TargetLibraryInfo.h>
#ifdef LLVM_2_9
#include <llvm/Support/StandardPasses.h>
#else
#include <llvm/Transforms/IPO/PassManagerBuilder.h>
#endif // LLVM_2_8
#include <llvm/ADT/Triple.h>
#include <llvm/Transforms/Scalar.h>
@@ -73,9 +71,7 @@
#include <llvm/Target/TargetMachine.h>
#include <llvm/Analysis/Verifier.h>
#include <llvm/Support/raw_ostream.h>
#ifndef LLVM_2_8
#include <llvm/Analysis/DIBuilder.h>
#endif
#include <llvm/Analysis/DebugInfo.h>
#include <llvm/Support/Dwarf.h>
#ifdef ISPC_IS_LINUX
@@ -186,11 +182,9 @@ Optimize(llvm::Module *module, int optLevel) {
llvm::PassManager optPM;
llvm::FunctionPassManager funcPM(module);
#ifndef LLVM_2_8
llvm::TargetLibraryInfo *targetLibraryInfo =
new llvm::TargetLibraryInfo(llvm::Triple(module->getTargetTriple()));
optPM.add(targetLibraryInfo);
#endif
optPM.add(new llvm::TargetData(module));
if (optLevel == 0) {
@@ -220,7 +214,6 @@ Optimize(llvm::Module *module, int optLevel) {
// only later in the optimization process as things like constant
// propagation have done their thing, and then when they do kick
// in, they can often open up new opportunities for optimization...
#ifndef LLVM_2_8
llvm::PassRegistry *registry = llvm::PassRegistry::getPassRegistry();
llvm::initializeCore(*registry);
llvm::initializeScalarOpts(*registry);
@@ -231,7 +224,7 @@ Optimize(llvm::Module *module, int optLevel) {
llvm::initializeInstCombine(*registry);
llvm::initializeInstrumentation(*registry);
llvm::initializeTarget(*registry);
#endif
// Early optimizations to try to reduce the total amount of code to
// work with if we can
optPM.add(CreateGatherScatterFlattenPass());
@@ -288,9 +281,7 @@ Optimize(llvm::Module *module, int optLevel) {
optPM.add(llvm::createConstantPropagationPass());
optPM.add(CreateIntrinsicsOptPass());
#if defined(LLVM_2_8)
optPM.add(CreateIsCompileTimeConstantPass(true));
#elif defined(LLVM_2_9)
#if defined(LLVM_2_9)
llvm::createStandardModulePasses(&optPM, 3,
false /* opt size */,
true /* unit at a time */,

View File

@@ -45,9 +45,7 @@
#include <stdio.h>
#include <llvm/Value.h>
#include <llvm/Module.h>
#ifndef LLVM_2_8
#include <llvm/Analysis/DIBuilder.h>
#endif
#include <llvm/Analysis/DebugInfo.h>
#include <llvm/Support/Dwarf.h>
@@ -414,10 +412,6 @@ AtomicType::LLVMType(llvm::LLVMContext *ctx) const {
llvm::DIType
AtomicType::GetDIType(llvm::DIDescriptor scope) const {
#ifdef LLVM_2_8
FATAL("debug info not supported in llvm 2.8");
return llvm::DIType();
#else
if (isUniform) {
switch (basicType) {
case TYPE_VOID:
@@ -484,7 +478,6 @@ AtomicType::GetDIType(llvm::DIDescriptor scope) const {
uint64_t align = unifType.getAlignInBits() * g->target.vectorWidth;
return m->diBuilder->createVectorType(size, align, unifType, subArray);
}
#endif // LLVM_2_8
}
@@ -645,10 +638,6 @@ EnumType::LLVMType(llvm::LLVMContext *ctx) const {
llvm::DIType
EnumType::GetDIType(llvm::DIDescriptor scope) const {
#ifdef LLVM_2_8
FATAL("debug info not supported in llvm 2.8");
return llvm::DIType();
#else
std::vector<llvm::Value *> enumeratorDescriptors;
for (unsigned int i = 0; i < enumerators.size(); ++i) {
unsigned int enumeratorValue;
@@ -688,7 +677,6 @@ EnumType::GetDIType(llvm::DIDescriptor scope) const {
uint64_t size = diType.getSizeInBits() * g->target.vectorWidth;
uint64_t align = diType.getAlignInBits() * g->target.vectorWidth;
return m->diBuilder->createVectorType(size, align, diType, subArray);
#endif // !LLVM_2_8
}
@@ -893,10 +881,6 @@ ArrayType::TotalElementCount() const {
llvm::DIType
ArrayType::GetDIType(llvm::DIDescriptor scope) const {
#ifdef LLVM_2_8
FATAL("debug info not supported in llvm 2.8");
return llvm::DIType();
#else
if (!child)
return llvm::DIType();
@@ -923,7 +907,6 @@ ArrayType::GetDIType(llvm::DIDescriptor scope) const {
uint64_t align = eltType.getAlignInBits();
return m->diBuilder->createArrayType(size, align, eltType, subArray);
#endif // LLVM_2_8
}
@@ -1044,16 +1027,11 @@ SOAArrayType::LLVMType(llvm::LLVMContext *ctx) const {
llvm::DIType
SOAArrayType::GetDIType(llvm::DIDescriptor scope) const {
#ifdef LLVM_2_8
FATAL("debug info not supported in llvm 2.8");
return llvm::DIType();
#else
if (!child)
return llvm::DIType();
const Type *t = soaType();
return t->GetDIType(scope);
#endif
}
@@ -1217,10 +1195,6 @@ VectorType::LLVMType(llvm::LLVMContext *ctx) const {
llvm::DIType
VectorType::GetDIType(llvm::DIDescriptor scope) const {
#ifdef LLVM_2_8
FATAL("debug info not supported in llvm 2.8");
return llvm::DIType();
#else
llvm::DIType eltType = base->GetDIType(scope);
llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, numElements-1);
#ifdef LLVM_2_9
@@ -1240,7 +1214,6 @@ VectorType::GetDIType(llvm::DIDescriptor scope) const {
align = 4 * g->target.nativeVectorWidth;
return m->diBuilder->createVectorType(sizeBits, align, eltType, subArray);
#endif // LLVM_2_8
}
@@ -1443,10 +1416,6 @@ StructType::LLVMType(llvm::LLVMContext *ctx) const {
llvm::DIType
StructType::GetDIType(llvm::DIDescriptor scope) const {
#ifdef LLVM_2_8
FATAL("debug info not supported in llvm 2.8");
return llvm::DIType();
#else
uint64_t currentSize = 0, align = 0;
std::vector<llvm::Value *> elementLLVMTypes;
@@ -1500,7 +1469,6 @@ StructType::GetDIType(llvm::DIDescriptor scope) const {
llvm::DIFile diFile = pos.GetDIFile();
return m->diBuilder->createStructType(scope, name, diFile, pos.first_line, currentSize,
align, 0, elements);
#endif // LLVM_2_8
}
@@ -1698,13 +1666,8 @@ ReferenceType::LLVMType(llvm::LLVMContext *ctx) const {
llvm::DIType
ReferenceType::GetDIType(llvm::DIDescriptor scope) const {
#ifdef LLVM_2_8
FATAL("debug info not supported in llvm 2.8");
return llvm::DIType();
#else
llvm::DIType diTargetType = targetType->GetDIType(scope);
return m->diBuilder->createReferenceType(diTargetType);
#endif // LLVM_2_8
}