[llvm] f2f70fc - [llubi] Error if main is not a definition (#226475)

via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 25 07:21:50 PDT 2026


Author: Nikita Popov
Date: 2026-09-25T16:21:44+02:00
New Revision: f2f70fc15fca532f4968ba211e430e269dd18489

URL: https://github.com/llvm/llvm-project/commit/f2f70fc15fca532f4968ba211e430e269dd18489
DIFF: https://github.com/llvm/llvm-project/commit/f2f70fc15fca532f4968ba211e430e269dd18489.diff

LOG: [llubi] Error if main is not a definition (#226475)

Currently this crashes. Ran into this while using llubi with
llvm-reduce.

Added: 
    llvm/test/tools/llubi/main_declaration.ll

Modified: 
    llvm/tools/llubi/llubi.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/test/tools/llubi/main_declaration.ll b/llvm/test/tools/llubi/main_declaration.ll
new file mode 100644
index 0000000000000..68d5c430f8769
--- /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 eb45a1a5b84b5..00863dd5ecb39 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