Merge pull request #569 from jerro/bugfix

Bugfix
This commit is contained in:
David Nadlinger
2014-01-05 19:31:20 -08:00
2 changed files with 30 additions and 1 deletions

View File

@@ -28,6 +28,7 @@
#include "gen/pragma.h"
#include "gen/runtime.h"
#include "gen/tollvm.h"
#include "llvm/Linker.h"
#if LDC_LLVM_VER >= 303
#include "llvm/IR/Intrinsics.h"
#else
@@ -353,7 +354,15 @@ LLFunction* DtoInlineIRFunction(FuncDeclaration* fdecl)
stream << ")\n{\n" << code << "\n}";
llvm::SMDiagnostic err;
llvm::ParseAssemblyString(stream.str().c_str(), gIR->module, err, gIR->context());
#if LDC_LLVM_VER >= 303
llvm::Module* m = llvm::ParseAssemblyString(
stream.str().c_str(), NULL, err, gIR->context());
#else
llvm::ParseAssemblyString(
stream.str().c_str(), gIR->module, err, gIR->context());
#endif
std::string errstr = err.getMessage();
if(errstr != "")
error(tinst->loc,
@@ -366,6 +375,14 @@ LLFunction* DtoInlineIRFunction(FuncDeclaration* fdecl)
(std::string(err.getColumnNo(), ' ') + '^').c_str(),
errstr.c_str(), stream.str().c_str());
#if LDC_LLVM_VER >= 303
std::string errstr2 = "";
llvm::Linker(gIR->module).linkInModule(m, &errstr2);
if(errstr2 != "")
error(tinst->loc,
"Error when linking in llvm inline ir: %s", errstr2.c_str());
#endif
LLFunction* fun = gIR->module->getFunction(mangled_name);
fun->setLinkage(llvm::GlobalValue::LinkOnceODRLinkage);
fun->addFnAttr(llvm::Attribute::AlwaysInline);

View File

@@ -55,6 +55,18 @@ string dtype(Record* rec)
type = type.substr(i);
}
if(vec.size() > 0 && type.size() > 0)
{
int typeSize, vecElements;
if(
sscanf(vec.c_str(), "%d", &vecElements) == 1 &&
sscanf(type.c_str() + 1, "%d", &typeSize) == 1 &&
typeSize * vecElements > 256)
{
return "";
}
}
if(type == "i8")
return "byte" + vec;
else if(type == "i16")