From b8437bc67c6004eb522f30b9baa939a0fa328ab5 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Tue, 24 Mar 2020 07:09:29 -0700 Subject: [PATCH] Critical fix- function inlining was broken --- IDEHelper/Compiler/BfIRCodeGen.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/IDEHelper/Compiler/BfIRCodeGen.cpp b/IDEHelper/Compiler/BfIRCodeGen.cpp index db67df8e..98a56b90 100644 --- a/IDEHelper/Compiler/BfIRCodeGen.cpp +++ b/IDEHelper/Compiler/BfIRCodeGen.cpp @@ -106,6 +106,8 @@ #include "llvm/Bitcode/BitcodeReader.h" #include "llvm/Bitcode/BitcodeWriterPass.h" #include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h" +#include "llvm/Transforms/IPO/AlwaysInliner.h" +#include "llvm/Transforms/IPO.h" #include "../LLVMUtils.h" @@ -3580,12 +3582,17 @@ static void PopulateModulePassManager(llvm::legacy::PassManagerBase &MPM, const // MPM.add(createPruneEHPass()); // MPM.add(createSampleProfileLoaderPass(PGOSampleUse)); // } - llvm::Pass* Inliner = NULL; + llvm::Pass* Inliner; bool prepareForLTO = false; bool prepareForThinLTO = options.mLTOType == BfLTOType_Thin; bool performThinLTO = false; bool enableNonLTOGlobalsModRef = false; + if (GetOptLevel(options.mOptLevel) > 0) + Inliner = llvm::createFunctionInliningPass(GetOptLevel(options.mOptLevel), options.mSizeLevel, false); + else + Inliner = llvm::createAlwaysInlinerLegacyPass(); + // Allow forcing function attributes as a debugging and tuning aid. MPM.add(llvm::createForceFunctionAttrsLegacyPass());