[llvm] dbaa5e6 - [docs] Kaleidoscope Tutorial Chapter 7 - base class Value* used for AllocaInst for assignment expression (#202101)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 12 01:26:50 PDT 2026
Author: Fan Mo
Date: 2026-06-12T18:22:50+10:00
New Revision: dbaa5e601ca06a88e66b95b94dc9d2974b1abded
URL: https://github.com/llvm/llvm-project/commit/dbaa5e601ca06a88e66b95b94dc9d2974b1abded
DIFF: https://github.com/llvm/llvm-project/commit/dbaa5e601ca06a88e66b95b94dc9d2974b1abded.diff
LOG: [docs] Kaleidoscope Tutorial Chapter 7 - base class Value* used for AllocaInst for assignment expression (#202101)
Eariler in this chapther, the value type of `NamedValues` was changed to
`AllocaInst*`, and so did all other occurs for example in
`VariableExprAST` and `ForExprAST`.
https://github.com/llvm/llvm-project/blob/6f8a363a483489687597e29b8bda0975e821f188/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl07.rst?plain=1#L321-L324
However, the newly added assignment expression is still using `Value*`
as the type for LHS. Although `Value` is the base class of `AllocaInst`
therefore the code compiles and works well, it's better to keep it
consistent
Added:
Modified:
llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl07.rst
llvm/examples/Kaleidoscope/Chapter7/toy.cpp
Removed:
################################################################################
diff --git a/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl07.rst b/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl07.rst
index ed1dea2324918..f7e7572367448 100644
--- a/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl07.rst
+++ b/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl07.rst
@@ -600,11 +600,11 @@ allowed.
return nullptr;
// Look up the name.
- Value *Variable = NamedValues[LHSE->getName()];
- if (!Variable)
+ AllocaInst *Alloca = NamedValues[LHSE->getName()];
+ if (!Alloca)
return LogErrorV("Unknown variable name");
- Builder->CreateStore(Val, Variable);
+ Builder->CreateStore(Val, Alloca);
return Val;
}
...
diff --git a/llvm/examples/Kaleidoscope/Chapter7/toy.cpp b/llvm/examples/Kaleidoscope/Chapter7/toy.cpp
index 91b7191a07c6f..9db44640f1c52 100644
--- a/llvm/examples/Kaleidoscope/Chapter7/toy.cpp
+++ b/llvm/examples/Kaleidoscope/Chapter7/toy.cpp
@@ -791,11 +791,11 @@ Value *BinaryExprAST::codegen() {
return nullptr;
// Look up the name.
- Value *Variable = NamedValues[LHSE->getName()];
- if (!Variable)
+ AllocaInst *Alloca = NamedValues[LHSE->getName()];
+ if (!Alloca)
return LogErrorV("Unknown variable name");
- Builder->CreateStore(Val, Variable);
+ Builder->CreateStore(Val, Alloca);
return Val;
}
More information about the llvm-commits
mailing list