This is an archive of the discontinued LLVM Phabricator instance.

docs: tutorial: insert the basic blocks into the function at construction
AbandonedPublic

Authored by thegameg on Apr 21 2016, 1:30 AM.

Details

Summary

In the 5th part of Kaleidoscope C++ tutorial, codegen part (5.2.5), the newly created basic blocks are not inserted right away in the parent function of the insertion point.

Inserting them right away makes it look similar to the loop construction, and, in my opinion, avoids confusion.

  • docs/tutorial/LangImpl5.rst: Update the tutorial.
  • examples/Kaleidoscope/Chapter5/toy.cpp,
  • examples/Kaleidoscope/Chapter6/toy.cpp,
  • examples/Kaleidoscope/Chapter7/toy.cpp,
  • examples/Kaleidoscope/Chapter8/toy.cpp: Propagate changes to next chapters.

Diff Detail

Repository
rL LLVM

Event Timeline

thegameg updated this revision to Diff 54466.Apr 21 2016, 1:30 AM
thegameg retitled this revision from to docs: tutorial: insert the basic blocks into the function at construction.
thegameg updated this object.
thegameg updated this object.Apr 21 2016, 1:36 AM
thegameg added reviewers: lhames, silvas, mehdi_amini.
thegameg added a subscriber: llvm-commits.
mehdi_amini edited edge metadata.Apr 27 2016, 11:08 PM

That can sound reasonable, but I'm not sure how much of it was intentional in the first place...

silvas resigned from this revision.Jul 8 2016, 11:44 PM
silvas removed a reviewer: silvas.
lhames edited edge metadata.Jul 9 2016, 8:52 AM

Apologies for the delayed reply on this.

I think the reason for the deferred emission is that it makes the resulting CFG print more neatly when you have nested ifs: the first nested if will appear above the second, and before the join block of the original if.

  • Lang.
thegameg abandoned this revision.Jul 9 2016, 9:05 AM

Oh, I see, sound reasonable. Thanks @lhames for reviewing this.