[llvm] [docs] Kaleidoscope Tutorial Chapter 7 - base class Value* used for AllocaInst for assignment expression (PR #202101)
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 11 01:05:45 PDT 2026
lhames wrote:
> Thanks @lhames , do you think it would be helpful if I add some instructions in the text like this: `Value` is the base class of `AllocaInst`, and `CreateStore` is generating exactly same IR for them
>
> So the readers may be less confused if they first time see this.
I just re-read this and realised that it's in code introduced in Chapter 7 anyway, so you can disregard my "minimise the diffs" argument: it doesn't apply here. :)
I've approved the patch as-is.
The alternative would be to explain _why_ `Value` is sufficient for `CreateStore`, but not for `CreateLoad`: `CreateStore` takes a Value to store and a location to store to (a `ptr`-typed Value), and can identify the type being stored from `Value` to store. `CreateLoad`, by contrast, takes a location to load from (another `ptr`-typed Value) and a _type to load_, which we have to get from somewhere else -- in this case `AllocaInst::getAllocatedType()`. If we hardcoded all values to be doubles then we could dispense with the `AllocaInst`s and use `Value` everywhere, but that would make adding more types later harder.
If this discussion is interesting enough it could be added as a footnote to the chapter, but I'm not sure it's worth it.
Thanks for for working on this, and sorry for the bum steer in the initial review! :)
https://github.com/llvm/llvm-project/pull/202101
More information about the llvm-commits
mailing list