Merge branch 'master' into merge-2.067

This commit is contained in:
Kai Nacke 2015-04-16 07:27:09 +02:00
commit 7159aa5392
4 changed files with 38 additions and 12 deletions

View file

@ -110,8 +110,16 @@ static void codegenModule(llvm::TargetMachine &Target, llvm::Module& m,
Target.addAnalysisPasses(Passes);
#endif
#if LDC_LLVM_VER < 307
llvm::formatted_raw_ostream fout(out);
if (Target.addPassesToEmitFile(Passes, fout, fileType, codeGenOptLevel()))
#endif
if (Target.addPassesToEmitFile(Passes,
#if LDC_LLVM_VER >= 307
out,
#else
fout,
#endif
fileType, codeGenOptLevel()))
llvm_unreachable("no support for asm output");
Passes.run(m);
@ -178,19 +186,21 @@ namespace
static MDNode* FindSubprogram(const Function *F, DebugInfoFinder &Finder)
#endif
{
#if LDC_LLVM_VER >= 305
for (DISubprogram Subprogram : Finder.subprograms()) {
#if LDC_LLVM_VER >= 307
for (DISubprogram Subprogram : Finder.subprograms())
if (Subprogram->describes(F)) return Subprogram;
return nullptr;
#elif LDC_LLVM_VER >= 305
for (DISubprogram Subprogram : Finder.subprograms())
if (Subprogram.describes(F)) return Subprogram;
return nullptr;
#else
for (DebugInfoFinder::iterator I = Finder.subprogram_begin(),
E = Finder.subprogram_end();
I != E; ++I) {
DISubprogram Subprogram(*I);
#endif
if (Subprogram.describes(F)) return Subprogram;
}
#if LDC_LLVM_VER >= 305
return nullptr;
#else
return 0;
#endif
}
@ -209,8 +219,12 @@ namespace
if (MDNode* N = FindSubprogram(F, Finder))
#endif
{
#if LDC_LLVM_VER >= 307
return N->getDisplayName();
#else
llvm::DISubprogram sub(N);
return sub.getDisplayName();
#endif
}
return "";
}
@ -267,7 +281,11 @@ namespace
os.PadToColumn(50);
os << ";";
}
#if LDC_LLVM_VER >= 307
os << " [debug variable = " << Var->getName() << ']';
#else
os << " [debug variable = " << Var.getName() << ']';
#endif
}
else if (const DbgValueInst* DVI = dyn_cast<DbgValueInst>(instr))
{
@ -277,7 +295,11 @@ namespace
os.PadToColumn(50);
os << ";";
}
#if LDC_LLVM_VER >= 307
os << " [debug variable = " << Var->getName() << ']';
#else
os << " [debug variable = " << Var.getName() << ']';
#endif
}
else if (const CallInst* callinstr = dyn_cast<CallInst>(instr))
{

View file

@ -1532,10 +1532,14 @@ size_t realignOffset(size_t offset, Type* type)
//////////////////////////////////////////////////////////////////////////////////////////
Type * stripModifiers( Type * type )
Type * stripModifiers(Type * type, bool transitive)
{
if (type->ty == Tfunction)
return type;
if (transitive)
return type->unqualify(MODimmutable | MODconst | MODwild);
else
return type->castMod(0);
}

View file

@ -199,7 +199,7 @@ LLFunctionType* DtoExtractFunctionType(LLType* type);
///
DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions* arguments, LLValue* retvar = 0);
Type* stripModifiers(Type* type);
Type* stripModifiers(Type* type, bool transitive = false);
void printLabelName(std::ostream& target, const char* func_mangle, const char* label_name);

View file

@ -494,8 +494,8 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
// repaint the type if necessary
if (resulttype)
{
Type* rbase = stripModifiers(resulttype->toBasetype());
Type* nextbase = stripModifiers(tf->nextOf()->toBasetype());
Type* rbase = stripModifiers(resulttype->toBasetype(), true);
Type* nextbase = stripModifiers(tf->nextOf()->toBasetype(), true);
if (!rbase->equals(nextbase))
{
IF_LOG Logger::println("repainting return value from '%s' to '%s'", tf->nextOf()->toChars(), rbase->toChars());