diff --git a/dmd2/func.c b/dmd2/func.c index 138feed511..55b30f847e 100644 --- a/dmd2/func.c +++ b/dmd2/func.c @@ -1948,7 +1948,13 @@ void FuncDeclaration::toCBuffer(OutBuffer *buf, HdrGenState *hgs) bodyToCBuffer(buf, hgs); hgs->autoMember--; } - else if(hgs->tpltMember == 0 && global.params.useInline == 0) + else if(hgs->tpltMember == 0 && +#if IN_LLVM + !global.params.hdrKeepAllBodies +#else + global.params.useInline == 0 +#endif + ) buf->writestring(";"); else bodyToCBuffer(buf, hgs); @@ -2022,7 +2028,13 @@ int FuncDeclaration::equals(Object *o) void FuncDeclaration::bodyToCBuffer(OutBuffer *buf, HdrGenState *hgs) { - if (fbody && (!hgs->hdrgen || global.params.useInline || hgs->autoMember || hgs->tpltMember)) + if (fbody && (!hgs->hdrgen || +#if IN_LLVM + global.params.hdrKeepAllBodies || +#else + global.params.useInline || +#endif + hgs->autoMember || hgs->tpltMember)) { int savetlpt = hgs->tpltMember; int saveauto = hgs->autoMember; diff --git a/dmd2/mars.h b/dmd2/mars.h index 59e1f7f61b..5645093a61 100644 --- a/dmd2/mars.h +++ b/dmd2/mars.h @@ -282,6 +282,11 @@ struct Param char *exefile; char *mapfile; #if IN_LLVM + // Whether to keep all function bodies in .di file generation or to strip + // those of plain functions. For DMD, this is govenered by the -inline + // flag, which does not directly translate to LDC. + bool hdrKeepAllBodies; + // LDC stuff OUTPUTFLAG output_ll; OUTPUTFLAG output_bc; diff --git a/driver/cl_options.cpp b/driver/cl_options.cpp index 76878d0223..c88a26337f 100644 --- a/driver/cl_options.cpp +++ b/driver/cl_options.cpp @@ -187,6 +187,10 @@ cl::opt hdrFile("Hf", cl::value_desc("filename"), cl::Prefix); +static cl::opt hdrKeepAllBodies("Hkeep-all-bodies", + cl::desc("Keep all function bodies in .di files"), + cl::ZeroOrMore, + cl::location(global.params.hdrKeepAllBodies)); static cl::opt unittest("unittest", cl::desc("Compile in unit tests"), diff --git a/driver/ldmd.cpp b/driver/ldmd.cpp index 6bc03ae60c..b9dba8a2a4 100644 --- a/driver/ldmd.cpp +++ b/driver/ldmd.cpp @@ -822,7 +822,11 @@ void buildCommandLine(std::vector& r, const Params& p) if (p.jsonName) r.push_back(concat("-Xf=", p.jsonName)); if (p.ignoreUnsupportedPragmas) r.push_back("-ignore"); if (p.enforcePropertySyntax) r.push_back("-property"); - if (p.enableInline) r.push_back("-enable-inlining"); + if (p.enableInline) { + // -inline also influences .di generation with DMD. + r.push_back("-enable-inlining"); + r.push_back("-Hkeep-all-bodies"); + } if (p.emitStaticLib) r.push_back("-lib"); if (p.noFloat) warning("-nofloat is ignored by LDC."); if (p.quiet) r.push_back("-quiet"); // Undocumented.