Register LLVM passes with the new API.

main
theraven 15 years ago
parent b68a5dda6d
commit ee3961f38e

@ -1,9 +1,14 @@
#include "llvm/Pass.h"
#include "llvm/Module.h"
#if LLVM_MAJOR >= 3
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
#include "llvm/PassManager.h"
#endif
#include "ObjectiveCOpts.h"
using namespace llvm;
namespace
{
class ObjectiveCOpts : public ModulePass {
@ -52,4 +57,36 @@ namespace
RegisterPass<ObjectiveCOpts> X("gnu-objc",
"Run all of the GNUstep Objective-C runtimm optimisations");
#if LLVM_MAJOR >= 3
void addObjCPasses(const PassManagerBuilder &Builder, PassManagerBase &PM) {
// Always add the ivar simplification pass
PM.add(createGNUNonfragileIvarPass());
// Only cache IMPs in loops if we're not optimising for size.
if (Builder.SizeLevel == 0) {
PM.add(createGNULoopIMPCachePass());
}
// Do the rest of the caching if we're not aggressively optimising for size
if (Builder.SizeLevel < 2) {
PM.add(createClassIMPCachePass());
PM.add(createClassLookupCachePass());
}
// Definitely don't do extra inlining if we're optimising for size!
if (Builder.SizeLevel == 0) {
PM.add(createClassMethodInliner());
}
}
/*
static struct PluginRegister {
PluginRegister() {
PassManagerBuilder::addGlobalExtension(PassManagerBuilder::EP_LoopOptimizerEnd,
addObjCPasses);
}
} Register;
*/
RegisterStandardPasses S(PassManagerBuilder::EP_LoopOptimizerEnd,
addObjCPasses);
#endif
}

Loading…
Cancel
Save