This is an archive of the discontinued LLVM Phabricator instance.

New Kaleidoscope section: Creating object files
ClosedPublic

Authored by Wilfred on Mar 10 2016, 3:32 PM.

Details

Summary

The Kaleidoscope tutorial has great coverage of most of the basic LLVM use cases, but it doesn't cover creating object files. I struggled with this when I started working with LLVM, and I've seen others express a need for this (e.g. this blog post).

So, I've written a new chapter that walks users through generating object code. This is based on my understanding from reading llc and rustc source code, so please highlight any sections that are misleading or outright wrong.

This new chapter is chapter 5. You can ignore any changes to chapters 6-10, this is a simple renumbering.

You can also view the new chapter as rendered HTML at http://www.wilfred.me.uk/llvm/tutorial/LangImpl5.html

Diff Detail

Event Timeline

Wilfred updated this revision to Diff 50366.Mar 10 2016, 3:32 PM
Wilfred updated this revision to Diff 50368.
Wilfred retitled this revision from to New Kaleidoscope section: Creating object files.
Wilfred updated this object.
Wilfred added reviewers: silvas, lhames.
Wilfred set the repository for this revision to rL LLVM.
Wilfred removed rL LLVM as the repository for this revision.
Wilfred added a subscriber: llvm-commits.

Fixing an issue where the "Next: ..." footers were using incorrect numbering.

silvas edited edge metadata.Mar 11 2016, 5:36 PM

Can you split out all the changes that end up making the diff huge? It makes the patch hard to review.

Wilfred updated this object.Mar 12 2016, 1:49 AM
Wilfred edited edge metadata.
Wilfred updated this revision to Diff 50517.EditedMar 12 2016, 1:56 AM

Here's a smaller diff that only shows the new chapter 5. What was previously chapter 5 is now chapter 6, and so on.

I've also uploaded the rendered HTML, so you can view the result of this patch: http://www.wilfred.me.uk/llvm/tutorial/LangImpl5.html

You might also find it helpful to simply read the whole .rst file rather than diff. https://github.com/Wilfred/llvm/blame/tutorial_object_files/docs/tutorial/LangImpl5.rst Likewise, the full toy.cpp for this chapter is visible at https://github.com/Wilfred/llvm/blob/tutorial_object_files/examples/Kaleidoscope/Chapter5/toy.cpp

(As far as I can see Phabricator only shows the diff, not the file after the patch is applied.)

lhames edited edge metadata.Mar 12 2016, 2:31 PM

Hi Wilfred,

I haven't had a chance to read the new chapter yet - I hope to do that early next week.

Regarding the chapter ordering - I don't think Chapter 5 is the right place to bring this material in. It should either be introduced before the JIT chapters, or after them. I think after is a better fit: Chapter 8 ("Adding Debug Information") currently has an Ahead-of-time mode section. I'd be inclined to insert your Chapter as a new Chapter 8, making "Adding Debug Information" Chapter 9, and removing the ahead-of-time section.

Cheers,
Lang.

Hi Wilfred,

This looks great. My only outstanding concern is the chapter ordering - I think this should be Chapter 8 instead.

Just a heads up - I'll be out on vacation next week, but back on the 1st of April, at which point I can take more of a look at this, and we can try to get it in tree.

Thanks again for working on this!

  • Lang.
Wilfred updated this revision to Diff 54281.Apr 19 2016, 3:32 PM
Wilfred edited edge metadata.
Wilfred set the repository for this revision to rL LLVM.

OK, I've updated the patch. The new chapter is now chapter 8, and the sample code is based on chapter 7 but with object code generation.

Since phabricator can show arbitrary diffs, I've 'cheated' and this patch shows chapter 8 as new, rather than showing the difference to current chapter 8 (which is now chapter 9).

I think this is easier to review. Please let me know what you think.

As before, you can view this chapter as HTML at http://www.wilfred.me.uk/llvm/tutorial/LangImpl08.html . You can also view the whole diff by looking at my branch: https://github.com/llvm-mirror/llvm/compare/master...Wilfred:create_object_files_chapter_9

Ping. Are you happy with this? I think it's ready to merge.

lhames accepted this revision.May 4 2016, 2:42 PM
lhames edited edge metadata.

Sorry for the delay Wilfred, and thanks very much for working on this.

It all looks good to me. Do you have commit access? If so, please go ahead and commit it. If not I'd be happy to commit it on your behalf.

  • Lang.
This revision is now accepted and ready to land.May 4 2016, 2:42 PM

Thanks!

I've got commit access, so I'll apply the patch.

This revision was automatically updated to reflect the committed changes.