This is an archive of the discontinued LLVM Phabricator instance.

[lli] Fix crash on empty entry-function
ClosedPublic

Authored by c-rhodes on Jul 28 2023, 1:35 AM.

Details

Summary

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.

Diff Detail

Event Timeline

c-rhodes created this revision.Jul 28 2023, 1:35 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 28 2023, 1:35 AM
c-rhodes requested review of this revision.Jul 28 2023, 1:35 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 28 2023, 1:35 AM
c-rhodes removed a project: Restricted Project.Jul 28 2023, 1:53 AM
lhames accepted this revision.Jul 28 2023, 10:12 AM

Otherwise LGTM. Thanks @c-rhodes!

llvm/test/ExecutionEngine/Orc/empty-entry-function.ll
7–10

I think you can omit the IR entirely since you'll error out before attempting to parse it:

; RUN: not lli --entry-function= %s 2>&1 | FileCheck %s
;
; Test empty entry-function yield an error.
;
; CHECK: error: entry-function empty
llvm/tools/lli/lli.cpp
449–452

Could you change the error message to "--entry-function name cannot be empty"?

This revision is now accepted and ready to land.Jul 28 2023, 10:12 AM
This revision was automatically updated to reflect the committed changes.
c-rhodes marked an inline comment as done.Jul 31 2023, 2:37 AM

Otherwise LGTM. Thanks @c-rhodes!

Addressed your comments before landing, thanks for reviewing!