LLVM debug info fix, again
This commit is contained in:
16
builtins.cpp
16
builtins.cpp
@@ -917,12 +917,16 @@ lDefineConstantInt(const char *name, int val, llvm::Module *module,
|
||||
symbolTable->AddVariable(sym);
|
||||
|
||||
if (m->diBuilder != NULL) {
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DIFile file;
|
||||
llvm::DIType diType = sym->type->GetDIType(file);
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
Assert(diType.Verify());
|
||||
#else // LLVM 3.7+
|
||||
//comming soon
|
||||
llvm::MDFile *file =
|
||||
m->diBuilder->createFile(m->diCompileUnit->getFilename(),
|
||||
m->diCompileUnit->getDirectory());
|
||||
llvm::MDType *diType = sym->type->GetDIType(file);
|
||||
// Assert(diType.Verify());
|
||||
#endif
|
||||
// FIXME? DWARF says that this (and programIndex below) should
|
||||
// have the DW_AT_artifical attribute. It's not clear if this
|
||||
@@ -1015,12 +1019,16 @@ lDefineProgramIndex(llvm::Module *module, SymbolTable *symbolTable) {
|
||||
symbolTable->AddVariable(sym);
|
||||
|
||||
if (m->diBuilder != NULL) {
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DIFile file;
|
||||
llvm::DIType diType = sym->type->GetDIType(file);
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
Assert(diType.Verify());
|
||||
#else // LLVM 3.7+
|
||||
//comming soon
|
||||
llvm::MDFile *file =
|
||||
m->diBuilder->createFile(m->diCompileUnit->getFilename(),
|
||||
m->diCompileUnit->getDirectory());
|
||||
llvm::MDType *diType = sym->type->GetDIType(file);
|
||||
// Assert(diType.Verify());
|
||||
#endif
|
||||
#if defined(LLVM_3_6)// LLVM 3.6+
|
||||
llvm::Constant *sym_const_storagePtr = llvm::dyn_cast<llvm::Constant>(sym->storagePtr);
|
||||
|
||||
117
ctx.cpp
117
ctx.cpp
@@ -337,12 +337,11 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym,
|
||||
|
||||
/* If debugging is enabled, tell the debug information emission
|
||||
code about this new function */
|
||||
diFile = funcStartPos.GetDIFile();
|
||||
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
diFile = funcStartPos.GetDIFile();
|
||||
AssertPos(currentPos, diFile.Verify());
|
||||
#else // LLVM 3.7+
|
||||
//comming soon
|
||||
diFile = funcStartPos.GetDIFile();
|
||||
#endif
|
||||
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3)
|
||||
@@ -350,16 +349,16 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym,
|
||||
#elif defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DIScope scope = llvm::DIScope(m->diCompileUnit);
|
||||
#else // LLVM 3.7+
|
||||
llvm::DIScope scope = m->diCompileUnit;
|
||||
llvm::MDScope *scope = m->diCompileUnit;
|
||||
#endif
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DIType diSubprogramType;
|
||||
AssertPos(currentPos, scope.Verify());
|
||||
#else // LLVM 3.7+
|
||||
//comming soon
|
||||
llvm::MDType *diSubprogramType = NULL;
|
||||
#endif
|
||||
|
||||
const FunctionType *functionType = function->GetType();
|
||||
llvm::DIType diSubprogramType;
|
||||
if (functionType == NULL)
|
||||
AssertPos(currentPos, m->errorCount > 0);
|
||||
else {
|
||||
@@ -380,8 +379,8 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym,
|
||||
int flags = llvm::DIDescriptor::FlagPrototyped;
|
||||
#else // LLVM 3.7+
|
||||
Assert(llvm::isa<llvm::MDCompositeTypeBase>(diSubprogramType));
|
||||
llvm::DICompositeType diSubprogramType_n =
|
||||
llvm::cast<llvm::MDCompositeTypeBase>(diSubprogramType);
|
||||
llvm::MDSubroutineType *diSubprogramType_n =
|
||||
llvm::cast<llvm::MDSubroutineType>(getDICompositeType(diSubprogramType));
|
||||
int flags = llvm::DebugNode::FlagPrototyped;
|
||||
#endif
|
||||
|
||||
@@ -393,18 +392,23 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym,
|
||||
bool isOptimized = (g->opt.level > 0);
|
||||
int firstLine = funcStartPos.first_line;
|
||||
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
diSubprogram =
|
||||
m->diBuilder->createFunction(diFile /* scope */, funSym->name,
|
||||
mangledName, diFile,
|
||||
firstLine, diSubprogramType_n,
|
||||
isStatic, true, /* is defn */
|
||||
firstLine,
|
||||
flags,
|
||||
firstLine, flags,
|
||||
isOptimized, llvmFunction);
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
AssertPos(currentPos, diSubprogram.Verify());
|
||||
#else // LLVM 3.7+
|
||||
//comming soon
|
||||
diSubprogram =
|
||||
m->diBuilder->createFunction(diFile /* scope */, funSym->name,
|
||||
mangledName, diFile,
|
||||
firstLine, diSubprogramType_n,
|
||||
isStatic, true, /* is defn */
|
||||
firstLine, flags,
|
||||
isOptimized, llvmFunction);
|
||||
#endif
|
||||
|
||||
/* And start a scope representing the initial function scope */
|
||||
@@ -1650,7 +1654,11 @@ FunctionEmitContext::GetDebugPos() const {
|
||||
|
||||
void
|
||||
FunctionEmitContext::AddDebugPos(llvm::Value *value, const SourcePos *pos,
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DIScope *scope) {
|
||||
#else // LLVM 3.7++
|
||||
llvm::MDScope *scope) {
|
||||
#endif
|
||||
llvm::Instruction *inst = llvm::dyn_cast<llvm::Instruction>(value);
|
||||
if (inst != NULL && m->diBuilder) {
|
||||
SourcePos p = pos ? *pos : currentPos;
|
||||
@@ -1659,7 +1667,7 @@ FunctionEmitContext::AddDebugPos(llvm::Value *value, const SourcePos *pos,
|
||||
// the standard library or the like; don't add debug positions
|
||||
// for those functions
|
||||
inst->setDebugLoc(llvm::DebugLoc::get(p.first_line, p.first_column,
|
||||
scope ? *scope : GetDIScope()));
|
||||
scope ? scope : GetDIScope()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1667,13 +1675,19 @@ FunctionEmitContext::AddDebugPos(llvm::Value *value, const SourcePos *pos,
|
||||
void
|
||||
FunctionEmitContext::StartScope() {
|
||||
if (m->diBuilder != NULL) {
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DIScope parentScope;
|
||||
llvm::DILexicalBlock lexicalBlock;
|
||||
#else // LLVM 3.7++
|
||||
llvm::MDScope *parentScope;
|
||||
llvm::MDLexicalBlock *lexicalBlock;
|
||||
#endif
|
||||
if (debugScopes.size() > 0)
|
||||
parentScope = debugScopes.back();
|
||||
else
|
||||
parentScope = diSubprogram;
|
||||
|
||||
llvm::DILexicalBlock lexicalBlock =
|
||||
lexicalBlock =
|
||||
m->diBuilder->createLexicalBlock(parentScope, diFile,
|
||||
currentPos.first_line,
|
||||
#if defined(LLVM_3_5)
|
||||
@@ -1705,7 +1719,11 @@ FunctionEmitContext::EndScope() {
|
||||
}
|
||||
|
||||
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DIScope
|
||||
#else // LLVM 3.7+
|
||||
llvm::MDScope*
|
||||
#endif
|
||||
FunctionEmitContext::GetDIScope() const {
|
||||
AssertPos(currentPos, debugScopes.size() > 0);
|
||||
return debugScopes.back();
|
||||
@@ -1717,14 +1735,16 @@ FunctionEmitContext::EmitVariableDebugInfo(Symbol *sym) {
|
||||
if (m->diBuilder == NULL)
|
||||
return;
|
||||
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DIScope scope = GetDIScope();
|
||||
llvm::DIType diType = sym->type->GetDIType(scope);
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
AssertPos(currentPos, diType.Verify());
|
||||
#else // LLVM 3.7+
|
||||
//comming soon
|
||||
#endif
|
||||
llvm::DIVariable var =
|
||||
#else // LLVM 3.7+
|
||||
llvm::MDScope *scope = GetDIScope();
|
||||
llvm::MDType *diType = sym->type->GetDIType(scope);
|
||||
llvm::MDLocalVariable *var =
|
||||
#endif
|
||||
m->diBuilder->createLocalVariable(llvm::dwarf::DW_TAG_auto_variable,
|
||||
scope,
|
||||
sym->name,
|
||||
@@ -1734,23 +1754,22 @@ FunctionEmitContext::EmitVariableDebugInfo(Symbol *sym) {
|
||||
true /* preserve through opts */);
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
AssertPos(currentPos, var.Verify());
|
||||
#else // LLVM 3.7+
|
||||
//comming soon
|
||||
#endif
|
||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5)// LLVM 3.6+
|
||||
llvm::DIExpression E = m->diBuilder->createExpression();
|
||||
llvm::Instruction *declareInst =
|
||||
m->diBuilder->insertDeclare(sym->storagePtr, var, E,
|
||||
#if !defined(LLVM_3_6) // LLVM 3.7++
|
||||
m->diBuilder->insertDeclare(sym->storagePtr, var,
|
||||
#if defined(LLVM_3_6)
|
||||
m->diBuilder->createExpression(),
|
||||
#endif
|
||||
bblock);
|
||||
AddDebugPos(declareInst, &sym->pos, &scope);
|
||||
#else // LLVM 3.7++
|
||||
llvm::Instruction *declareInst =
|
||||
m->diBuilder->insertDeclare(sym->storagePtr, var,
|
||||
m->diBuilder->createExpression(),
|
||||
llvm::DebugLoc::get(sym->pos.first_line,
|
||||
sym->pos.first_column, scope),
|
||||
#endif
|
||||
bblock);
|
||||
#else
|
||||
llvm::Instruction *declareInst =
|
||||
m->diBuilder->insertDeclare(sym->storagePtr, var, bblock);
|
||||
AddDebugPos(declareInst, &sym->pos, scope);
|
||||
#endif
|
||||
AddDebugPos(declareInst, &sym->pos, &scope);
|
||||
}
|
||||
|
||||
|
||||
@@ -1759,16 +1778,17 @@ FunctionEmitContext::EmitFunctionParameterDebugInfo(Symbol *sym, int argNum) {
|
||||
if (m->diBuilder == NULL)
|
||||
return;
|
||||
|
||||
int flags = 0;
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DIScope scope = diSubprogram;
|
||||
llvm::DIType diType = sym->type->GetDIType(scope);
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
AssertPos(currentPos, diType.Verify());
|
||||
#else // LLVM 3.7+
|
||||
//comming soon
|
||||
#endif
|
||||
int flags = 0;
|
||||
|
||||
llvm::DIVariable var =
|
||||
#else // LLVM 3.7+
|
||||
llvm::MDScope *scope = diSubprogram;
|
||||
llvm::MDType *diType = sym->type->GetDIType(scope);
|
||||
llvm::MDLocalVariable *var =
|
||||
#endif
|
||||
m->diBuilder->createLocalVariable(llvm::dwarf::DW_TAG_arg_variable,
|
||||
scope,
|
||||
sym->name,
|
||||
@@ -1777,26 +1797,25 @@ FunctionEmitContext::EmitFunctionParameterDebugInfo(Symbol *sym, int argNum) {
|
||||
diType,
|
||||
true /* preserve through opts */,
|
||||
flags,
|
||||
argNum+1);
|
||||
argNum + 1);
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
AssertPos(currentPos, var.Verify());
|
||||
#else // LLVM 3.7+
|
||||
//comming soon
|
||||
#endif
|
||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5)// LLVM 3.6+
|
||||
llvm::DIExpression E = m->diBuilder->createExpression();
|
||||
llvm::Instruction *declareInst =
|
||||
m->diBuilder->insertDeclare(sym->storagePtr, var, E,
|
||||
#if !defined(LLVM_3_6) // LLVM 3.7++
|
||||
m->diBuilder->insertDeclare(sym->storagePtr, var,
|
||||
#if defined(LLVM_3_6)
|
||||
m->diBuilder->createExpression(),
|
||||
#endif
|
||||
bblock);
|
||||
AddDebugPos(declareInst, &sym->pos, &scope);
|
||||
#else // LLVM 3.7++
|
||||
llvm::Instruction *declareInst =
|
||||
m->diBuilder->insertDeclare(sym->storagePtr, var,
|
||||
m->diBuilder->createExpression(),
|
||||
llvm::DebugLoc::get(sym->pos.first_line,
|
||||
sym->pos.first_column, scope),
|
||||
#endif
|
||||
bblock);
|
||||
#else
|
||||
llvm::Instruction *declareInst =
|
||||
m->diBuilder->insertDeclare(sym->storagePtr, var, bblock);
|
||||
AddDebugPos(declareInst, &sym->pos, scope);
|
||||
#endif
|
||||
AddDebugPos(declareInst, &sym->pos, &scope);
|
||||
}
|
||||
|
||||
|
||||
|
||||
22
ctx.h
22
ctx.h
@@ -352,7 +352,11 @@ public:
|
||||
Instructions stored using Value pointers; the code here returns
|
||||
silently if it's not actually given an instruction. */
|
||||
void AddDebugPos(llvm::Value *instruction, const SourcePos *pos = NULL,
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DIScope *scope = NULL);
|
||||
#else // LLVM 3.7++
|
||||
llvm::MDScope *scope = NULL);
|
||||
#endif
|
||||
|
||||
/** Inform the debugging information generation code that a new scope
|
||||
is starting in the source program. */
|
||||
@@ -364,7 +368,11 @@ public:
|
||||
|
||||
/** Returns the llvm::DIScope corresponding to the current program
|
||||
scope. */
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DIScope GetDIScope() const;
|
||||
#else // LLVM 3.7++
|
||||
llvm::MDScope *GetDIScope() const;
|
||||
#endif
|
||||
|
||||
/** Emits debugging information for the variable represented by
|
||||
sym. */
|
||||
@@ -675,6 +683,7 @@ private:
|
||||
emitted. */
|
||||
std::vector<CFInfo *> controlFlowInfo;
|
||||
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
/** DIFile object corresponding to the source file where the current
|
||||
function was defined (used for debugging info). */
|
||||
llvm::DIFile diFile;
|
||||
@@ -685,10 +694,19 @@ private:
|
||||
|
||||
/** These correspond to the current set of nested scopes in the
|
||||
function. */
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
std::vector<llvm::DILexicalBlock> debugScopes;
|
||||
#else // LLVM 3.7++
|
||||
std::vector<llvm::DIScope> debugScopes;
|
||||
/** MDFile object corresponding to the source file where the current
|
||||
function was defined (used for debugging info). */
|
||||
llvm::MDFile *diFile;
|
||||
|
||||
/** MDSubprogram corresponding to this function (used for debugging
|
||||
info). */
|
||||
llvm::MDSubprogram *diSubprogram;
|
||||
|
||||
/** These correspond to the current set of nested scopes in the
|
||||
function. */
|
||||
std::vector<llvm::MDScope *> debugScopes;
|
||||
#endif
|
||||
|
||||
/** True if a 'launch' statement has been encountered in the function. */
|
||||
|
||||
8
ispc.cpp
8
ispc.cpp
@@ -1407,15 +1407,19 @@ SourcePos::SourcePos(const char *n, int fl, int fc, int ll, int lc) {
|
||||
}
|
||||
|
||||
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DIFile
|
||||
#else // LLVM 3.7+
|
||||
llvm::MDFile*
|
||||
#endif
|
||||
SourcePos::GetDIFile() const {
|
||||
std::string directory, filename;
|
||||
GetDirectoryAndFileName(g->currentDirectory, name, &directory, &filename);
|
||||
llvm::DIFile ret = m->diBuilder->createFile(filename, directory);
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DIFile ret = m->diBuilder->createFile(filename, directory);
|
||||
Assert(ret.Verify());
|
||||
#else // LLVM 3.7+
|
||||
//comming soon
|
||||
llvm::MDFile *ret = m->diBuilder->createFile(filename, directory);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
17
ispc.h
17
ispc.h
@@ -78,9 +78,6 @@ namespace llvm {
|
||||
class ConstantValue;
|
||||
class DataLayout;
|
||||
class DIBuilder;
|
||||
class DIDescriptor;
|
||||
class DIFile;
|
||||
class DIType;
|
||||
class Function;
|
||||
class FunctionType;
|
||||
class LLVMContext;
|
||||
@@ -89,6 +86,15 @@ namespace llvm {
|
||||
class TargetMachine;
|
||||
class Type;
|
||||
class Value;
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
class DIFile;
|
||||
class DIType;
|
||||
class DIDescriptor;
|
||||
#else // LLVM 3.7++
|
||||
class MDFile;
|
||||
class MDType;
|
||||
class MDScope;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -138,8 +144,13 @@ struct SourcePos {
|
||||
/** Prints the filename and line/column range to standard output. */
|
||||
void Print() const;
|
||||
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
/** Returns a LLVM DIFile object that represents the SourcePos's file */
|
||||
llvm::DIFile GetDIFile() const;
|
||||
#else
|
||||
/** Returns a LLVM MDFile object that represents the SourcePos's file */
|
||||
llvm::MDFile *GetDIFile() const;
|
||||
#endif
|
||||
|
||||
bool operator==(const SourcePos &p2) const;
|
||||
};
|
||||
|
||||
30
module.cpp
30
module.cpp
@@ -207,17 +207,17 @@ lStripUnusedDebugInfo(llvm::Module *module) {
|
||||
}
|
||||
if (scope.isSubprogram()) {
|
||||
#else // LLVM 3.7+
|
||||
llvm::DILocation dloc(llvm::cast<llvm::MDLocation>(node));
|
||||
llvm::DIScope scope = dloc->getScope();
|
||||
llvm::MDLocation *dloc = llvm::cast<llvm::MDLocation>(node);
|
||||
llvm::MDScope *scope = dloc->getScope();
|
||||
node = dloc->getInlinedAt();
|
||||
// now following a chain of nested scopes
|
||||
while (!0) {
|
||||
if (llvm::isa<llvm::MDLexicalBlockFile>(scope))
|
||||
scope = llvm::DILexicalBlockFile(llvm::cast<llvm::MDLexicalBlockFile>(scope))->getScope();
|
||||
scope = llvm::cast<llvm::MDLexicalBlockFile>(scope)->getScope();
|
||||
else if (llvm::isa<llvm::MDLexicalBlockBase>(scope))
|
||||
scope = llvm::DILexicalBlock(llvm::cast<llvm::MDLexicalBlockBase>(scope))->getScope();
|
||||
scope = llvm::cast<llvm::MDLexicalBlockBase>(scope)->getScope();
|
||||
else if (llvm::isa<llvm::MDNamespace>(scope))
|
||||
scope = llvm::DINameSpace(llvm::cast<llvm::MDNamespace>(scope))->getScope();
|
||||
scope = llvm::cast<llvm::MDNamespace>(scope)->getScope();
|
||||
else break;
|
||||
}
|
||||
if (llvm::isa<llvm::MDSubprogram>(scope)) {
|
||||
@@ -235,18 +235,14 @@ lStripUnusedDebugInfo(llvm::Module *module) {
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DICompileUnit cu(cuNode);
|
||||
llvm::DIArray subprograms = cu.getSubprograms();
|
||||
if (subprograms.getNumElements() == 0) {
|
||||
#else // LLVM 3.7+
|
||||
llvm::DICompileUnit cu(llvm::cast<llvm::MDCompileUnit>(cuNode));
|
||||
llvm::DIArray subprograms = cu->getSubprograms();
|
||||
#endif
|
||||
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
if (subprograms.getNumElements() == 0)
|
||||
#else // LLVM 3.7+
|
||||
if (subprograms.size() == 0)
|
||||
llvm::MDCompileUnit *cu = llvm::cast<llvm::MDCompileUnit>(cuNode);
|
||||
llvm::MDSubprogramArray subprograms = cu->getSubprograms();
|
||||
if (subprograms.size() == 0) {
|
||||
#endif
|
||||
continue;
|
||||
|
||||
}
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5)
|
||||
std::set<llvm::Value *> SPset;
|
||||
std::vector<llvm::Value *> usedSubprograms;
|
||||
@@ -345,7 +341,7 @@ lStripUnusedDebugInfo(llvm::Module *module) {
|
||||
llvm::ArrayRef<llvm::Metadata *>(usedSubprograms));
|
||||
cu.replaceSubprograms(llvm::DIArray(replNode));
|
||||
#else // LLVM 3.7+
|
||||
llvm::DIArray nodeSPs = cu->getSubprograms();
|
||||
llvm::MDSubprogramArray nodeSPs = cu->getSubprograms();
|
||||
Assert(nodeSPs.size() == subprograms.size());
|
||||
for (int i = 0; i < (int)nodeSPs.size(); ++i)
|
||||
Assert(nodeSPs [i] == subprograms [i]);
|
||||
@@ -702,8 +698,8 @@ Module::AddGlobalVariable(const std::string &name, const Type *type, Expr *initE
|
||||
}
|
||||
|
||||
if (diBuilder) {
|
||||
llvm::DIFile file = pos.GetDIFile();
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5)
|
||||
llvm::DIFile file = pos.GetDIFile();
|
||||
llvm::DIGlobalVariable var = diBuilder->createGlobalVariable(
|
||||
name,
|
||||
file,
|
||||
@@ -712,6 +708,7 @@ Module::AddGlobalVariable(const std::string &name, const Type *type, Expr *initE
|
||||
(sym->storageClass == SC_STATIC),
|
||||
sym->storagePtr);
|
||||
#elif defined(LLVM_3_6)
|
||||
llvm::DIFile file = pos.GetDIFile();
|
||||
llvm::Constant *sym_const_storagePtr = llvm::dyn_cast<llvm::Constant>(sym->storagePtr);
|
||||
Assert(sym_const_storagePtr);
|
||||
llvm::DIGlobalVariable var = diBuilder->createGlobalVariable(
|
||||
@@ -724,6 +721,7 @@ Module::AddGlobalVariable(const std::string &name, const Type *type, Expr *initE
|
||||
(sym->storageClass == SC_STATIC),
|
||||
sym_const_storagePtr);
|
||||
#else // LLVM 3.7+
|
||||
llvm::MDFile *file = pos.GetDIFile();
|
||||
llvm::Constant *sym_const_storagePtr = llvm::dyn_cast<llvm::Constant>(sym->storagePtr);
|
||||
Assert(sym_const_storagePtr);
|
||||
diBuilder->createGlobalVariable(
|
||||
|
||||
4
module.h
4
module.h
@@ -161,8 +161,10 @@ public:
|
||||
/** The diBuilder manages generating debugging information */
|
||||
llvm::DIBuilder *diBuilder;
|
||||
|
||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3)
|
||||
#if defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DICompileUnit diCompileUnit;
|
||||
#elif !defined(LLVM_3_2) && !defined(LLVM_3_3) // LLVM 3.7++
|
||||
llvm::MDCompileUnit *diCompileUnit;
|
||||
#endif // LLVM_3_4+
|
||||
|
||||
private:
|
||||
|
||||
206
type.cpp
206
type.cpp
@@ -77,10 +77,13 @@ lShouldPrintName(const std::string &name) {
|
||||
}
|
||||
|
||||
|
||||
/** Utility routine to create a llvm DIArray type of the given number of
|
||||
/** Utility routine to create a llvm array type of the given number of
|
||||
the given element type. */
|
||||
static llvm::DIType
|
||||
lCreateDIArray(llvm::DIType eltType, int count) {
|
||||
#if defined (LLVM_3_2) || defined (LLVM_3_3) || defined (LLVM_3_4) || defined (LLVM_3_5) || defined (LLVM_3_6)
|
||||
static llvm::DIType lCreateDIArray(llvm::DIType eltType, int count) {
|
||||
#else // LLVM 3.7++
|
||||
static llvm::MDType *lCreateDIArray(llvm::MDType *eltType, int count) {
|
||||
#endif
|
||||
#ifdef LLVM_3_2
|
||||
int lowerBound = 0, upperBound = count-1;
|
||||
|
||||
@@ -102,12 +105,13 @@ lCreateDIArray(llvm::DIType eltType, int count) {
|
||||
std::vector<llvm::Metadata *> subs;
|
||||
#endif
|
||||
subs.push_back(sub);
|
||||
llvm::DIArray subArray = m->diBuilder->getOrCreateArray(subs);
|
||||
|
||||
#if defined (LLVM_3_2) || defined (LLVM_3_3) || defined (LLVM_3_4) || defined (LLVM_3_5) || defined (LLVM_3_6)
|
||||
llvm::DIArray subArray = m->diBuilder->getOrCreateArray(subs);
|
||||
uint64_t size = eltType.getSizeInBits() * count;
|
||||
uint64_t align = eltType.getAlignInBits();
|
||||
#else // LLVM 3.7++
|
||||
llvm::DebugNodeArray subArray = m->diBuilder->getOrCreateArray(subs);
|
||||
uint64_t size = eltType->getSizeInBits() * count;
|
||||
uint64_t align = eltType->getAlignInBits();
|
||||
#endif
|
||||
@@ -521,14 +525,21 @@ AtomicType::LLVMType(llvm::LLVMContext *ctx) const {
|
||||
}
|
||||
|
||||
|
||||
llvm::DIType
|
||||
AtomicType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DIType AtomicType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
#else //LLVM 3.7++
|
||||
llvm::MDType *AtomicType::GetDIType(llvm::MDScope *scope) const {
|
||||
#endif
|
||||
Assert(variability.type != Variability::Unbound);
|
||||
|
||||
if (variability.type == Variability::Uniform) {
|
||||
switch (basicType) {
|
||||
case TYPE_VOID:
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
return llvm::DIType();
|
||||
#else //LLVM 3.7++
|
||||
return NULL;
|
||||
#endif
|
||||
case TYPE_BOOL:
|
||||
return m->diBuilder->createBasicType("bool", 32 /* size */, 32 /* align */,
|
||||
llvm::dwarf::DW_ATE_unsigned);
|
||||
@@ -575,11 +586,14 @@ AtomicType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
break;
|
||||
default:
|
||||
FATAL("unhandled basic type in AtomicType::GetDIType()");
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
return llvm::DIType();
|
||||
#else //LLVM 3.7++
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else if (variability == Variability::Varying) {
|
||||
llvm::DIType unifType = GetAsUniformType()->GetDIType(scope);
|
||||
#ifdef LLVM_3_2
|
||||
llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, g->target->getVectorWidth()-1);
|
||||
#elif defined (LLVM_3_3)|| defined (LLVM_3_4) || defined (LLVM_3_5)
|
||||
@@ -587,11 +601,14 @@ AtomicType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
#else // LLVM 3.6++
|
||||
llvm::Metadata *sub = m->diBuilder->getOrCreateSubrange(0, g->target->getVectorWidth());
|
||||
#endif
|
||||
llvm::DIArray subArray = m->diBuilder->getOrCreateArray(sub);
|
||||
#if defined (LLVM_3_3)|| defined (LLVM_3_4) || defined (LLVM_3_5) || defined (LLVM_3_6)
|
||||
llvm::DIArray subArray = m->diBuilder->getOrCreateArray(sub);
|
||||
llvm::DIType unifType = GetAsUniformType()->GetDIType(scope);
|
||||
uint64_t size = unifType.getSizeInBits() * g->target->getVectorWidth();
|
||||
uint64_t align = unifType.getAlignInBits() * g->target->getVectorWidth();
|
||||
#else // LLVM 3.7++
|
||||
llvm::DebugNodeArray subArray = m->diBuilder->getOrCreateArray(sub);
|
||||
llvm::MDType *unifType = GetAsUniformType()->GetDIType(scope);
|
||||
uint64_t size = unifType->getSizeInBits() * g->target->getVectorWidth();
|
||||
uint64_t align = unifType->getAlignInBits()* g->target->getVectorWidth();
|
||||
#endif
|
||||
@@ -827,8 +844,12 @@ EnumType::LLVMType(llvm::LLVMContext *ctx) const {
|
||||
}
|
||||
|
||||
|
||||
llvm::DIType
|
||||
EnumType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DIType EnumType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
#else // LLVM 3.7++
|
||||
llvm::MDType *EnumType::GetDIType(llvm::MDScope *scope) const {
|
||||
#endif
|
||||
|
||||
#if defined (LLVM_3_2) || defined (LLVM_3_3) || defined (LLVM_3_4) || defined (LLVM_3_5)
|
||||
std::vector<llvm::Value *> enumeratorDescriptors;
|
||||
#else // LLVM 3.6++
|
||||
@@ -847,19 +868,25 @@ EnumType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
m->diBuilder->createEnumerator(enumerators[i]->name, enumeratorValue);
|
||||
enumeratorDescriptors.push_back(descriptor);
|
||||
}
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DIArray elementArray =
|
||||
m->diBuilder->getOrCreateArray(enumeratorDescriptors);
|
||||
|
||||
llvm::DIFile diFile = pos.GetDIFile();
|
||||
llvm::DIType diType =
|
||||
m->diBuilder->createEnumerationType(diFile, name, diFile, pos.first_line,
|
||||
32 /* size in bits */,
|
||||
32 /* align in bits */,
|
||||
elementArray
|
||||
, llvm::DIType()
|
||||
);
|
||||
|
||||
|
||||
elementArray, llvm::DIType());
|
||||
#else // LLVM 3.7++
|
||||
llvm::DebugNodeArray elementArray =
|
||||
m->diBuilder->getOrCreateArray(enumeratorDescriptors);
|
||||
llvm::MDFile *diFile = pos.GetDIFile();
|
||||
llvm::MDType *diType =
|
||||
m->diBuilder->createEnumerationType(diFile, name, diFile, pos.first_line,
|
||||
32 /* size in bits */,
|
||||
32 /* align in bits */,
|
||||
elementArray, NULL);
|
||||
#endif
|
||||
switch (variability.type) {
|
||||
case Variability::Uniform:
|
||||
return diType;
|
||||
@@ -871,11 +898,12 @@ EnumType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
#else // LLVM 3.6++
|
||||
llvm::Metadata *sub = m->diBuilder->getOrCreateSubrange(0, g->target->getVectorWidth());
|
||||
#endif
|
||||
llvm::DIArray subArray = m->diBuilder->getOrCreateArray(sub);
|
||||
#if defined (LLVM_3_3)|| defined (LLVM_3_4) || defined (LLVM_3_5) || defined (LLVM_3_6)
|
||||
llvm::DIArray subArray = m->diBuilder->getOrCreateArray(sub);
|
||||
uint64_t size = diType.getSizeInBits() * g->target->getVectorWidth();
|
||||
uint64_t align = diType.getAlignInBits() * g->target->getVectorWidth();
|
||||
#else // LLVM 3.7++
|
||||
llvm::DebugNodeArray subArray = m->diBuilder->getOrCreateArray(sub);
|
||||
uint64_t size = diType->getSizeInBits() * g->target->getVectorWidth();
|
||||
uint64_t align = diType->getAlignInBits()* g->target->getVectorWidth();
|
||||
#endif
|
||||
@@ -886,7 +914,11 @@ EnumType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
}
|
||||
default:
|
||||
FATAL("Unexpected variability in EnumType::GetDIType()");
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
return llvm::DIType();
|
||||
#else //LLVM 3.7++
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1220,14 +1252,21 @@ PointerType::LLVMType(llvm::LLVMContext *ctx) const {
|
||||
}
|
||||
|
||||
|
||||
llvm::DIType
|
||||
PointerType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DIType PointerType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
if (baseType == NULL) {
|
||||
Assert(m->errorCount > 0);
|
||||
return llvm::DIType();
|
||||
}
|
||||
|
||||
llvm::DIType diTargetType = baseType->GetDIType(scope);
|
||||
#else //LLVM 3.7++
|
||||
llvm::MDType *PointerType::GetDIType(llvm::MDScope *scope) const {
|
||||
if (baseType == NULL) {
|
||||
Assert(m->errorCount > 0);
|
||||
return NULL;
|
||||
}
|
||||
llvm::MDType *diTargetType = baseType->GetDIType(scope);
|
||||
#endif
|
||||
int bitsSize = g->target->is32Bit() ? 32 : 64;
|
||||
int ptrAlignBits = bitsSize;
|
||||
switch (variability.type) {
|
||||
@@ -1236,8 +1275,11 @@ PointerType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
ptrAlignBits);
|
||||
case Variability::Varying: {
|
||||
// emit them as an array of pointers
|
||||
llvm::DIType eltType = m->diBuilder->createPointerType(diTargetType,
|
||||
bitsSize, ptrAlignBits);
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
#else //LLVM 3.7++
|
||||
llvm::MDDerivedType *eltType =
|
||||
m->diBuilder->createPointerType(diTargetType, bitsSize, ptrAlignBits);
|
||||
#endif
|
||||
return lCreateDIArray(eltType, g->target->getVectorWidth());
|
||||
}
|
||||
case Variability::SOA: {
|
||||
@@ -1246,7 +1288,11 @@ PointerType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
}
|
||||
default:
|
||||
FATAL("Unexpected variability in PointerType::GetDIType()");
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
return llvm::DIType();
|
||||
#else //LLVM 3.7++
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1520,14 +1566,21 @@ ArrayType::TotalElementCount() const {
|
||||
}
|
||||
|
||||
|
||||
llvm::DIType
|
||||
ArrayType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DIType ArrayType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
if (child == NULL) {
|
||||
Assert(m->errorCount > 0);
|
||||
return llvm::DIType();
|
||||
}
|
||||
|
||||
llvm::DIType eltType = child->GetDIType(scope);
|
||||
#else //LLVM 3.7++
|
||||
llvm::MDType *ArrayType::GetDIType(llvm::MDScope *scope) const {
|
||||
if (child == NULL) {
|
||||
Assert(m->errorCount > 0);
|
||||
return NULL;
|
||||
}
|
||||
llvm::MDType *eltType = child->GetDIType(scope);
|
||||
#endif
|
||||
return lCreateDIArray(eltType, numElements);
|
||||
}
|
||||
|
||||
@@ -1762,9 +1815,13 @@ VectorType::LLVMType(llvm::LLVMContext *ctx) const {
|
||||
}
|
||||
|
||||
|
||||
llvm::DIType
|
||||
VectorType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DIType VectorType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
llvm::DIType eltType = base->GetDIType(scope);
|
||||
#else //LLVM 3.7++
|
||||
llvm::MDType *VectorType::GetDIType(llvm::MDScope *scope) const {
|
||||
llvm::MDType *eltType = base->GetDIType(scope);
|
||||
#endif
|
||||
#ifdef LLVM_3_2
|
||||
llvm::Value *sub = m->diBuilder->getOrCreateSubrange(0, numElements-1);
|
||||
#elif defined (LLVM_3_3)|| defined (LLVM_3_4) || defined (LLVM_3_5)
|
||||
@@ -1772,15 +1829,16 @@ VectorType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
#else // LLVM 3.6++
|
||||
llvm::Metadata *sub = m->diBuilder->getOrCreateSubrange(0, numElements);
|
||||
#endif
|
||||
llvm::DIArray subArray = m->diBuilder->getOrCreateArray(sub);
|
||||
|
||||
// vectors of varying types are already naturally aligned to the
|
||||
// machine's vector width, but arrays of uniform types need to be
|
||||
// explicitly aligned to the machines natural vector alignment.
|
||||
#if defined (LLVM_3_3)|| defined (LLVM_3_4) || defined (LLVM_3_5) || defined (LLVM_3_6)
|
||||
llvm::DIArray subArray = m->diBuilder->getOrCreateArray(sub);
|
||||
uint64_t sizeBits = eltType.getSizeInBits() * numElements;
|
||||
uint64_t align = eltType.getAlignInBits();
|
||||
#else // LLVM 3.7++
|
||||
llvm::DebugNodeArray subArray = m->diBuilder->getOrCreateArray(sub);
|
||||
uint64_t sizeBits = eltType->getSizeInBits() * numElements;
|
||||
uint64_t align = eltType->getAlignInBits();
|
||||
#endif
|
||||
@@ -1796,7 +1854,11 @@ VectorType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
}
|
||||
else {
|
||||
FATAL("Unexpected variability in VectorType::GetDIType()");
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
return llvm::DIType();
|
||||
#else // LLVM 3.7++
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2196,8 +2258,11 @@ StructType::LLVMType(llvm::LLVMContext *ctx) const {
|
||||
}
|
||||
|
||||
|
||||
llvm::DIType
|
||||
StructType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DIType StructType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
#else //LLVM 3.7++
|
||||
llvm::MDType *StructType::GetDIType(llvm::MDScope *scope) const {
|
||||
#endif
|
||||
uint64_t currentSize = 0, align = 0;
|
||||
#if defined (LLVM_3_2) || defined (LLVM_3_3) || defined (LLVM_3_4) || defined (LLVM_3_5)
|
||||
std::vector<llvm::Value *> elementLLVMTypes;
|
||||
@@ -2208,11 +2273,12 @@ StructType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
// alignment and size, using that to figure out its offset w.r.t. the
|
||||
// start of the structure.
|
||||
for (unsigned int i = 0; i < elementTypes.size(); ++i) {
|
||||
llvm::DIType eltType = GetElementType(i)->GetDIType(scope);
|
||||
#if defined (LLVM_3_2) || defined (LLVM_3_3) || defined (LLVM_3_4) || defined (LLVM_3_5) || defined (LLVM_3_6)
|
||||
llvm::DIType eltType = GetElementType(i)->GetDIType(scope);
|
||||
uint64_t eltAlign = eltType.getAlignInBits();
|
||||
uint64_t eltSize = eltType.getSizeInBits();
|
||||
#else // LLVM 3.7++
|
||||
llvm::MDType *eltType = GetElementType(i)->GetDIType(scope);
|
||||
uint64_t eltAlign = eltType->getAlignInBits();
|
||||
uint64_t eltSize = eltType->getSizeInBits();
|
||||
#endif
|
||||
@@ -2228,9 +2294,14 @@ StructType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
currentSize += eltAlign - (currentSize % eltAlign);
|
||||
Assert((currentSize == 0) || (currentSize % eltAlign) == 0);
|
||||
|
||||
llvm::DIFile diFile = elementPositions[i].GetDIFile();
|
||||
int line = elementPositions[i].first_line;
|
||||
#if defined (LLVM_3_2) || defined (LLVM_3_3) || defined (LLVM_3_4) || defined (LLVM_3_5) || defined (LLVM_3_6)
|
||||
llvm::DIFile diFile = elementPositions[i].GetDIFile();
|
||||
llvm::DIType fieldType =
|
||||
#else // LLVM 3.7++
|
||||
llvm::MDFile *diFile = elementPositions[i].GetDIFile();
|
||||
llvm::MDDerivedType *fieldType =
|
||||
#endif
|
||||
m->diBuilder->createMemberType(scope, elementNames[i], diFile,
|
||||
line, eltSize, eltAlign,
|
||||
currentSize, 0, eltType);
|
||||
@@ -2244,8 +2315,13 @@ StructType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
if (currentSize > 0 && (currentSize % align))
|
||||
currentSize += align - (currentSize % align);
|
||||
|
||||
#if defined (LLVM_3_2) || defined (LLVM_3_3) || defined (LLVM_3_4) || defined (LLVM_3_5) || defined (LLVM_3_6)
|
||||
llvm::DIArray elements = m->diBuilder->getOrCreateArray(elementLLVMTypes);
|
||||
llvm::DIFile diFile = pos.GetDIFile();
|
||||
#else // LLVM 3.7++
|
||||
llvm::DebugNodeArray elements = m->diBuilder->getOrCreateArray(elementLLVMTypes);
|
||||
llvm::MDFile *diFile = pos.GetDIFile();
|
||||
#endif
|
||||
return m->diBuilder->createStructType(
|
||||
diFile,
|
||||
name,
|
||||
@@ -2254,8 +2330,10 @@ StructType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
currentSize, // Size in bits
|
||||
align, // Alignment in bits
|
||||
0, // Flags
|
||||
#if !defined(LLVM_3_2)
|
||||
#if defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DIType(), // DerivedFrom
|
||||
#elif !defined(LLVM_3_2) // LLVM 3.7++
|
||||
NULL,
|
||||
#endif
|
||||
elements);
|
||||
}
|
||||
@@ -2485,10 +2563,15 @@ UndefinedStructType::LLVMType(llvm::LLVMContext *ctx) const {
|
||||
}
|
||||
|
||||
|
||||
llvm::DIType
|
||||
UndefinedStructType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DIType UndefinedStructType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
llvm::DIFile diFile = pos.GetDIFile();
|
||||
llvm::DIArray elements;
|
||||
#else //LLVM 3.7++
|
||||
llvm::MDType *UndefinedStructType::GetDIType(llvm::MDScope *scope) const {
|
||||
llvm::MDFile *diFile = pos.GetDIFile();
|
||||
llvm::DebugNodeArray elements;
|
||||
#endif
|
||||
return m->diBuilder->createStructType(
|
||||
diFile,
|
||||
name,
|
||||
@@ -2497,8 +2580,10 @@ UndefinedStructType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
0, // Size
|
||||
0, // Align
|
||||
0, // Flags
|
||||
#if !defined(LLVM_3_2)
|
||||
#if defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DIType(), // DerivedFrom
|
||||
#elif !defined(LLVM_3_2) // LLVM 3.7++
|
||||
NULL,
|
||||
#endif
|
||||
elements);
|
||||
}
|
||||
@@ -2752,14 +2837,21 @@ ReferenceType::LLVMType(llvm::LLVMContext *ctx) const {
|
||||
}
|
||||
|
||||
|
||||
llvm::DIType
|
||||
ReferenceType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DIType ReferenceType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
if (targetType == NULL) {
|
||||
Assert(m->errorCount > 0);
|
||||
return llvm::DIType();
|
||||
}
|
||||
|
||||
llvm::DIType diTargetType = targetType->GetDIType(scope);
|
||||
#else //LLVM 3.7++
|
||||
llvm::MDType *ReferenceType::GetDIType(llvm::MDScope *scope) const {
|
||||
if (targetType == NULL) {
|
||||
Assert(m->errorCount > 0);
|
||||
return NULL;
|
||||
}
|
||||
llvm::MDType *diTargetType = targetType->GetDIType(scope);
|
||||
#endif
|
||||
return m->diBuilder->createReferenceType(llvm::dwarf::DW_TAG_reference_type,
|
||||
diTargetType);
|
||||
}
|
||||
@@ -3024,8 +3116,12 @@ FunctionType::LLVMType(llvm::LLVMContext *ctx) const {
|
||||
}
|
||||
|
||||
|
||||
llvm::DIType
|
||||
FunctionType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DIType FunctionType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
#else //LLVM 3.7++
|
||||
llvm::MDType *FunctionType::GetDIType(llvm::MDScope *scope) const {
|
||||
#endif
|
||||
|
||||
#if defined (LLVM_3_2) || defined (LLVM_3_3) || defined (LLVM_3_4) || defined (LLVM_3_5)
|
||||
std::vector<llvm::Value *> retArgTypes;
|
||||
#else // LLVM 3.6++
|
||||
@@ -3036,25 +3132,33 @@ FunctionType::GetDIType(llvm::DIDescriptor scope) const {
|
||||
const Type *t = GetParameterType(i);
|
||||
if (t == NULL)
|
||||
|
||||
#if !defined(LLVM_3_2) && !defined(LLVM_3_3)// LLVM 3.4+
|
||||
return llvm::DICompositeType();
|
||||
#else
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3)
|
||||
return llvm::DIType();
|
||||
#elif defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
return llvm::DICompositeType();
|
||||
#else // LLVM 3.7++
|
||||
return NULL;
|
||||
#endif
|
||||
retArgTypes.push_back(t->GetDIType(scope));
|
||||
}
|
||||
|
||||
#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(retArgTypes);
|
||||
#else
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5)
|
||||
llvm::DIArray retArgTypesArray =
|
||||
m->diBuilder->getOrCreateArray(llvm::ArrayRef<llvm::Value *>(retArgTypes));
|
||||
#endif
|
||||
|
||||
llvm::DIType diType =
|
||||
// FIXME: DIFile
|
||||
m->diBuilder->createSubroutineType(llvm::DIFile(), retArgTypesArray);
|
||||
#elif defined(LLVM_3_6)
|
||||
llvm::DITypeArray retArgTypesArray =
|
||||
m->diBuilder->getOrCreateTypeArray(retArgTypes);
|
||||
llvm::DIType diType =
|
||||
// FIXME: DIFile
|
||||
m->diBuilder->createSubroutineType(llvm::DIFile(), retArgTypesArray);
|
||||
#else // LLVM 3.7++
|
||||
llvm::MDTypeRefArray retArgTypesArray =
|
||||
m->diBuilder->getOrCreateTypeArray(retArgTypes);
|
||||
llvm::MDType *diType =
|
||||
m->diBuilder->createSubroutineType(NULL, retArgTypesArray);
|
||||
#endif
|
||||
return diType;
|
||||
}
|
||||
|
||||
|
||||
42
type.h
42
type.h
@@ -222,9 +222,15 @@ public:
|
||||
/** Returns the LLVM type corresponding to this ispc type */
|
||||
virtual llvm::Type *LLVMType(llvm::LLVMContext *ctx) const = 0;
|
||||
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
/** Returns the DIType (LLVM's debugging information structure),
|
||||
corresponding to this type. */
|
||||
virtual llvm::DIType GetDIType(llvm::DIDescriptor scope) const = 0;
|
||||
#else
|
||||
/** Returns the MDType (LLVM's debugging information structure),
|
||||
corresponding to this type. */
|
||||
virtual llvm::MDType *GetDIType(llvm::MDScope *scope) const = 0;
|
||||
#endif
|
||||
|
||||
/** Checks two types for equality. Returns true if they are exactly
|
||||
the same, false otherwise. */
|
||||
@@ -311,7 +317,11 @@ public:
|
||||
std::string GetCDeclaration(const std::string &name) const;
|
||||
|
||||
llvm::Type *LLVMType(llvm::LLVMContext *ctx) const;
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DIType GetDIType(llvm::DIDescriptor scope) const;
|
||||
#else // LLVM 3.7++
|
||||
llvm::MDType *GetDIType(llvm::MDScope *scope) const;
|
||||
#endif
|
||||
|
||||
/** This enumerator records the basic types that AtomicTypes can be
|
||||
built from. */
|
||||
@@ -390,7 +400,11 @@ public:
|
||||
const std::string &GetEnumName() const { return name; }
|
||||
|
||||
llvm::Type *LLVMType(llvm::LLVMContext *ctx) const;
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DIType GetDIType(llvm::DIDescriptor scope) const;
|
||||
#else // LLVM 3.7++
|
||||
llvm::MDType *GetDIType(llvm::MDScope *scope) const;
|
||||
#endif
|
||||
|
||||
/** Provides the enumerators defined in the enum definition. */
|
||||
void SetEnumerators(const std::vector<Symbol *> &enumerators);
|
||||
@@ -471,7 +485,11 @@ public:
|
||||
std::string GetCDeclaration(const std::string &name) const;
|
||||
|
||||
llvm::Type *LLVMType(llvm::LLVMContext *ctx) const;
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DIType GetDIType(llvm::DIDescriptor scope) const;
|
||||
#else // LLVM 3.7++
|
||||
llvm::MDType *GetDIType(llvm::MDScope *scope) const;
|
||||
#endif
|
||||
|
||||
static PointerType *Void;
|
||||
|
||||
@@ -573,7 +591,11 @@ public:
|
||||
std::string Mangle() const;
|
||||
std::string GetCDeclaration(const std::string &name) const;
|
||||
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DIType GetDIType(llvm::DIDescriptor scope) const;
|
||||
#else // LLVM 3.7++
|
||||
llvm::MDType *GetDIType(llvm::MDScope *scope) const;
|
||||
#endif
|
||||
llvm::ArrayType *LLVMType(llvm::LLVMContext *ctx) const;
|
||||
|
||||
/** This method returns the total number of elements in the array,
|
||||
@@ -641,7 +663,11 @@ public:
|
||||
std::string GetCDeclaration(const std::string &name) const;
|
||||
|
||||
llvm::Type *LLVMType(llvm::LLVMContext *ctx) const;
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DIType GetDIType(llvm::DIDescriptor scope) const;
|
||||
#else // LLVM 3.7++
|
||||
llvm::MDType *GetDIType(llvm::MDScope *scope) const;
|
||||
#endif
|
||||
|
||||
int GetElementCount() const;
|
||||
const AtomicType *GetElementType() const;
|
||||
@@ -692,7 +718,11 @@ public:
|
||||
std::string GetCDeclaration(const std::string &name) const;
|
||||
|
||||
llvm::Type *LLVMType(llvm::LLVMContext *ctx) const;
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DIType GetDIType(llvm::DIDescriptor scope) const;
|
||||
#else // LLVM 3.7++
|
||||
llvm::MDType *GetDIType(llvm::MDScope *scope) const;
|
||||
#endif
|
||||
|
||||
/** Returns the type of the structure element with the given name (if any).
|
||||
Returns NULL if there is no such named element. */
|
||||
@@ -780,7 +810,11 @@ public:
|
||||
std::string GetCDeclaration(const std::string &name) const;
|
||||
|
||||
llvm::Type *LLVMType(llvm::LLVMContext *ctx) const;
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DIType GetDIType(llvm::DIDescriptor scope) const;
|
||||
#else // LLVM 3.7++
|
||||
llvm::MDType *GetDIType(llvm::MDScope *scope) const;
|
||||
#endif
|
||||
|
||||
/** Returns the name of the structure type. (e.g. struct Foo -> "Foo".) */
|
||||
const std::string &GetStructName() const { return name; }
|
||||
@@ -823,7 +857,11 @@ public:
|
||||
std::string GetCDeclaration(const std::string &name) const;
|
||||
|
||||
llvm::Type *LLVMType(llvm::LLVMContext *ctx) const;
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DIType GetDIType(llvm::DIDescriptor scope) const;
|
||||
#else // LLVM 3.7++
|
||||
llvm::MDType *GetDIType(llvm::MDScope *scope) const;
|
||||
#endif
|
||||
|
||||
private:
|
||||
const Type * const targetType;
|
||||
@@ -877,7 +915,11 @@ public:
|
||||
std::string GetCDeclarationForDispatch(const std::string &fname) const;
|
||||
|
||||
llvm::Type *LLVMType(llvm::LLVMContext *ctx) const;
|
||||
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
|
||||
llvm::DIType GetDIType(llvm::DIDescriptor scope) const;
|
||||
#else // LLVM 3.7++
|
||||
llvm::MDType *GetDIType(llvm::MDScope *scope) const;
|
||||
#endif
|
||||
|
||||
const Type *GetReturnType() const { return returnType; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user