[llvm] kaleidoscope: add missing check in the FunctionAST::codegen (PR #76322)
Amila Senadheera via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 17 23:29:16 PST 2025
https://github.com/Amila-Rukshan updated https://github.com/llvm/llvm-project/pull/76322
>From 485fbf4234398ee37de1c84c785f9c31857abae9 Mon Sep 17 00:00:00 2001
From: amila <amila.15 at cse.mrt.ac.lk>
Date: Sun, 24 Dec 2023 14:24:58 +0530
Subject: [PATCH] kaleidoscope tutorial: add missing check in the
FunctionAST::codegen
Signed-off-by: amila <amila.15 at cse.mrt.ac.lk>
---
llvm/examples/Kaleidoscope/Chapter3/toy.cpp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/llvm/examples/Kaleidoscope/Chapter3/toy.cpp b/llvm/examples/Kaleidoscope/Chapter3/toy.cpp
index 03563006685ad..66973ee3ebcfa 100644
--- a/llvm/examples/Kaleidoscope/Chapter3/toy.cpp
+++ b/llvm/examples/Kaleidoscope/Chapter3/toy.cpp
@@ -490,6 +490,9 @@ Function *FunctionAST::codegen() {
if (!TheFunction)
return nullptr;
+ if (!TheFunction->empty())
+ return (Function *)LogErrorV("Function cannot be redefined.");
+
// Create a new basic block to start insertion into.
BasicBlock *BB = BasicBlock::Create(*TheContext, "entry", TheFunction);
Builder->SetInsertPoint(BB);
More information about the llvm-commits
mailing list