[llvm] [llubi] Error if main is not a definition (PR #226475)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 25 06:11:47 PDT 2026
https://github.com/nikic updated https://github.com/llvm/llvm-project/pull/226475
>From 13859f1ff9d6e72183b14b0ba8be4703b825958d Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov at redhat.com>
Date: Fri, 25 Sep 2026 14:59:40 +0200
Subject: [PATCH] [llubi] Error if main is not a definition
Currently this crashes. Ran into this while using llubi with
llvm-reduce.
---
llvm/test/tools/llubi/main_declaration.ll | 5 +++++
llvm/tools/llubi/llubi.cpp | 4 ++++
2 files changed, 9 insertions(+)
create mode 100644 llvm/test/tools/llubi/main_declaration.ll
diff --git a/llvm/test/tools/llubi/main_declaration.ll b/llvm/test/tools/llubi/main_declaration.ll
new file mode 100644
index 00000000000000..68d5c430f87693
--- /dev/null
+++ b/llvm/test/tools/llubi/main_declaration.ll
@@ -0,0 +1,5 @@
+; NOTE: Assertions have been autogenerated by utils/update_llubi_test_checks.py UTC_ARGS: --version 6
+; RUN: not llubi --verbose < %s 2>&1 | FileCheck %s
+
+declare i32 @main()
+; CHECK: error: 'main' must be definition.
diff --git a/llvm/tools/llubi/llubi.cpp b/llvm/tools/llubi/llubi.cpp
index eb45a1a5b84b56..00863dd5ecb391 100644
--- a/llvm/tools/llubi/llubi.cpp
+++ b/llvm/tools/llubi/llubi.cpp
@@ -277,6 +277,10 @@ int main(int argc, char **argv) {
<< "\' function not found in module.\n";
return 1;
}
+ if (EntryFn->isDeclaration()) {
+ WithColor::error() << '\'' << EntryFunc << "\' must be definition.\n";
+ return 1;
+ }
TargetLibraryInfo TLI(Ctx.getTLIImpl());
Type *IntTy = IntegerType::get(Ctx.getContext(), TLI.getIntSize());
Type *PtrTy = PointerType::getUnqual(Ctx.getContext());
More information about the llvm-commits
mailing list