Merge pull request #1007 from Vsevolod-Livinskij/fix_for_trunk

Fix for trunk
This commit is contained in:
Dmitry Babokin
2015-04-10 15:25:17 +03:00
4 changed files with 167 additions and 21 deletions

View File

@@ -919,12 +919,24 @@ lDefineConstantInt(const char *name, int val, llvm::Module *module,
if (m->diBuilder != NULL) { if (m->diBuilder != NULL) {
llvm::DIFile file; llvm::DIFile file;
llvm::DIType diType = sym->type->GetDIType(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()); Assert(diType.Verify());
#else // LLVM 3.7+
//comming soon
#endif
// FIXME? DWARF says that this (and programIndex below) should // FIXME? DWARF says that this (and programIndex below) should
// have the DW_AT_artifical attribute. It's not clear if this // have the DW_AT_artifical attribute. It's not clear if this
// matters for anything though. // matters for anything though.
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5)// LLVM 3.6+ #if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5)
llvm::DIGlobalVariable var = m->diBuilder->createGlobalVariable(
name,
file,
0 /* line */,
diType,
true /* static */,
sym->storagePtr);
#elif defined(LLVM_3_6)
llvm::Constant *sym_const_storagePtr = llvm::dyn_cast<llvm::Constant>(sym->storagePtr); llvm::Constant *sym_const_storagePtr = llvm::dyn_cast<llvm::Constant>(sym->storagePtr);
Assert(sym_const_storagePtr); Assert(sym_const_storagePtr);
llvm::DIGlobalVariable var = m->diBuilder->createGlobalVariable( llvm::DIGlobalVariable var = m->diBuilder->createGlobalVariable(
@@ -936,16 +948,24 @@ lDefineConstantInt(const char *name, int val, llvm::Module *module,
diType, diType,
true /* static */, true /* static */,
sym_const_storagePtr); sym_const_storagePtr);
#else #else // LLVM 3.7+
llvm::DIGlobalVariable var = m->diBuilder->createGlobalVariable( llvm::Constant *sym_const_storagePtr = llvm::dyn_cast<llvm::Constant>(sym->storagePtr);
name, Assert(sym_const_storagePtr);
file, m->diBuilder->createGlobalVariable(
0 /* line */, file,
diType, name,
true /* static */, name,
sym->storagePtr); file,
0 /* line */,
diType,
true /* static */,
sym_const_storagePtr);
#endif #endif
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
Assert(var.Verify()); Assert(var.Verify());
#else // LLVM 3.7+
//comming soon
#endif
} }
} }
@@ -997,8 +1017,12 @@ lDefineProgramIndex(llvm::Module *module, SymbolTable *symbolTable) {
if (m->diBuilder != NULL) { if (m->diBuilder != NULL) {
llvm::DIFile file; llvm::DIFile file;
llvm::DIType diType = sym->type->GetDIType(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()); Assert(diType.Verify());
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5)// LLVM 3.6+ #else // LLVM 3.7+
//comming soon
#endif
#if defined(LLVM_3_6)// LLVM 3.6+
llvm::Constant *sym_const_storagePtr = llvm::dyn_cast<llvm::Constant>(sym->storagePtr); llvm::Constant *sym_const_storagePtr = llvm::dyn_cast<llvm::Constant>(sym->storagePtr);
Assert(sym_const_storagePtr); Assert(sym_const_storagePtr);
llvm::DIGlobalVariable var = m->diBuilder->createGlobalVariable( llvm::DIGlobalVariable var = m->diBuilder->createGlobalVariable(
@@ -1010,7 +1034,7 @@ lDefineProgramIndex(llvm::Module *module, SymbolTable *symbolTable) {
diType, diType,
false /* static */, false /* static */,
sym_const_storagePtr); sym_const_storagePtr);
#else #elif defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5)
llvm::DIGlobalVariable var = m->diBuilder->createGlobalVariable( llvm::DIGlobalVariable var = m->diBuilder->createGlobalVariable(
sym->name.c_str(), sym->name.c_str(),
file, file,
@@ -1018,8 +1042,24 @@ lDefineProgramIndex(llvm::Module *module, SymbolTable *symbolTable) {
diType, diType,
false /* static */, false /* static */,
sym->storagePtr); sym->storagePtr);
#else
llvm::Constant *sym_const_storagePtr = llvm::dyn_cast<llvm::Constant>(sym->storagePtr);
Assert(sym_const_storagePtr);
m->diBuilder->createGlobalVariable(
file,
sym->name.c_str(),
sym->name.c_str(),
file,
0 /* line */,
diType,
false /* static */,
sym_const_storagePtr);
#endif #endif
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
Assert(var.Verify()); Assert(var.Verify());
#else // LLVM 3.7+
//comming soon
#endif
} }
} }

47
ctx.cpp
View File

@@ -338,14 +338,23 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym,
/* 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 */
diFile = funcStartPos.GetDIFile(); diFile = funcStartPos.GetDIFile();
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
AssertPos(currentPos, diFile.Verify()); AssertPos(currentPos, diFile.Verify());
#else // LLVM 3.7+
//comming soon
#endif
#if defined(LLVM_3_2) || defined(LLVM_3_3) #if defined(LLVM_3_2) || defined(LLVM_3_3)
llvm::DIScope scope = llvm::DIScope(m->diBuilder->getCU()); llvm::DIScope scope = llvm::DIScope(m->diBuilder->getCU());
#else // LLVM_3_4+ #else // LLVM_3_4+
llvm::DIScope scope = llvm::DIScope(m->diCompileUnit); llvm::DIScope scope = llvm::DIScope(m->diCompileUnit);
#endif #endif
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
AssertPos(currentPos, scope.Verify()); AssertPos(currentPos, scope.Verify());
#else // LLVM 3.7+
//comming soon
#endif
const FunctionType *functionType = function->GetType(); const FunctionType *functionType = function->GetType();
llvm::DIType diSubprogramType; llvm::DIType diSubprogramType;
@@ -353,15 +362,23 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym,
AssertPos(currentPos, m->errorCount > 0); AssertPos(currentPos, m->errorCount > 0);
else { else {
diSubprogramType = functionType->GetDIType(scope); diSubprogramType = functionType->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, diSubprogramType.Verify()); AssertPos(currentPos, diSubprogramType.Verify());
#else // LLVM 3.7+
//comming soon
#endif
} }
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) #if defined(LLVM_3_2) || defined(LLVM_3_3)
llvm::DIType diSubprogramType_n = diSubprogramType;
#elif defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
Assert(diSubprogramType.isCompositeType()); Assert(diSubprogramType.isCompositeType());
llvm::DICompositeType diSubprogramType_n = llvm::DICompositeType diSubprogramType_n =
static_cast<llvm::DICompositeType>(diSubprogramType); static_cast<llvm::DICompositeType>(diSubprogramType);
#else #else // LLVM 3.7+
llvm::DIType diSubprogramType_n = diSubprogramType; Assert(llvm::isa<llvm::MDCompositeTypeBase>(diSubprogramType));
llvm::DICompositeType diSubprogramType_n =
llvm::cast<llvm::MDCompositeTypeBase>(diSubprogramType);
#endif #endif
std::string mangledName = llvmFunction->getName(); std::string mangledName = llvmFunction->getName();
@@ -381,7 +398,11 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym,
firstLine, firstLine,
flags, flags,
isOptimized, llvmFunction); 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()); AssertPos(currentPos, diSubprogram.Verify());
#else // LLVM 3.7+
//comming soon
#endif
/* And start a scope representing the initial function scope */ /* And start a scope representing the initial function scope */
StartScope(); StartScope();
@@ -1662,7 +1683,11 @@ FunctionEmitContext::StartScope() {
// as the last argument // as the last argument
currentPos.first_column); currentPos.first_column);
#endif // LLVM 3.2, 3.3, 3.4 and 3.6+ #endif // LLVM 3.2, 3.3, 3.4 and 3.6+
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
AssertPos(currentPos, lexicalBlock.Verify()); AssertPos(currentPos, lexicalBlock.Verify());
#else // LLVM 3.7+
//comming soon
#endif
debugScopes.push_back(lexicalBlock); debugScopes.push_back(lexicalBlock);
} }
} }
@@ -1691,7 +1716,11 @@ FunctionEmitContext::EmitVariableDebugInfo(Symbol *sym) {
llvm::DIScope scope = GetDIScope(); llvm::DIScope scope = GetDIScope();
llvm::DIType diType = sym->type->GetDIType(scope); 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()); AssertPos(currentPos, diType.Verify());
#else // LLVM 3.7+
//comming soon
#endif
llvm::DIVariable var = llvm::DIVariable var =
m->diBuilder->createLocalVariable(llvm::dwarf::DW_TAG_auto_variable, m->diBuilder->createLocalVariable(llvm::dwarf::DW_TAG_auto_variable,
scope, scope,
@@ -1700,7 +1729,11 @@ FunctionEmitContext::EmitVariableDebugInfo(Symbol *sym) {
sym->pos.first_line, sym->pos.first_line,
diType, diType,
true /* preserve through opts */); 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()); 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+ #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::DIExpression E = m->diBuilder->createExpression();
llvm::Instruction *declareInst = llvm::Instruction *declareInst =
@@ -1720,7 +1753,11 @@ FunctionEmitContext::EmitFunctionParameterDebugInfo(Symbol *sym, int argNum) {
llvm::DIScope scope = diSubprogram; llvm::DIScope scope = diSubprogram;
llvm::DIType diType = sym->type->GetDIType(scope); 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()); AssertPos(currentPos, diType.Verify());
#else // LLVM 3.7+
//comming soon
#endif
int flags = 0; int flags = 0;
llvm::DIVariable var = llvm::DIVariable var =
@@ -1733,7 +1770,11 @@ FunctionEmitContext::EmitFunctionParameterDebugInfo(Symbol *sym, int argNum) {
true /* preserve through opts */, true /* preserve through opts */,
flags, 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()); 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+ #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::DIExpression E = m->diBuilder->createExpression();
llvm::Instruction *declareInst = llvm::Instruction *declareInst =

View File

@@ -1352,7 +1352,11 @@ SourcePos::GetDIFile() const {
std::string directory, filename; std::string directory, filename;
GetDirectoryAndFileName(g->currentDirectory, name, &directory, &filename); GetDirectoryAndFileName(g->currentDirectory, name, &directory, &filename);
llvm::DIFile ret = m->diBuilder->createFile(filename, directory); 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)
Assert(ret.Verify()); Assert(ret.Verify());
#else // LLVM 3.7+
//comming soon
#endif
return ret; return ret;
} }

View File

@@ -189,22 +189,39 @@ lStripUnusedDebugInfo(llvm::Module *module) {
// get the instruction`s debugging metadata // get the instruction`s debugging metadata
llvm::MDNode *node = inst->getMetadata(llvm::LLVMContext::MD_dbg); llvm::MDNode *node = inst->getMetadata(llvm::LLVMContext::MD_dbg);
while (node) { while (node) {
#if defined (LLVM_3_2) || defined (LLVM_3_3)|| defined (LLVM_3_4)|| defined (LLVM_3_5) || (LLVM_3_6)
llvm::DILocation dloc(node); llvm::DILocation dloc(node);
#else // LLVM 3.7+
llvm::DILocation dloc(llvm::cast<llvm::MDLocation>(node));
#endif
// get the scope of the current instruction`s location // get the scope of the current instruction`s location
llvm::DIScope scope = dloc.getScope(); llvm::DIScope scope = dloc.getScope();
// node becomes NULL if this was the original location // node becomes NULL if this was the original location
node = dloc.getOrigLocation(); node = dloc.getOrigLocation();
// now following a chain of nested scopes // now following a chain of nested scopes
while (!0) { while (!0) {
#if defined (LLVM_3_2) || defined (LLVM_3_3)|| defined (LLVM_3_4)|| defined (LLVM_3_5) || (LLVM_3_6)
if (scope.isLexicalBlockFile()) if (scope.isLexicalBlockFile())
scope = llvm::DILexicalBlockFile(scope).getScope(); scope = llvm::DILexicalBlockFile(scope).getScope();
else if (scope.isLexicalBlock()) else if (scope.isLexicalBlock())
scope = llvm::DILexicalBlock(scope).getContext(); scope = llvm::DILexicalBlock(scope).getContext();
else if (scope.isNameSpace()) else if (scope.isNameSpace())
scope = llvm::DINameSpace(scope).getContext(); scope = llvm::DINameSpace(scope).getContext();
#else // LLVM 3.7+
if (llvm::isa<llvm::MDLexicalBlockFile>(scope))
scope = llvm::DILexicalBlockFile(llvm::cast<llvm::MDLexicalBlockFile>(scope)).getContext();
else if (llvm::isa<llvm::MDLexicalBlockBase>(scope))
scope = llvm::DILexicalBlock(llvm::cast<llvm::MDLexicalBlockBase>(scope)).getContext();
else if (llvm::isa<llvm::MDNamespace>(scope))
scope = llvm::DINameSpace(llvm::cast<llvm::MDNamespace>(scope)).getContext();
#endif
else break; else break;
} }
#if defined (LLVM_3_2) || defined (LLVM_3_3)|| defined (LLVM_3_4)|| defined (LLVM_3_5) || (LLVM_3_6)
if (scope.isSubprogram()) { if (scope.isSubprogram()) {
#else // LLVM 3.7+
if (llvm::isa<llvm::MDSubprogram>(scope)) {
#endif
// good, the chain ended with a function; adding // good, the chain ended with a function; adding
SPall.insert(scope); SPall.insert(scope);
} }
@@ -215,10 +232,18 @@ lStripUnusedDebugInfo(llvm::Module *module) {
if (llvm::NamedMDNode *cuNodes = module->getNamedMetadata("llvm.dbg.cu")) { if (llvm::NamedMDNode *cuNodes = module->getNamedMetadata("llvm.dbg.cu")) {
for (unsigned i = 0, ie = cuNodes->getNumOperands(); i != ie; ++i) { for (unsigned i = 0, ie = cuNodes->getNumOperands(); i != ie; ++i) {
llvm::MDNode *cuNode = cuNodes->getOperand(i); llvm::MDNode *cuNode = cuNodes->getOperand(i);
#if defined (LLVM_3_2) || defined (LLVM_3_3)|| defined (LLVM_3_4)|| defined (LLVM_3_5) || (LLVM_3_6)
llvm::DICompileUnit cu(cuNode); llvm::DICompileUnit cu(cuNode);
#else // LLVM 3.7+
llvm::DICompileUnit cu(llvm::cast<llvm::MDCompileUnit>(cuNode));
#endif
llvm::DIArray subprograms = cu.getSubprograms(); llvm::DIArray subprograms = cu.getSubprograms();
#if defined (LLVM_3_2) || defined (LLVM_3_3)|| defined (LLVM_3_4)|| defined (LLVM_3_5) || (LLVM_3_6)
if (subprograms.getNumElements() == 0) if (subprograms.getNumElements() == 0)
#else // LLVM 3.7+
if (subprograms.size() == 0)
#endif
continue; continue;
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) #if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5)
@@ -230,11 +255,17 @@ lStripUnusedDebugInfo(llvm::Module *module) {
#endif #endif
// determine what functions of those extracted belong to the unit // determine what functions of those extracted belong to the unit
#if defined (LLVM_3_2) || defined (LLVM_3_3)|| defined (LLVM_3_4)|| defined (LLVM_3_5) || (LLVM_3_6)
for (unsigned j = 0, je = subprograms.getNumElements(); j != je; ++j) for (unsigned j = 0, je = subprograms.getNumElements(); j != je; ++j)
#else // LLVM 3.7+
for (unsigned j = 0, je = subprograms.size(); j != je; ++j)
#endif
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) #if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5)
SPset.insert(subprograms->getOperand(j)); SPset.insert(subprograms->getOperand(j));
#else // LLVM 3.6+ #elif defined(LLVM_3_6)
SPset.insert(subprograms.getElement(j)); SPset.insert(subprograms.getElement(j));
#else // LLVM 3.7+
SPset.insert(subprograms [j]);
#endif #endif
std::set_intersection(SPall.begin(), SPall.end(), std::set_intersection(SPall.begin(), SPall.end(),
@@ -243,7 +274,11 @@ lStripUnusedDebugInfo(llvm::Module *module) {
Debug(SourcePos(), "%d / %d functions left in module with debug " Debug(SourcePos(), "%d / %d functions left in module with debug "
"info.", (int)usedSubprograms.size(), "info.", (int)usedSubprograms.size(),
#if defined (LLVM_3_2) || defined (LLVM_3_3)|| defined (LLVM_3_4)|| defined (LLVM_3_5) || (LLVM_3_6)
(int)subprograms.getNumElements()); (int)subprograms.getNumElements());
#else // LLVM 3.7+
(int)subprograms.size());
#endif
// We'd now like to replace the array of subprograms in the // We'd now like to replace the array of subprograms in the
// compile unit with only the ones that actually have function // compile unit with only the ones that actually have function
@@ -298,15 +333,25 @@ lStripUnusedDebugInfo(llvm::Module *module) {
cuNode->replaceOperandWith(9, replNode); cuNode->replaceOperandWith(9, replNode);
#else // LLVM 3.6+ #else // LLVM 3.6+
llvm::DIArray nodeSPs = cu.getSubprograms(); llvm::DIArray nodeSPs = cu.getSubprograms();
#if defined(LLVM_3_6)
Assert(nodeSPs.getNumElements() == subprograms.getNumElements()); Assert(nodeSPs.getNumElements() == subprograms.getNumElements());
for (int i = 0; i < (int)nodeSPs.getNumElements(); ++i) for (int i = 0; i < (int)nodeSPs.getNumElements(); ++i)
Assert(nodeSPs.getElement(i) == subprograms.getElement(i)); Assert(nodeSPs.getElement(i) == subprograms.getElement(i));
#else // LLVM 3.7+
Assert(nodeSPs.size() == subprograms.size());
for (int i = 0; i < (int)nodeSPs.size(); ++i)
Assert(nodeSPs [i] == subprograms [i]);
#endif
// And now we can go and stuff it into the unit with some // And now we can go and stuff it into the unit with some
// confidence... // confidence...
llvm::MDNode *replNode = llvm::MDNode::get(module->getContext(), llvm::MDNode *replNode = llvm::MDNode::get(module->getContext(),
llvm::ArrayRef<llvm::Metadata *>(usedSubprograms)); llvm::ArrayRef<llvm::Metadata *>(usedSubprograms));
#if defined(LLVM_3_6)
cu.replaceSubprograms(llvm::DIArray(replNode)); cu.replaceSubprograms(llvm::DIArray(replNode));
#else // LLVM 3.7+
cu.replaceSubprograms(llvm::DIArray(llvm::cast<llvm::MDTuple>(replNode)));
#endif
#endif #endif
} }
} }
@@ -655,7 +700,15 @@ Module::AddGlobalVariable(const std::string &name, const Type *type, Expr *initE
if (diBuilder) { if (diBuilder) {
llvm::DIFile file = pos.GetDIFile(); llvm::DIFile file = pos.GetDIFile();
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) && !defined(LLVM_3_5)// LLVM 3.6+ #if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5)
llvm::DIGlobalVariable var = diBuilder->createGlobalVariable(
name,
file,
pos.first_line,
sym->type->GetDIType(file),
(sym->storageClass == SC_STATIC),
sym->storagePtr);
#elif defined(LLVM_3_6)
llvm::Constant *sym_const_storagePtr = llvm::dyn_cast<llvm::Constant>(sym->storagePtr); llvm::Constant *sym_const_storagePtr = llvm::dyn_cast<llvm::Constant>(sym->storagePtr);
Assert(sym_const_storagePtr); Assert(sym_const_storagePtr);
llvm::DIGlobalVariable var = diBuilder->createGlobalVariable( llvm::DIGlobalVariable var = diBuilder->createGlobalVariable(
@@ -667,16 +720,24 @@ Module::AddGlobalVariable(const std::string &name, const Type *type, Expr *initE
sym->type->GetDIType(file), sym->type->GetDIType(file),
(sym->storageClass == SC_STATIC), (sym->storageClass == SC_STATIC),
sym_const_storagePtr); sym_const_storagePtr);
#else #else // LLVM 3.7+
llvm::DIGlobalVariable var = diBuilder->createGlobalVariable( llvm::Constant *sym_const_storagePtr = llvm::dyn_cast<llvm::Constant>(sym->storagePtr);
Assert(sym_const_storagePtr);
diBuilder->createGlobalVariable(
file,
name,
name, name,
file, file,
pos.first_line, pos.first_line,
sym->type->GetDIType(file), sym->type->GetDIType(file),
(sym->storageClass == SC_STATIC), (sym->storageClass == SC_STATIC),
sym->storagePtr); sym_const_storagePtr);
#endif #endif
#if defined(LLVM_3_2) || defined(LLVM_3_3) || defined(LLVM_3_4) || defined(LLVM_3_5) || defined(LLVM_3_6)
Assert(var.Verify()); Assert(var.Verify());
#else // LLVM 3.7+
//comming soon
#endif
} }
} }