From: Nikita Popov Date: Thu, 10 Feb 2022 11:20:34 +0000 (+0100) Subject: [LLParser][OpaquePtr] Support forward reference to unnamed function X-Git-Tag: upstream/15.0.7~17070 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8fa45b826a68037904e2c4b7a9e2de7c4a798bd3;p=platform%2Fupstream%2Fllvm.git [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. --- diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index 432ec15..4281193 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -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(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()) + diff --git a/llvm/test/Assembler/opaque-ptr.ll b/llvm/test/Assembler/opaque-ptr.ll index ad292f8..c4171fa 100644 --- a/llvm/test/Assembler/opaque-ptr.ll +++ b/llvm/test/Assembler/opaque-ptr.ll @@ -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 +}