mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-01 15:40:55 +03:00
Fixed a bug in DtoInlineIR
Before this fix, debug info was removed from the module while parsing inline ir.
This commit is contained in:
parent
019d254ea5
commit
7436d94e09
1 changed files with 18 additions and 1 deletions
|
@ -28,6 +28,7 @@
|
||||||
#include "gen/pragma.h"
|
#include "gen/pragma.h"
|
||||||
#include "gen/runtime.h"
|
#include "gen/runtime.h"
|
||||||
#include "gen/tollvm.h"
|
#include "gen/tollvm.h"
|
||||||
|
#include "llvm/Linker.h"
|
||||||
#if LDC_LLVM_VER >= 303
|
#if LDC_LLVM_VER >= 303
|
||||||
#include "llvm/IR/Intrinsics.h"
|
#include "llvm/IR/Intrinsics.h"
|
||||||
#else
|
#else
|
||||||
|
@ -353,7 +354,15 @@ LLFunction* DtoInlineIRFunction(FuncDeclaration* fdecl)
|
||||||
stream << ")\n{\n" << code << "\n}";
|
stream << ")\n{\n" << code << "\n}";
|
||||||
|
|
||||||
llvm::SMDiagnostic err;
|
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();
|
std::string errstr = err.getMessage();
|
||||||
if(errstr != "")
|
if(errstr != "")
|
||||||
error(tinst->loc,
|
error(tinst->loc,
|
||||||
|
@ -366,6 +375,14 @@ LLFunction* DtoInlineIRFunction(FuncDeclaration* fdecl)
|
||||||
(std::string(err.getColumnNo(), ' ') + '^').c_str(),
|
(std::string(err.getColumnNo(), ' ') + '^').c_str(),
|
||||||
errstr.c_str(), stream.str().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);
|
LLFunction* fun = gIR->module->getFunction(mangled_name);
|
||||||
fun->setLinkage(llvm::GlobalValue::LinkOnceODRLinkage);
|
fun->setLinkage(llvm::GlobalValue::LinkOnceODRLinkage);
|
||||||
fun->addFnAttr(llvm::Attribute::AlwaysInline);
|
fun->addFnAttr(llvm::Attribute::AlwaysInline);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue