[llvm] 48578ec - Fix use of deprecated IRBuilder::CreateLoad in Kaleidoscope
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 11 15:49:59 PST 2021
Author: David Blaikie
Date: 2021-03-11T15:44:02-08:00
New Revision: 48578ec2c4b7a86841c4018b56dbf5a7ae24869d
URL: https://github.com/llvm/llvm-project/commit/48578ec2c4b7a86841c4018b56dbf5a7ae24869d
DIFF: https://github.com/llvm/llvm-project/commit/48578ec2c4b7a86841c4018b56dbf5a7ae24869d.diff
LOG: Fix use of deprecated IRBuilder::CreateLoad in Kaleidoscope
Added:
Modified:
llvm/examples/Kaleidoscope/Chapter7/toy.cpp
Removed:
################################################################################
diff --git a/llvm/examples/Kaleidoscope/Chapter7/toy.cpp b/llvm/examples/Kaleidoscope/Chapter7/toy.cpp
index f2d4cbb80486..d6069c015b61 100644
--- a/llvm/examples/Kaleidoscope/Chapter7/toy.cpp
+++ b/llvm/examples/Kaleidoscope/Chapter7/toy.cpp
@@ -745,12 +745,12 @@ Value *NumberExprAST::codegen() {
Value *VariableExprAST::codegen() {
// Look this variable up in the function.
- Value *V = NamedValues[Name];
- if (!V)
+ AllocaInst *A = NamedValues[Name];
+ if (!A)
return LogErrorV("Unknown variable name");
// Load the value.
- return Builder->CreateLoad(V, Name.c_str());
+ return Builder->CreateLoad(A->getAllocatedType(), A, Name.c_str());
}
Value *UnaryExprAST::codegen() {
@@ -962,7 +962,8 @@ Value *ForExprAST::codegen() {
// Reload, increment, and restore the alloca. This handles the case where
// the body of the loop mutates the variable.
- Value *CurVar = Builder->CreateLoad(Alloca, VarName.c_str());
+ Value *CurVar =
+ Builder->CreateLoad(Alloca->getAllocatedType(), Alloca, VarName.c_str());
Value *NextVar = Builder->CreateFAdd(CurVar, StepVal, "nextvar");
Builder->CreateStore(NextVar, Alloca);
More information about the llvm-commits
mailing list