//
// The LLVM Compiler Infrastructure
//
-// This file was developed by the LLVM research group and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/IPO/InlinerPass.h"
#include "llvm/Transforms/Utils/InlineCost.h"
-#include <set>
+#include "llvm/ADT/SmallPtrSet.h"
using namespace llvm;
namespace {
class VISIBILITY_HIDDEN SimpleInliner : public Inliner {
- std::set<const Function*> NeverInline; // Functions that are never inlined
+ // Functions that are never inlined
+ SmallPtrSet<const Function*, 16> NeverInline;
InlineCostAnalyzer CA;
public:
SimpleInliner() : Inliner(&ID) {}
+ SimpleInliner(int Threshold) : Inliner(&ID, Threshold) {}
static char ID; // Pass identification, replacement for typeid
int getInlineCost(CallSite CS) {
return CA.getInlineCost(CS, NeverInline);
Pass *llvm::createFunctionInliningPass() { return new SimpleInliner(); }
+Pass *llvm::createFunctionInliningPass(int Threshold) {
+ return new SimpleInliner(Threshold);
+}
+
// doInitialization - Initializes the vector of functions that have been
// annotated with the noinline attribute.
bool SimpleInliner::doInitialization(CallGraph &CG) {
if (GV == 0)
return false;
+ // Don't crash on invalid code
+ if (!GV->hasInitializer())
+ return false;
+
const ConstantArray *InitList = dyn_cast<ConstantArray>(GV->getInitializer());
if (InitList == 0)