[llvm-commits] [www] r154820 - in /www/trunk/devmtg/2012-04-12/Slides: ./ Eli_Bendersky.pdf Hal_Finkel.pdf Igor_Bohm.pdf Lee_Smith.pdf Lightning talks/ Manuel_Klimek.pdf Mark_Charlebois.pptx Michael_Spencer.pptx Pablo_Barrio.pptx Ralf_Karrenberg.pdf Reed_Kotler.ppt Richard_Barton.ppt Wayne_Palmer.ppt Workshops/ Workshops/Anton_Korobeynikov.pdf Workshops/David_Chisnall.pdf Workshops/examples.tbz2 Workshops/memo.cc
James Molloy
james.molloy at arm.com
Mon Apr 16 09:23:00 PDT 2012
Author: jamesm
Date: Mon Apr 16 11:23:00 2012
New Revision: 154820
URL: http://llvm.org/viewvc/llvm-project?rev=154820&view=rev
Log:
Add slide decks for Euro-LLVM devmtg site.
Added:
www/trunk/devmtg/2012-04-12/Slides/
www/trunk/devmtg/2012-04-12/Slides/Eli_Bendersky.pdf
www/trunk/devmtg/2012-04-12/Slides/Hal_Finkel.pdf (with props)
www/trunk/devmtg/2012-04-12/Slides/Igor_Bohm.pdf
www/trunk/devmtg/2012-04-12/Slides/Lee_Smith.pdf (with props)
www/trunk/devmtg/2012-04-12/Slides/Lightning talks/
www/trunk/devmtg/2012-04-12/Slides/Manuel_Klimek.pdf (with props)
www/trunk/devmtg/2012-04-12/Slides/Mark_Charlebois.pptx (with props)
www/trunk/devmtg/2012-04-12/Slides/Michael_Spencer.pptx (with props)
www/trunk/devmtg/2012-04-12/Slides/Pablo_Barrio.pptx (with props)
www/trunk/devmtg/2012-04-12/Slides/Ralf_Karrenberg.pdf (with props)
www/trunk/devmtg/2012-04-12/Slides/Reed_Kotler.ppt (with props)
www/trunk/devmtg/2012-04-12/Slides/Richard_Barton.ppt (with props)
www/trunk/devmtg/2012-04-12/Slides/Wayne_Palmer.ppt (with props)
www/trunk/devmtg/2012-04-12/Slides/Workshops/
www/trunk/devmtg/2012-04-12/Slides/Workshops/Anton_Korobeynikov.pdf (with props)
www/trunk/devmtg/2012-04-12/Slides/Workshops/David_Chisnall.pdf (with props)
www/trunk/devmtg/2012-04-12/Slides/Workshops/examples.tbz2 (with props)
www/trunk/devmtg/2012-04-12/Slides/Workshops/memo.cc (with props)
Added: www/trunk/devmtg/2012-04-12/Slides/Eli_Bendersky.pdf
URL: http://llvm.org/viewvc/llvm-project/www/trunk/devmtg/2012-04-12/Slides/Eli_Bendersky.pdf?rev=154820&view=auto
==============================================================================
Binary files www/trunk/devmtg/2012-04-12/Slides/Eli_Bendersky.pdf (added) and www/trunk/devmtg/2012-04-12/Slides/Eli_Bendersky.pdf Mon Apr 16 11:23:00 2012 differ
Added: www/trunk/devmtg/2012-04-12/Slides/Hal_Finkel.pdf
URL: http://llvm.org/viewvc/llvm-project/www/trunk/devmtg/2012-04-12/Slides/Hal_Finkel.pdf?rev=154820&view=auto
==============================================================================
Binary file - no diff available.
Propchange: www/trunk/devmtg/2012-04-12/Slides/Hal_Finkel.pdf
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: www/trunk/devmtg/2012-04-12/Slides/Igor_Bohm.pdf
URL: http://llvm.org/viewvc/llvm-project/www/trunk/devmtg/2012-04-12/Slides/Igor_Bohm.pdf?rev=154820&view=auto
==============================================================================
Binary files www/trunk/devmtg/2012-04-12/Slides/Igor_Bohm.pdf (added) and www/trunk/devmtg/2012-04-12/Slides/Igor_Bohm.pdf Mon Apr 16 11:23:00 2012 differ
Added: www/trunk/devmtg/2012-04-12/Slides/Lee_Smith.pdf
URL: http://llvm.org/viewvc/llvm-project/www/trunk/devmtg/2012-04-12/Slides/Lee_Smith.pdf?rev=154820&view=auto
==============================================================================
Binary file - no diff available.
Propchange: www/trunk/devmtg/2012-04-12/Slides/Lee_Smith.pdf
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: www/trunk/devmtg/2012-04-12/Slides/Manuel_Klimek.pdf
URL: http://llvm.org/viewvc/llvm-project/www/trunk/devmtg/2012-04-12/Slides/Manuel_Klimek.pdf?rev=154820&view=auto
==============================================================================
Binary file - no diff available.
Propchange: www/trunk/devmtg/2012-04-12/Slides/Manuel_Klimek.pdf
------------------------------------------------------------------------------
svn:executable = *
Propchange: www/trunk/devmtg/2012-04-12/Slides/Manuel_Klimek.pdf
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: www/trunk/devmtg/2012-04-12/Slides/Mark_Charlebois.pptx
URL: http://llvm.org/viewvc/llvm-project/www/trunk/devmtg/2012-04-12/Slides/Mark_Charlebois.pptx?rev=154820&view=auto
==============================================================================
Binary file - no diff available.
Propchange: www/trunk/devmtg/2012-04-12/Slides/Mark_Charlebois.pptx
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: www/trunk/devmtg/2012-04-12/Slides/Michael_Spencer.pptx
URL: http://llvm.org/viewvc/llvm-project/www/trunk/devmtg/2012-04-12/Slides/Michael_Spencer.pptx?rev=154820&view=auto
==============================================================================
Binary file - no diff available.
Propchange: www/trunk/devmtg/2012-04-12/Slides/Michael_Spencer.pptx
------------------------------------------------------------------------------
svn:executable = *
Propchange: www/trunk/devmtg/2012-04-12/Slides/Michael_Spencer.pptx
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: www/trunk/devmtg/2012-04-12/Slides/Pablo_Barrio.pptx
URL: http://llvm.org/viewvc/llvm-project/www/trunk/devmtg/2012-04-12/Slides/Pablo_Barrio.pptx?rev=154820&view=auto
==============================================================================
Binary file - no diff available.
Propchange: www/trunk/devmtg/2012-04-12/Slides/Pablo_Barrio.pptx
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: www/trunk/devmtg/2012-04-12/Slides/Ralf_Karrenberg.pdf
URL: http://llvm.org/viewvc/llvm-project/www/trunk/devmtg/2012-04-12/Slides/Ralf_Karrenberg.pdf?rev=154820&view=auto
==============================================================================
Binary file - no diff available.
Propchange: www/trunk/devmtg/2012-04-12/Slides/Ralf_Karrenberg.pdf
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: www/trunk/devmtg/2012-04-12/Slides/Reed_Kotler.ppt
URL: http://llvm.org/viewvc/llvm-project/www/trunk/devmtg/2012-04-12/Slides/Reed_Kotler.ppt?rev=154820&view=auto
==============================================================================
Binary file - no diff available.
Propchange: www/trunk/devmtg/2012-04-12/Slides/Reed_Kotler.ppt
------------------------------------------------------------------------------
svn:executable = *
Propchange: www/trunk/devmtg/2012-04-12/Slides/Reed_Kotler.ppt
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: www/trunk/devmtg/2012-04-12/Slides/Richard_Barton.ppt
URL: http://llvm.org/viewvc/llvm-project/www/trunk/devmtg/2012-04-12/Slides/Richard_Barton.ppt?rev=154820&view=auto
==============================================================================
Binary file - no diff available.
Propchange: www/trunk/devmtg/2012-04-12/Slides/Richard_Barton.ppt
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: www/trunk/devmtg/2012-04-12/Slides/Wayne_Palmer.ppt
URL: http://llvm.org/viewvc/llvm-project/www/trunk/devmtg/2012-04-12/Slides/Wayne_Palmer.ppt?rev=154820&view=auto
==============================================================================
Binary file - no diff available.
Propchange: www/trunk/devmtg/2012-04-12/Slides/Wayne_Palmer.ppt
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: www/trunk/devmtg/2012-04-12/Slides/Workshops/Anton_Korobeynikov.pdf
URL: http://llvm.org/viewvc/llvm-project/www/trunk/devmtg/2012-04-12/Slides/Workshops/Anton_Korobeynikov.pdf?rev=154820&view=auto
==============================================================================
Binary file - no diff available.
Propchange: www/trunk/devmtg/2012-04-12/Slides/Workshops/Anton_Korobeynikov.pdf
------------------------------------------------------------------------------
svn:executable = *
Propchange: www/trunk/devmtg/2012-04-12/Slides/Workshops/Anton_Korobeynikov.pdf
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: www/trunk/devmtg/2012-04-12/Slides/Workshops/David_Chisnall.pdf
URL: http://llvm.org/viewvc/llvm-project/www/trunk/devmtg/2012-04-12/Slides/Workshops/David_Chisnall.pdf?rev=154820&view=auto
==============================================================================
Binary files www/trunk/devmtg/2012-04-12/Slides/Workshops/David_Chisnall.pdf (added) and www/trunk/devmtg/2012-04-12/Slides/Workshops/David_Chisnall.pdf Mon Apr 16 11:23:00 2012 differ
Propchange: www/trunk/devmtg/2012-04-12/Slides/Workshops/David_Chisnall.pdf
------------------------------------------------------------------------------
svn:executable = *
Added: www/trunk/devmtg/2012-04-12/Slides/Workshops/examples.tbz2
URL: http://llvm.org/viewvc/llvm-project/www/trunk/devmtg/2012-04-12/Slides/Workshops/examples.tbz2?rev=154820&view=auto
==============================================================================
Binary file - no diff available.
Propchange: www/trunk/devmtg/2012-04-12/Slides/Workshops/examples.tbz2
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: www/trunk/devmtg/2012-04-12/Slides/Workshops/memo.cc
URL: http://llvm.org/viewvc/llvm-project/www/trunk/devmtg/2012-04-12/Slides/Workshops/memo.cc?rev=154820&view=auto
==============================================================================
--- www/trunk/devmtg/2012-04-12/Slides/Workshops/memo.cc (added)
+++ www/trunk/devmtg/2012-04-12/Slides/Workshops/memo.cc Mon Apr 16 11:23:00 2012
@@ -0,0 +1,134 @@
+#include "llvm/Pass.h"
+#include "llvm/Function.h"
+#include "llvm/Module.h"
+#include "llvm/Instructions.h"
+#include "llvm/Constants.h"
+#include "llvm/GlobalVariable.h"
+#include "llvm/Support/IRBuilder.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/Analysis/LoopInfo.h"
+#include "llvm/Transforms/Utils/BasicBlockUtils.h"
+#include "llvm/DefaultPasses.h"
+#include <string>
+
+using namespace llvm;
+using std::string;
+using std::pair;
+
+namespace
+{
+ class MemoiseExample : public ModulePass {
+ /// Module that we're currently optimising
+ Module *M;
+ /// Static cache.
+ llvm::StringMap<GlobalVariable*> statics;
+ // Lookup - call plus its argument
+ typedef std::pair<CallInst*,std::string> ExampleCall;
+ bool runOnFunction(Function &F);
+ public:
+ static char ID;
+ MemoiseExample() : ModulePass(ID) {}
+ virtual bool runOnModule(Module &Mod);
+ };
+ RegisterPass<MemoiseExample> X("example-pass",
+ "Memoise example pass");
+}
+char MemoiseExample::ID;
+
+static void removeTerminator(BasicBlock *BB) {
+ TerminatorInst *BBTerm = BB->getTerminator();
+ // Remove the BB as a predecessor from all of successors
+ for (unsigned i = 0, e = BBTerm->getNumSuccessors(); i != e; ++i) {
+ BBTerm->getSuccessor(i)->removePredecessor(BB);
+ }
+ BBTerm->replaceAllUsesWith(UndefValue::get(BBTerm->getType()));
+ // Remove the terminator instruction itself.
+ BBTerm->eraseFromParent();
+}
+
+bool MemoiseExample::runOnFunction(Function &F) {
+ bool modified = false;
+ SmallVector<ExampleCall, 16> Lookups;
+
+ for (auto &i : F) {
+ for (auto &b : i) {
+ if (CallInst *c = dyn_cast<CallInst>(&b)) {
+ if (Function *func = c->getCalledFunction()) {
+ if (func->getName() == "example") {
+ ExampleCall lookup;
+ GlobalVariable *arg= dyn_cast<GlobalVariable>(
+ c->getOperand(0)->stripPointerCasts());
+ if (0 == arg) { continue; }
+ ConstantDataArray *init = dyn_cast<ConstantDataArray>(
+ arg->getInitializer());
+ if (0 == init || !init->isCString()) { continue; }
+ lookup.first = c;
+ lookup.second = init->getAsString();
+ modified = true;
+ Lookups.push_back(lookup);
+ }
+ }
+ }
+ }
+ }
+ for (SmallVectorImpl<ExampleCall>::iterator i=Lookups.begin(),
+ e=Lookups.end() ; e!=i ; i++) {
+ llvm::Instruction *lookup = i->first;
+ std::string &arg= i->second;
+ Type *retTy = lookup->getType();
+ GlobalVariable *cache = statics[arg];
+ if (!cache) {
+ cache = new GlobalVariable(*M, retTy, false,
+ GlobalVariable::PrivateLinkage, Constant::getNullValue(retTy),
+ "._cache");
+ statics[arg] = cache;
+ }
+ BasicBlock *beforeLookupBB = lookup->getParent();
+ BasicBlock *lookupBB = SplitBlock(beforeLookupBB, lookup, this);
+ BasicBlock::iterator iter = lookup;
+ iter++;
+ BasicBlock *afterLookupBB = SplitBlock(iter->getParent(), iter, this);
+ // SplitBlock() adds an unconditional branch, which we don't want.
+ // Remove it.
+ removeTerminator(beforeLookupBB);
+ removeTerminator(lookupBB);
+
+ PHINode *phi = PHINode::Create(retTy, 2, arg, afterLookupBB->begin());
+ // We replace all of the existing uses with the PHI node now, because
+ // we're going to add some more uses later that we don't want
+ // replaced.
+ lookup->replaceAllUsesWith(phi);
+
+ // In the original basic block, we test whether the cache is NULL,
+ // and skip the lookup if it isn't.
+ IRBuilder<> B(beforeLookupBB);
+ llvm::Value *cachedClass =
+ B.CreateBitCast(B.CreateLoad(cache), retTy);
+ llvm::Value *needsLookup = B.CreateIsNull(cachedClass);
+ B.CreateCondBr(needsLookup, lookupBB, afterLookupBB);
+ // In the lookup basic block, we just do the lookup, store it in the
+ // cache, and then jump to the continue block
+ B.SetInsertPoint(lookupBB);
+ B.CreateStore(lookup, cache);
+ B.CreateBr(afterLookupBB);
+ // Now we just need to set the PHI node to use the cache or the
+ // lookup result
+ phi->addIncoming(cachedClass, beforeLookupBB);
+ phi->addIncoming(lookup, lookupBB);
+ }
+ return modified;
+}
+bool MemoiseExample::runOnModule(Module &Mod) {
+ statics.empty();
+ M = &Mod;
+ bool modified = false;
+
+ for (auto &F : Mod) {
+
+ if (F.isDeclaration()) { continue; }
+
+ modified |= runOnFunction(F);
+ }
+
+ return modified;
+};
Propchange: www/trunk/devmtg/2012-04-12/Slides/Workshops/memo.cc
------------------------------------------------------------------------------
svn:executable = *
More information about the llvm-commits
mailing list