diff --git a/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl07.rst b/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl07.rst index 8fd4c39d3ff47..ed1dea2324918 100644 --- a/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl07.rst +++ b/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl07.rst @@ -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, @@ -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 diff --git a/llvm/examples/Kaleidoscope/Chapter7/toy.cpp b/llvm/examples/Kaleidoscope/Chapter7/toy.cpp index 68208c4f3394a..374f2c03b48e0 100644 --- a/llvm/examples/Kaleidoscope/Chapter7/toy.cpp +++ b/llvm/examples/Kaleidoscope/Chapter7/toy.cpp @@ -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 #include #include @@ -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.