From 7436d94e09700fc3ead5fc3b1912d172c299dfaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jernej=20Krempu=C5=A1?= Date: Sun, 5 Jan 2014 18:03:07 +0100 Subject: [PATCH 1/2] Fixed a bug in DtoInlineIR Before this fix, debug info was removed from the module while parsing inline ir. --- gen/functions.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/gen/functions.cpp b/gen/functions.cpp index 40eadd72..bc536812 100644 --- a/gen/functions.cpp +++ b/gen/functions.cpp @@ -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); From 77c0192c06df7747928c4d8ca6e45964b9c9ba9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jernej=20Krempu=C5=A1?= Date: Sun, 5 Jan 2014 18:39:03 +0100 Subject: [PATCH 2/2] Added a check for vector size to gen_gccbuiltins.cpp. Previously, gen_gccbuiltins was emitting intrinsics that used vector types larger than 256 bits and those are not defined in core.simd. --- utils/gen_gccbuiltins.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/utils/gen_gccbuiltins.cpp b/utils/gen_gccbuiltins.cpp index cd59a2a9..7efcffa7 100644 --- a/utils/gen_gccbuiltins.cpp +++ b/utils/gen_gccbuiltins.cpp @@ -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")