Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 4 additions & 4 deletions llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl07.rst
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ the function:
/// CreateEntryBlockAlloca - Create an alloca instruction in the entry block of
/// the function. This is used for mutable variables etc.
static AllocaInst *CreateEntryBlockAlloca(Function *TheFunction,
const std::string &VarName) {
StringRef VarName) {
IRBuilder<> TmpB(&TheFunction->getEntryBlock(),
TheFunction->getEntryBlock().begin());
return TmpB.CreateAlloca(Type::getDoubleTy(*TheContext), nullptr,
Expand Down Expand Up @@ -440,11 +440,11 @@ get good codegen once again:
.. code-block:: c++

// Promote allocas to registers.
TheFPM->add(createPromoteMemoryToRegisterPass());
TheFPM->addPass(PromotePass());
// Do simple "peephole" optimizations and bit-twiddling optzns.
TheFPM->add(createInstructionCombiningPass());
TheFPM->addPass(InstCombinePass());
// Reassociate expressions.
TheFPM->add(createReassociatePass());
TheFPM->addPass(ReassociatePass());
...

It is interesting to see what the code looks like before and after the
Expand Down
4 changes: 3 additions & 1 deletion llvm/examples/Kaleidoscope/Chapter7/toy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "llvm/Transforms/Scalar/GVN.h"
#include "llvm/Transforms/Scalar/Reassociate.h"
#include "llvm/Transforms/Scalar/SimplifyCFG.h"
#include "llvm/Transforms/Utils.h"
#include "llvm/Transforms/Utils/Mem2Reg.h"
#include <algorithm>
#include <cassert>
#include <cctype>
Expand Down Expand Up @@ -1142,6 +1142,8 @@ static void InitializeModuleAndManagers() {
TheSI->registerCallbacks(*ThePIC, TheMAM.get());

// Add transform passes.
// Promote allocas to registers.
TheFPM->addPass(PromotePass());
// Do simple "peephole" optimizations and bit-twiddling optzns.
TheFPM->addPass(InstCombinePass());
// Reassociate expressions.
Expand Down
Loading