[llvm-dev] [PATCH] A problem with a code sample in the tutorial LangImpl4.rst

Peter Martini via llvm-dev llvm-dev at lists.llvm.org
Wed Jan 20 18:33:33 PST 2016


Hello!

I was reading through the tutorial at
http://llvm.org/docs/tutorial/LangImpl4.html last night and ran into an
issue.  It was late, so I copy/pasted from the screen to test the code and
missed what turned out to be a pretty clear error in the sample code.

The literalinclude of the full code from the examples directory correctly
uses ```TheFPM->add(...)```, while the example code in the tutorial has
```TheFPM.add(...)```

The example in the tutorial also includes a function -
createBasicAliasAnalysisPass - which is not in the example file, and if I
try to add it back by hand causes the compilation to fail.

Attaching a diff with my local fixups to make it clearer (and assuming I
didn't make any fundamentally silly mistakes, I hope that's enough to apply
- but it's been a long time since I've played with subversion).

Regards,
Peter Martini
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160120/737125c6/attachment-0001.html>
-------------- next part --------------
Index: LangImpl4.rst
===================================================================
--- LangImpl4.rst	(revision 258296)
+++ LangImpl4.rst	(working copy)
@@ -137,18 +137,16 @@
       // Create a new pass manager attached to it.
       TheFPM = llvm::make_unique<FunctionPassManager>(TheModule.get());
 
-      // Provide basic AliasAnalysis support for GVN.
-      TheFPM.add(createBasicAliasAnalysisPass());
       // Do simple "peephole" optimizations and bit-twiddling optzns.
-      TheFPM.add(createInstructionCombiningPass());
+      TheFPM->add(createInstructionCombiningPass());
       // Reassociate expressions.
-      TheFPM.add(createReassociatePass());
+      TheFPM->add(createReassociatePass());
       // Eliminate Common SubExpressions.
-      TheFPM.add(createGVNPass());
+      TheFPM->add(createGVNPass());
       // Simplify the control flow graph (deleting unreachable blocks, etc).
-      TheFPM.add(createCFGSimplificationPass());
+      TheFPM->add(createCFGSimplificationPass());
 
-      TheFPM.doInitialization();
+      TheFPM->doInitialization();
     }
 
 This code initializes the global module ``TheModule``, and the function pass


More information about the llvm-dev mailing list