File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed
docs/tutorial/MyFirstLanguageFrontend
examples/Kaleidoscope/Chapter7 Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -336,7 +336,7 @@ the function:
336336 /// CreateEntryBlockAlloca - Create an alloca instruction in the entry block of
337337 /// the function. This is used for mutable variables etc.
338338 static AllocaInst *CreateEntryBlockAlloca(Function *TheFunction,
339- const std::string & VarName) {
339+ StringRef VarName) {
340340 IRBuilder<> TmpB(&TheFunction->getEntryBlock(),
341341 TheFunction->getEntryBlock().begin());
342342 return TmpB.CreateAlloca(Type::getDoubleTy(*TheContext), nullptr,
@@ -440,11 +440,11 @@ get good codegen once again:
440440.. code-block :: c++
441441
442442 // Promote allocas to registers.
443- TheFPM->add(createPromoteMemoryToRegisterPass ());
443+ TheFPM->addPass(PromotePass ());
444444 // Do simple "peephole" optimizations and bit-twiddling optzns.
445- TheFPM->add(createInstructionCombiningPass ());
445+ TheFPM->addPass(InstCombinePass ());
446446 // Reassociate expressions.
447- TheFPM->add(createReassociatePass ());
447+ TheFPM->addPass(ReassociatePass ());
448448 ...
449449
450450It is interesting to see what the code looks like before and after the
Original file line number Diff line number Diff line change 2121#include " llvm/Transforms/Scalar/GVN.h"
2222#include " llvm/Transforms/Scalar/Reassociate.h"
2323#include " llvm/Transforms/Scalar/SimplifyCFG.h"
24- #include " llvm/Transforms/Utils.h"
24+ #include " llvm/Transforms/Utils/Mem2Reg .h"
2525#include < algorithm>
2626#include < cassert>
2727#include < cctype>
@@ -1142,6 +1142,8 @@ static void InitializeModuleAndManagers() {
11421142 TheSI->registerCallbacks (*ThePIC, TheMAM.get ());
11431143
11441144 // Add transform passes.
1145+ // Promote allocas to registers.
1146+ TheFPM->addPass (PromotePass ());
11451147 // Do simple "peephole" optimizations and bit-twiddling optzns.
11461148 TheFPM->addPass (InstCombinePass ());
11471149 // Reassociate expressions.
You can’t perform that action at this time.
0 commit comments