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:
32
ctx.cpp
32
ctx.cpp
@@ -153,7 +153,6 @@ FunctionEmitContext::FunctionEmitContext(const Type *rt, llvm::Function *functio
|
|||||||
StoreInst(llvm::Constant::getNullValue(ftype), returnValuePtr);
|
StoreInst(llvm::Constant::getNullValue(ftype), returnValuePtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef LLVM_2_8
|
|
||||||
if (m->diBuilder) {
|
if (m->diBuilder) {
|
||||||
/* If debugging is enabled, tell the debug information emission
|
/* If debugging is enabled, tell the debug information emission
|
||||||
code about this new function */
|
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 */
|
/* And start a scope representing the initial function scope */
|
||||||
StartScope();
|
StartScope();
|
||||||
}
|
}
|
||||||
#endif // LLVM_2_8
|
|
||||||
|
|
||||||
launchedTasks = false;
|
launchedTasks = false;
|
||||||
|
|
||||||
@@ -183,7 +181,6 @@ FunctionEmitContext::FunctionEmitContext(const Type *rt, llvm::Function *functio
|
|||||||
assert(maskSymbol != NULL);
|
assert(maskSymbol != NULL);
|
||||||
maskSymbol->storagePtr = maskPtr;
|
maskSymbol->storagePtr = maskPtr;
|
||||||
|
|
||||||
#ifndef LLVM_2_8
|
|
||||||
// add debugging info for __mask, programIndex, ...
|
// add debugging info for __mask, programIndex, ...
|
||||||
if (m->diBuilder) {
|
if (m->diBuilder) {
|
||||||
maskSymbol->pos = funcStartPos;
|
maskSymbol->pos = funcStartPos;
|
||||||
@@ -208,15 +205,12 @@ FunctionEmitContext::FunctionEmitContext(const Type *rt, llvm::Function *functio
|
|||||||
true /* static */,
|
true /* static */,
|
||||||
programCountSymbol->storagePtr);
|
programCountSymbol->storagePtr);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FunctionEmitContext::~FunctionEmitContext() {
|
FunctionEmitContext::~FunctionEmitContext() {
|
||||||
assert(controlFlowInfo.size() == 0);
|
assert(controlFlowInfo.size() == 0);
|
||||||
#ifndef LLVM_2_8
|
|
||||||
assert(debugScopes.size() == (m->diBuilder ? 1 : 0));
|
assert(debugScopes.size() == (m->diBuilder ? 1 : 0));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -857,7 +851,6 @@ FunctionEmitContext::GetDebugPos() const {
|
|||||||
void
|
void
|
||||||
FunctionEmitContext::AddDebugPos(llvm::Value *value, const SourcePos *pos,
|
FunctionEmitContext::AddDebugPos(llvm::Value *value, const SourcePos *pos,
|
||||||
llvm::DIScope *scope) {
|
llvm::DIScope *scope) {
|
||||||
#ifndef LLVM_2_8
|
|
||||||
llvm::Instruction *inst = llvm::dyn_cast<llvm::Instruction>(value);
|
llvm::Instruction *inst = llvm::dyn_cast<llvm::Instruction>(value);
|
||||||
if (inst != NULL && m->diBuilder) {
|
if (inst != NULL && m->diBuilder) {
|
||||||
SourcePos p = pos ? *pos : currentPos;
|
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,
|
inst->setDebugLoc(llvm::DebugLoc::get(p.first_line, p.first_column,
|
||||||
scope ? *scope : GetDIScope()));
|
scope ? *scope : GetDIScope()));
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
FunctionEmitContext::StartScope() {
|
FunctionEmitContext::StartScope() {
|
||||||
#ifndef LLVM_2_8
|
|
||||||
if (m->diBuilder != NULL) {
|
if (m->diBuilder != NULL) {
|
||||||
llvm::DIScope parentScope;
|
llvm::DIScope parentScope;
|
||||||
if (debugScopes.size() > 0)
|
if (debugScopes.size() > 0)
|
||||||
@@ -888,18 +879,15 @@ FunctionEmitContext::StartScope() {
|
|||||||
currentPos.first_column);
|
currentPos.first_column);
|
||||||
debugScopes.push_back(lexicalBlock);
|
debugScopes.push_back(lexicalBlock);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
FunctionEmitContext::EndScope() {
|
FunctionEmitContext::EndScope() {
|
||||||
#ifndef LLVM_2_8
|
|
||||||
if (m->diBuilder != NULL) {
|
if (m->diBuilder != NULL) {
|
||||||
assert(debugScopes.size() > 0);
|
assert(debugScopes.size() > 0);
|
||||||
debugScopes.pop_back();
|
debugScopes.pop_back();
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -912,7 +900,6 @@ FunctionEmitContext::GetDIScope() const {
|
|||||||
|
|
||||||
void
|
void
|
||||||
FunctionEmitContext::EmitVariableDebugInfo(Symbol *sym) {
|
FunctionEmitContext::EmitVariableDebugInfo(Symbol *sym) {
|
||||||
#ifndef LLVM_2_8
|
|
||||||
if (m->diBuilder == NULL)
|
if (m->diBuilder == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -928,13 +915,11 @@ FunctionEmitContext::EmitVariableDebugInfo(Symbol *sym) {
|
|||||||
llvm::Instruction *declareInst =
|
llvm::Instruction *declareInst =
|
||||||
m->diBuilder->insertDeclare(sym->storagePtr, var, bblock);
|
m->diBuilder->insertDeclare(sym->storagePtr, var, bblock);
|
||||||
AddDebugPos(declareInst, &sym->pos, &scope);
|
AddDebugPos(declareInst, &sym->pos, &scope);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
FunctionEmitContext::EmitFunctionParameterDebugInfo(Symbol *sym) {
|
FunctionEmitContext::EmitFunctionParameterDebugInfo(Symbol *sym) {
|
||||||
#ifndef LLVM_2_8
|
|
||||||
if (m->diBuilder == NULL)
|
if (m->diBuilder == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -950,7 +935,6 @@ FunctionEmitContext::EmitFunctionParameterDebugInfo(Symbol *sym) {
|
|||||||
llvm::Instruction *declareInst =
|
llvm::Instruction *declareInst =
|
||||||
m->diBuilder->insertDeclare(sym->storagePtr, var, bblock);
|
m->diBuilder->insertDeclare(sym->storagePtr, var, bblock);
|
||||||
AddDebugPos(declareInst, &sym->pos, &scope);
|
AddDebugPos(declareInst, &sym->pos, &scope);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1508,27 +1492,15 @@ FunctionEmitContext::gather(llvm::Value *lvalue, const Type *type,
|
|||||||
void
|
void
|
||||||
FunctionEmitContext::addGSMetadata(llvm::Instruction *inst, SourcePos pos) {
|
FunctionEmitContext::addGSMetadata(llvm::Instruction *inst, SourcePos pos) {
|
||||||
llvm::Value *str = llvm::MDString::get(*g->ctx, pos.name);
|
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);
|
llvm::MDNode *md = llvm::MDNode::get(*g->ctx, str);
|
||||||
#endif
|
|
||||||
inst->setMetadata("filename", md);
|
inst->setMetadata("filename", md);
|
||||||
|
|
||||||
llvm::Value *line = LLVMInt32(pos.first_line);
|
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);
|
md = llvm::MDNode::get(*g->ctx, line);
|
||||||
#endif
|
|
||||||
inst->setMetadata("line", md);
|
inst->setMetadata("line", md);
|
||||||
|
|
||||||
llvm::Value *column = LLVMInt32(pos.first_column);
|
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);
|
md = llvm::MDNode::get(*g->ctx, column);
|
||||||
#endif
|
|
||||||
inst->setMetadata("column", md);
|
inst->setMetadata("column", md);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1845,9 +1817,9 @@ llvm::PHINode *
|
|||||||
FunctionEmitContext::PhiNode(LLVM_TYPE_CONST llvm::Type *type, int count,
|
FunctionEmitContext::PhiNode(LLVM_TYPE_CONST llvm::Type *type, int count,
|
||||||
const char *name) {
|
const char *name) {
|
||||||
llvm::PHINode *pn = llvm::PHINode::Create(type,
|
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,
|
count,
|
||||||
#endif // !LLVM_2_8 && !LLVM_2_9
|
#endif // LLVM_3_0
|
||||||
name ? name : "phi", bblock);
|
name ? name : "phi", bblock);
|
||||||
AddDebugPos(pn);
|
AddDebugPos(pn);
|
||||||
return pn;
|
return pn;
|
||||||
|
|||||||
2
expr.cpp
2
expr.cpp
@@ -2569,7 +2569,7 @@ ExprList::GetConstant(const Type *type) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dynamic_cast<const StructType *>(type) != NULL) {
|
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);
|
return llvm::ConstantStruct::get(*g->ctx, cv, false);
|
||||||
#else
|
#else
|
||||||
LLVM_TYPE_CONST llvm::StructType *llvmStructType =
|
LLVM_TYPE_CONST llvm::StructType *llvmStructType =
|
||||||
|
|||||||
6
ispc.cpp
6
ispc.cpp
@@ -46,9 +46,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <llvm/LLVMContext.h>
|
#include <llvm/LLVMContext.h>
|
||||||
#include <llvm/Module.h>
|
#include <llvm/Module.h>
|
||||||
#ifndef LLVM_2_8
|
|
||||||
#include <llvm/Analysis/DIBuilder.h>
|
#include <llvm/Analysis/DIBuilder.h>
|
||||||
#endif
|
|
||||||
#include <llvm/Analysis/DebugInfo.h>
|
#include <llvm/Analysis/DebugInfo.h>
|
||||||
#include <llvm/Support/Dwarf.h>
|
#include <llvm/Support/Dwarf.h>
|
||||||
#include <llvm/Target/TargetMachine.h>
|
#include <llvm/Target/TargetMachine.h>
|
||||||
@@ -309,13 +307,9 @@ SourcePos::SourcePos(const char *n, int l, int c) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
llvm::DIFile SourcePos::GetDIFile() const {
|
llvm::DIFile SourcePos::GetDIFile() const {
|
||||||
#ifdef LLVM_2_8
|
|
||||||
return llvm::DIFile();
|
|
||||||
#else
|
|
||||||
std::string directory, filename;
|
std::string directory, filename;
|
||||||
GetDirectoryAndFileName(g->currentDirectory, name, &directory, &filename);
|
GetDirectoryAndFileName(g->currentDirectory, name, &directory, &filename);
|
||||||
return m->diBuilder->createFile(filename, directory);
|
return m->diBuilder->createFile(filename, directory);
|
||||||
#endif // LLVM_2_8
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -81,9 +81,7 @@ extern "C" {
|
|||||||
#include <llvm/Support/raw_ostream.h>
|
#include <llvm/Support/raw_ostream.h>
|
||||||
#include <llvm/Bitcode/ReaderWriter.h>
|
#include <llvm/Bitcode/ReaderWriter.h>
|
||||||
#include <llvm/Support/MemoryBuffer.h>
|
#include <llvm/Support/MemoryBuffer.h>
|
||||||
#ifndef LLVM_2_8
|
|
||||||
#include <llvm/Support/system_error.h>
|
#include <llvm/Support/system_error.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
bool shouldFail = false;
|
bool shouldFail = false;
|
||||||
|
|
||||||
@@ -145,17 +143,6 @@ double Log(double x) { return log(x); }
|
|||||||
static bool lRunTest(const char *fn) {
|
static bool lRunTest(const char *fn) {
|
||||||
llvm::LLVMContext *ctx = new llvm::LLVMContext;
|
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::OwningPtr<llvm::MemoryBuffer> buf;
|
||||||
llvm::error_code err = llvm::MemoryBuffer::getFileOrSTDIN(fn, buf);
|
llvm::error_code err = llvm::MemoryBuffer::getFileOrSTDIN(fn, buf);
|
||||||
if (err) {
|
if (err) {
|
||||||
@@ -165,7 +152,6 @@ static bool lRunTest(const char *fn) {
|
|||||||
}
|
}
|
||||||
std::string bcErr;
|
std::string bcErr;
|
||||||
llvm::Module *module = llvm::ParseBitcodeFile(buf.get(), *ctx, &bcErr);
|
llvm::Module *module = llvm::ParseBitcodeFile(buf.get(), *ctx, &bcErr);
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!module) {
|
if (!module) {
|
||||||
fprintf(stderr, "Bitcode reader failed for \"%s\": %s\n", fn, bcErr.c_str());
|
fprintf(stderr, "Bitcode reader failed for \"%s\": %s\n", fn, bcErr.c_str());
|
||||||
|
|||||||
6
main.cpp
6
main.cpp
@@ -40,11 +40,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <llvm/Support/PrettyStackTrace.h>
|
#include <llvm/Support/PrettyStackTrace.h>
|
||||||
#ifdef LLVM_2_8
|
#include <llvm/Support/Signals.h>
|
||||||
#include <llvm/System/Signals.h>
|
|
||||||
#else
|
|
||||||
#include <llvm/Support/Signals.h>
|
|
||||||
#endif
|
|
||||||
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
|
#if defined(LLVM_3_0) || defined(LLVM_3_0svn)
|
||||||
#include <llvm/Support/TargetRegistry.h>
|
#include <llvm/Support/TargetRegistry.h>
|
||||||
#include <llvm/Support/TargetSelect.h>
|
#include <llvm/Support/TargetSelect.h>
|
||||||
|
|||||||
19
module.cpp
19
module.cpp
@@ -80,12 +80,8 @@
|
|||||||
#include <clang/Frontend/CompilerInstance.h>
|
#include <clang/Frontend/CompilerInstance.h>
|
||||||
#include <clang/Frontend/Utils.h>
|
#include <clang/Frontend/Utils.h>
|
||||||
#include <clang/Basic/TargetInfo.h>
|
#include <clang/Basic/TargetInfo.h>
|
||||||
#ifndef LLVM_2_8
|
#include <llvm/Support/ToolOutputFile.h>
|
||||||
#include <llvm/Support/ToolOutputFile.h>
|
#include <llvm/Support/Host.h>
|
||||||
#include <llvm/Support/Host.h>
|
|
||||||
#else // !LLVM_2_8
|
|
||||||
#include <llvm/System/Host.h>
|
|
||||||
#endif // LLVM_2_8
|
|
||||||
#include <llvm/Assembly/PrintModulePass.h>
|
#include <llvm/Assembly/PrintModulePass.h>
|
||||||
#include <llvm/Support/raw_ostream.h>
|
#include <llvm/Support/raw_ostream.h>
|
||||||
#include <llvm/Bitcode/ReaderWriter.h>
|
#include <llvm/Bitcode/ReaderWriter.h>
|
||||||
@@ -106,14 +102,11 @@ Module::Module(const char *fn) {
|
|||||||
|
|
||||||
module->setTargetTriple(g->target.GetTripleString());
|
module->setTargetTriple(g->target.GetTripleString());
|
||||||
|
|
||||||
#ifndef LLVM_2_8
|
|
||||||
if (g->generateDebuggingSymbols)
|
if (g->generateDebuggingSymbols)
|
||||||
diBuilder = new llvm::DIBuilder(*module);
|
diBuilder = new llvm::DIBuilder(*module);
|
||||||
else
|
else
|
||||||
diBuilder = NULL;
|
diBuilder = NULL;
|
||||||
#endif // LLVM_2_8
|
|
||||||
|
|
||||||
#ifndef LLVM_2_8
|
|
||||||
// If we're generating debugging symbols, let the DIBuilder know that
|
// If we're generating debugging symbols, let the DIBuilder know that
|
||||||
// we're starting a new compilation unit.
|
// we're starting a new compilation unit.
|
||||||
if (diBuilder != NULL) {
|
if (diBuilder != NULL) {
|
||||||
@@ -139,7 +132,6 @@ Module::Module(const char *fn) {
|
|||||||
0 /* run time version */);
|
0 /* run time version */);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // LLVM_2_8
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -564,7 +556,6 @@ Module::AddGlobal(DeclSpecs *ds, Declarator *decl) {
|
|||||||
decl->sym->name.c_str());
|
decl->sym->name.c_str());
|
||||||
m->symbolTable->AddVariable(decl->sym);
|
m->symbolTable->AddVariable(decl->sym);
|
||||||
|
|
||||||
#ifndef LLVM_2_8
|
|
||||||
if (diBuilder && (ds->storageClass != SC_EXTERN)) {
|
if (diBuilder && (ds->storageClass != SC_EXTERN)) {
|
||||||
llvm::DIFile file = decl->pos.GetDIFile();
|
llvm::DIFile file = decl->pos.GetDIFile();
|
||||||
diBuilder->createGlobalVariable(decl->sym->name,
|
diBuilder->createGlobalVariable(decl->sym->name,
|
||||||
@@ -574,7 +565,6 @@ Module::AddGlobal(DeclSpecs *ds, Declarator *decl) {
|
|||||||
(ds->storageClass == SC_STATIC),
|
(ds->storageClass == SC_STATIC),
|
||||||
decl->sym->storagePtr);
|
decl->sym->storagePtr);
|
||||||
}
|
}
|
||||||
#endif // LLVM_2_8
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -931,12 +921,7 @@ Module::WriteOutput(OutputType outputType, const char *outFileName) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#ifdef LLVM_2_8
|
|
||||||
fprintf(stderr, "Direct object file emission not supported in this build.\n");
|
|
||||||
return false;
|
|
||||||
#else
|
|
||||||
return writeObjectFileOrAssembly(outputType, outFileName);
|
return writeObjectFileOrAssembly(outputType, outFileName);
|
||||||
#endif // LLVM_2_8
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
5
module.h
5
module.h
@@ -91,11 +91,8 @@ public:
|
|||||||
/** llvm Module object into which globals and functions are added. */
|
/** llvm Module object into which globals and functions are added. */
|
||||||
llvm::Module *module;
|
llvm::Module *module;
|
||||||
|
|
||||||
#ifndef LLVM_2_8
|
/** The diBuilder manages generating debugging information */
|
||||||
/** The diBuilder manages generating debugging information (only
|
|
||||||
supported in LLVM 2.9 and beyond...) */
|
|
||||||
llvm::DIBuilder *diBuilder;
|
llvm::DIBuilder *diBuilder;
|
||||||
#endif
|
|
||||||
|
|
||||||
GatherBuffer *gatherBuffer;
|
GatherBuffer *gatherBuffer;
|
||||||
|
|
||||||
|
|||||||
23
opt.cpp
23
opt.cpp
@@ -56,13 +56,11 @@
|
|||||||
#include <llvm/Intrinsics.h>
|
#include <llvm/Intrinsics.h>
|
||||||
#include <llvm/Constants.h>
|
#include <llvm/Constants.h>
|
||||||
#include <llvm/Analysis/ConstantFolding.h>
|
#include <llvm/Analysis/ConstantFolding.h>
|
||||||
#ifndef LLVM_2_8
|
#include <llvm/Target/TargetLibraryInfo.h>
|
||||||
#include <llvm/Target/TargetLibraryInfo.h>
|
#ifdef LLVM_2_9
|
||||||
#ifdef LLVM_2_9
|
#include <llvm/Support/StandardPasses.h>
|
||||||
#include <llvm/Support/StandardPasses.h>
|
#else
|
||||||
#else
|
#include <llvm/Transforms/IPO/PassManagerBuilder.h>
|
||||||
#include <llvm/Transforms/IPO/PassManagerBuilder.h>
|
|
||||||
#endif // LLVM_2_9
|
|
||||||
#endif // LLVM_2_8
|
#endif // LLVM_2_8
|
||||||
#include <llvm/ADT/Triple.h>
|
#include <llvm/ADT/Triple.h>
|
||||||
#include <llvm/Transforms/Scalar.h>
|
#include <llvm/Transforms/Scalar.h>
|
||||||
@@ -73,9 +71,7 @@
|
|||||||
#include <llvm/Target/TargetMachine.h>
|
#include <llvm/Target/TargetMachine.h>
|
||||||
#include <llvm/Analysis/Verifier.h>
|
#include <llvm/Analysis/Verifier.h>
|
||||||
#include <llvm/Support/raw_ostream.h>
|
#include <llvm/Support/raw_ostream.h>
|
||||||
#ifndef LLVM_2_8
|
|
||||||
#include <llvm/Analysis/DIBuilder.h>
|
#include <llvm/Analysis/DIBuilder.h>
|
||||||
#endif
|
|
||||||
#include <llvm/Analysis/DebugInfo.h>
|
#include <llvm/Analysis/DebugInfo.h>
|
||||||
#include <llvm/Support/Dwarf.h>
|
#include <llvm/Support/Dwarf.h>
|
||||||
#ifdef ISPC_IS_LINUX
|
#ifdef ISPC_IS_LINUX
|
||||||
@@ -186,11 +182,9 @@ Optimize(llvm::Module *module, int optLevel) {
|
|||||||
llvm::PassManager optPM;
|
llvm::PassManager optPM;
|
||||||
llvm::FunctionPassManager funcPM(module);
|
llvm::FunctionPassManager funcPM(module);
|
||||||
|
|
||||||
#ifndef LLVM_2_8
|
|
||||||
llvm::TargetLibraryInfo *targetLibraryInfo =
|
llvm::TargetLibraryInfo *targetLibraryInfo =
|
||||||
new llvm::TargetLibraryInfo(llvm::Triple(module->getTargetTriple()));
|
new llvm::TargetLibraryInfo(llvm::Triple(module->getTargetTriple()));
|
||||||
optPM.add(targetLibraryInfo);
|
optPM.add(targetLibraryInfo);
|
||||||
#endif
|
|
||||||
optPM.add(new llvm::TargetData(module));
|
optPM.add(new llvm::TargetData(module));
|
||||||
|
|
||||||
if (optLevel == 0) {
|
if (optLevel == 0) {
|
||||||
@@ -220,7 +214,6 @@ Optimize(llvm::Module *module, int optLevel) {
|
|||||||
// only later in the optimization process as things like constant
|
// only later in the optimization process as things like constant
|
||||||
// propagation have done their thing, and then when they do kick
|
// propagation have done their thing, and then when they do kick
|
||||||
// in, they can often open up new opportunities for optimization...
|
// in, they can often open up new opportunities for optimization...
|
||||||
#ifndef LLVM_2_8
|
|
||||||
llvm::PassRegistry *registry = llvm::PassRegistry::getPassRegistry();
|
llvm::PassRegistry *registry = llvm::PassRegistry::getPassRegistry();
|
||||||
llvm::initializeCore(*registry);
|
llvm::initializeCore(*registry);
|
||||||
llvm::initializeScalarOpts(*registry);
|
llvm::initializeScalarOpts(*registry);
|
||||||
@@ -231,7 +224,7 @@ Optimize(llvm::Module *module, int optLevel) {
|
|||||||
llvm::initializeInstCombine(*registry);
|
llvm::initializeInstCombine(*registry);
|
||||||
llvm::initializeInstrumentation(*registry);
|
llvm::initializeInstrumentation(*registry);
|
||||||
llvm::initializeTarget(*registry);
|
llvm::initializeTarget(*registry);
|
||||||
#endif
|
|
||||||
// Early optimizations to try to reduce the total amount of code to
|
// Early optimizations to try to reduce the total amount of code to
|
||||||
// work with if we can
|
// work with if we can
|
||||||
optPM.add(CreateGatherScatterFlattenPass());
|
optPM.add(CreateGatherScatterFlattenPass());
|
||||||
@@ -288,9 +281,7 @@ Optimize(llvm::Module *module, int optLevel) {
|
|||||||
optPM.add(llvm::createConstantPropagationPass());
|
optPM.add(llvm::createConstantPropagationPass());
|
||||||
optPM.add(CreateIntrinsicsOptPass());
|
optPM.add(CreateIntrinsicsOptPass());
|
||||||
|
|
||||||
#if defined(LLVM_2_8)
|
#if defined(LLVM_2_9)
|
||||||
optPM.add(CreateIsCompileTimeConstantPass(true));
|
|
||||||
#elif defined(LLVM_2_9)
|
|
||||||
llvm::createStandardModulePasses(&optPM, 3,
|
llvm::createStandardModulePasses(&optPM, 3,
|
||||||
false /* opt size */,
|
false /* opt size */,
|
||||||
true /* unit at a time */,
|
true /* unit at a time */,
|
||||||
|
|||||||
37
type.cpp
37
type.cpp
@@ -45,9 +45,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <llvm/Value.h>
|
#include <llvm/Value.h>
|
||||||
#include <llvm/Module.h>
|
#include <llvm/Module.h>
|
||||||
#ifndef LLVM_2_8
|
|
||||||
#include <llvm/Analysis/DIBuilder.h>
|
#include <llvm/Analysis/DIBuilder.h>
|
||||||
#endif
|
|
||||||
#include <llvm/Analysis/DebugInfo.h>
|
#include <llvm/Analysis/DebugInfo.h>
|
||||||
#include <llvm/Support/Dwarf.h>
|
#include <llvm/Support/Dwarf.h>
|
||||||
|
|
||||||
@@ -414,10 +412,6 @@ AtomicType::LLVMType(llvm::LLVMContext *ctx) const {
|
|||||||
|
|
||||||
llvm::DIType
|
llvm::DIType
|
||||||
AtomicType::GetDIType(llvm::DIDescriptor scope) const {
|
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) {
|
if (isUniform) {
|
||||||
switch (basicType) {
|
switch (basicType) {
|
||||||
case TYPE_VOID:
|
case TYPE_VOID:
|
||||||
@@ -484,7 +478,6 @@ AtomicType::GetDIType(llvm::DIDescriptor scope) const {
|
|||||||
uint64_t align = unifType.getAlignInBits() * g->target.vectorWidth;
|
uint64_t align = unifType.getAlignInBits() * g->target.vectorWidth;
|
||||||
return m->diBuilder->createVectorType(size, align, unifType, subArray);
|
return m->diBuilder->createVectorType(size, align, unifType, subArray);
|
||||||
}
|
}
|
||||||
#endif // LLVM_2_8
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -645,10 +638,6 @@ EnumType::LLVMType(llvm::LLVMContext *ctx) const {
|
|||||||
|
|
||||||
llvm::DIType
|
llvm::DIType
|
||||||
EnumType::GetDIType(llvm::DIDescriptor scope) const {
|
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;
|
std::vector<llvm::Value *> enumeratorDescriptors;
|
||||||
for (unsigned int i = 0; i < enumerators.size(); ++i) {
|
for (unsigned int i = 0; i < enumerators.size(); ++i) {
|
||||||
unsigned int enumeratorValue;
|
unsigned int enumeratorValue;
|
||||||
@@ -688,7 +677,6 @@ EnumType::GetDIType(llvm::DIDescriptor scope) const {
|
|||||||
uint64_t size = diType.getSizeInBits() * g->target.vectorWidth;
|
uint64_t size = diType.getSizeInBits() * g->target.vectorWidth;
|
||||||
uint64_t align = diType.getAlignInBits() * g->target.vectorWidth;
|
uint64_t align = diType.getAlignInBits() * g->target.vectorWidth;
|
||||||
return m->diBuilder->createVectorType(size, align, diType, subArray);
|
return m->diBuilder->createVectorType(size, align, diType, subArray);
|
||||||
#endif // !LLVM_2_8
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -893,10 +881,6 @@ ArrayType::TotalElementCount() const {
|
|||||||
|
|
||||||
llvm::DIType
|
llvm::DIType
|
||||||
ArrayType::GetDIType(llvm::DIDescriptor scope) const {
|
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)
|
if (!child)
|
||||||
return llvm::DIType();
|
return llvm::DIType();
|
||||||
|
|
||||||
@@ -923,7 +907,6 @@ ArrayType::GetDIType(llvm::DIDescriptor scope) const {
|
|||||||
uint64_t align = eltType.getAlignInBits();
|
uint64_t align = eltType.getAlignInBits();
|
||||||
|
|
||||||
return m->diBuilder->createArrayType(size, align, eltType, subArray);
|
return m->diBuilder->createArrayType(size, align, eltType, subArray);
|
||||||
#endif // LLVM_2_8
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1044,16 +1027,11 @@ SOAArrayType::LLVMType(llvm::LLVMContext *ctx) const {
|
|||||||
|
|
||||||
llvm::DIType
|
llvm::DIType
|
||||||
SOAArrayType::GetDIType(llvm::DIDescriptor scope) const {
|
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)
|
if (!child)
|
||||||
return llvm::DIType();
|
return llvm::DIType();
|
||||||
|
|
||||||
const Type *t = soaType();
|
const Type *t = soaType();
|
||||||
return t->GetDIType(scope);
|
return t->GetDIType(scope);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1217,10 +1195,6 @@ VectorType::LLVMType(llvm::LLVMContext *ctx) const {
|
|||||||
|
|
||||||
llvm::DIType
|
llvm::DIType
|
||||||
VectorType::GetDIType(llvm::DIDescriptor scope) const {
|
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::DIType eltType = base->GetDIType(scope);
|
||||||
llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, numElements-1);
|
llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, numElements-1);
|
||||||
#ifdef LLVM_2_9
|
#ifdef LLVM_2_9
|
||||||
@@ -1240,7 +1214,6 @@ VectorType::GetDIType(llvm::DIDescriptor scope) const {
|
|||||||
align = 4 * g->target.nativeVectorWidth;
|
align = 4 * g->target.nativeVectorWidth;
|
||||||
|
|
||||||
return m->diBuilder->createVectorType(sizeBits, align, eltType, subArray);
|
return m->diBuilder->createVectorType(sizeBits, align, eltType, subArray);
|
||||||
#endif // LLVM_2_8
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1443,10 +1416,6 @@ StructType::LLVMType(llvm::LLVMContext *ctx) const {
|
|||||||
|
|
||||||
llvm::DIType
|
llvm::DIType
|
||||||
StructType::GetDIType(llvm::DIDescriptor scope) const {
|
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;
|
uint64_t currentSize = 0, align = 0;
|
||||||
|
|
||||||
std::vector<llvm::Value *> elementLLVMTypes;
|
std::vector<llvm::Value *> elementLLVMTypes;
|
||||||
@@ -1500,7 +1469,6 @@ StructType::GetDIType(llvm::DIDescriptor scope) const {
|
|||||||
llvm::DIFile diFile = pos.GetDIFile();
|
llvm::DIFile diFile = pos.GetDIFile();
|
||||||
return m->diBuilder->createStructType(scope, name, diFile, pos.first_line, currentSize,
|
return m->diBuilder->createStructType(scope, name, diFile, pos.first_line, currentSize,
|
||||||
align, 0, elements);
|
align, 0, elements);
|
||||||
#endif // LLVM_2_8
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1698,13 +1666,8 @@ ReferenceType::LLVMType(llvm::LLVMContext *ctx) const {
|
|||||||
|
|
||||||
llvm::DIType
|
llvm::DIType
|
||||||
ReferenceType::GetDIType(llvm::DIDescriptor scope) const {
|
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);
|
llvm::DIType diTargetType = targetType->GetDIType(scope);
|
||||||
return m->diBuilder->createReferenceType(diTargetType);
|
return m->diBuilder->createReferenceType(diTargetType);
|
||||||
#endif // LLVM_2_8
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user