[LLParser][OpaquePtr] Support forward reference to unnamed function

With opaque pointers, we always create forward references as i8
globals, so it will not be Function here.
This commit is contained in:
Nikita Popov 2022-02-10 12:20:34 +01:00
parent 1c729d719a
commit 8fa45b826a
2 changed files with 13 additions and 1 deletions

View File

@ -5631,7 +5631,7 @@ bool LLParser::parseFunctionHeader(Function *&Fn, bool IsDefine) {
// types agree.
auto I = ForwardRefValIDs.find(NumberedVals.size());
if (I != ForwardRefValIDs.end()) {
FwdFn = cast<Function>(I->second.first);
FwdFn = I->second.first;
if (!FwdFn->getType()->isOpaque() && FwdFn->getType() != PFT)
return error(NameLoc, "type of definition and forward reference of '@" +
Twine(NumberedVals.size()) +

View File

@ -149,3 +149,15 @@ cleanup:
define void @byval(ptr byval({ i32, i32 }) %0) {
ret void
}
; CHECK: define void @call_unnamed_fn() {
; CHECK: call void @0()
define void @call_unnamed_fn() {
call void @0()
ret void
}
; CHECK: define void @0() {
define void @0() {
ret void
}