some fixes for new LLVM API

This commit is contained in:
Andrey Shishpanov
2015-07-28 18:35:58 +03:00
parent 2c4c79d55e
commit 90c6e0172a
2 changed files with 15 additions and 2 deletions

13
ctx.cpp
View File

@@ -380,11 +380,22 @@ FunctionEmitContext::FunctionEmitContext(Function *func, Symbol *funSym,
llvm::DICompositeType diSubprogramType_n =
static_cast<llvm::DICompositeType>(diSubprogramType);
int flags = llvm::DIDescriptor::FlagPrototyped;
#else /* LLVM 3.7+ */
#elif ISPC_LLVM_VERSION == ISPC_LLVM_3_7 /* LLVM 3.7 */
Assert(llvm::isa<llvm::DICompositeTypeBase>(diSubprogramType));
llvm::DISubroutineType *diSubprogramType_n =
llvm::cast<llvm::DISubroutineType>(getDICompositeType(diSubprogramType));
int flags = llvm::DINode::FlagPrototyped;
#else /* LLVM 3.8+ */
Assert(llvm::isa<llvm::DICompositeType>(diSubprogramType));
llvm::DICompositeType *C = llvm::dyn_cast_or_null<llvm::DICompositeType>(diSubprogramType);
if (!C){
llvm::DITypeIdentifierMap EmptyMap;
C = llvm::dyn_cast_or_null<llvm::DICompositeType>(llvm::dyn_cast_or_null<llvm::DIDerivedType>(diSubprogramType)->getBaseType().resolve(EmptyMap));
} //restored function getDICompositeType() from 3.7 which absents in 3.8
llvm::DISubroutineType *diSubprogramType_n =
llvm::cast<llvm::DISubroutineType>(C);
int flags = llvm::DINode::FlagPrototyped;
#endif
std::string mangledName = llvmFunction->getName();

View File

@@ -1044,7 +1044,9 @@ Target::Target(const char *arch, const char *cpu, const char *isa, bool pic, boo
std::string dl_string;
#if ISPC_LLVM_VERSION == ISPC_LLVM_3_6
dl_string = m_targetMachine->getSubtargetImpl()->getDataLayout()->getStringRepresentation();
#else // LLVM 3.5- or LLVM 3.7+
#elif ISPC_LLVM_VERSION >= ISPC_LLVM_3_8 // LLVM 3.8+
dl_string = m_targetMachine->createDataLayout().getStringRepresentation();
#else // LLVM 3.5- or LLVM 3.7
dl_string = m_targetMachine->getDataLayout()->getStringRepresentation();
#endif
// 2. Adjust for generic