[PATCH] D156516: [lli] Fix crash on empty entry-function
Cullen Rhodes via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 28 01:35:47 PDT 2023
c-rhodes created this revision.
c-rhodes added a reviewer: lhames.
c-rhodes added a project: MLIR.
Herald added a project: All.
c-rhodes requested review of this revision.
Herald added a project: LLVM.
Empty entry-function triggers the following assertion:
llvm/lib/IR/Mangler.cpp:38: void getNameWithPrefixImpl(llvm::raw_ostream
&, const llvm::Twine &, (anonymous namespace)::ManglerPrefixTy, const
llvm::DataLayout &, char):
Assertion `!Name.empty() && "getNameWithPrefix requires non-empty name"' failed.
Throw an error if entry-function is empty.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D156516
Files:
llvm/test/ExecutionEngine/Orc/empty-entry-function.ll
llvm/tools/lli/lli.cpp
Index: llvm/tools/lli/lli.cpp
===================================================================
--- llvm/tools/lli/lli.cpp
+++ llvm/tools/lli/lli.cpp
@@ -446,6 +446,11 @@
ExitOnErr(loadDylibs());
+ if (EntryFunc.empty()) {
+ WithColor::error(errs(), argv[0]) << "entry-function empty\n";
+ exit(1);
+ }
+
if (UseJITKind == JITKind::MCJIT)
disallowOrcOptions();
else
Index: llvm/test/ExecutionEngine/Orc/empty-entry-function.ll
===================================================================
--- /dev/null
+++ llvm/test/ExecutionEngine/Orc/empty-entry-function.ll
@@ -0,0 +1,9 @@
+; RUN: not lli --entry-function= %s 2>&1 | FileCheck %s
+;
+; Test empty entry-function yield an error.
+
+; CHECK: error: entry-function empty
+define i32 @main(i32 %argc, ptr %argv) {
+entry:
+ ret i32 0
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156516.545057.patch
Type: text/x-patch
Size: 822 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230728/0f860340/attachment.bin>
More information about the llvm-commits
mailing list