Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Use default inliner but keep inlining to a minimum.
We cannot turn on inlining completely due to a clang /GCC ABI mismatch that
is visible with -O2, see https://bugs.llvm.org//show_bug.cgi?id=19668.
  • Loading branch information
Axel-Naumann committed Mar 27, 2017
commit 7a7c9b17f0ca8f94fd08eb09f0ac3e1b8b0e6f36
61 changes: 9 additions & 52 deletions interpreter/cling/lib/Interpreter/BackendPasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,49 +30,6 @@ using namespace clang;
using namespace llvm;
using namespace llvm::legacy;

namespace {

class InlinerKeepDeadFunc: public Inliner {
Inliner* m_Inliner; // the actual inliner
static char ID; // Pass identification, replacement for typeid
public:
InlinerKeepDeadFunc():
Inliner(ID), m_Inliner(0) { }
InlinerKeepDeadFunc(Pass* I):
Inliner(ID), m_Inliner((Inliner*)I) { }

using llvm::Pass::doInitialization;
bool doInitialization(CallGraph &CG) override {
// Forward out Resolver now that we are registered.
if (!m_Inliner->getResolver())
m_Inliner->setResolver(getResolver());
return m_Inliner->doInitialization(CG); // no Module modification
}

InlineCost getInlineCost(CallSite CS) override {
return m_Inliner->getInlineCost(CS);
}
void getAnalysisUsage(AnalysisUsage &AU) const override {
m_Inliner->getAnalysisUsage(AU);
}
bool runOnSCC(CallGraphSCC &SCC) override {
return m_Inliner->runOnSCC(SCC);
}

using llvm::Pass::doFinalization;
// No-op: we need to keep the inlined functions for later use.
bool doFinalization(CallGraph& /*CG*/) override {
// Module is unchanged
return false;
}
};
} // end anonymous namespace

// Pass registration. Luckily all known inliners depend on the same set
// of passes.
char InlinerKeepDeadFunc::ID = 0;


BackendPasses::~BackendPasses() {
//delete m_PMBuilder->Inliner;
}
Expand All @@ -96,12 +53,15 @@ void BackendPasses::CreatePasses(llvm::Module& M)
CGOpts_.VectorizeLoop = 1;
CGOpts_.VectorizeSLP = 1;
#endif

// Better inlining is pending https://bugs.llvm.org//show_bug.cgi?id=19668
// and its consequence https://sft.its.cern.ch/jira/browse/ROOT-7111
// shown e.g. by roottest/cling/stl/map/badstringMap
CGOpts_.setInlining(CodeGenOptions::NormalInlining);

unsigned OptLevel = m_CGOpts.OptimizationLevel;

// CodeGenOptions::InliningMethod Inlining = m_CGOpts.getInlining();
CodeGenOptions::InliningMethod Inlining = CodeGenOptions::NormalInlining;
CodeGenOptions::InliningMethod Inlining = m_CGOpts.getInlining();

// Handle disabling of LLVM optimization, where we want to preserve the
// internal module before any optimization.
Expand Down Expand Up @@ -137,20 +97,17 @@ void BackendPasses::CreatePasses(llvm::Module& M)
break;
}
case CodeGenOptions::NormalInlining: {
PMBuilder.Inliner =
new InlinerKeepDeadFunc(createFunctionInliningPass(OptLevel,
m_CGOpts.OptimizeSize));
PMBuilder.Inliner = createFunctionInliningPass(OptLevel,
m_CGOpts.OptimizeSize);
break;
}
case CodeGenOptions::OnlyAlwaysInlining:
// Respect always_inline.
if (OptLevel == 0)
// Do not insert lifetime intrinsics at -O0.
PMBuilder.Inliner
= new InlinerKeepDeadFunc(createAlwaysInlinerPass(false));
PMBuilder.Inliner = createAlwaysInlinerPass(false);
else
PMBuilder.Inliner
= new InlinerKeepDeadFunc(createAlwaysInlinerPass());
PMBuilder.Inliner = createAlwaysInlinerPass();
break;
}

Expand Down