[llvm] 8fa45b8 - [LLParser][OpaquePtr] Support forward reference to unnamed function
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 10 03:22:01 PST 2022
Author: Nikita Popov
Date: 2022-02-10T12:20:34+01:00
New Revision: 8fa45b826a68037904e2c4b7a9e2de7c4a798bd3
URL: https://github.com/llvm/llvm-project/commit/8fa45b826a68037904e2c4b7a9e2de7c4a798bd3
DIFF: https://github.com/llvm/llvm-project/commit/8fa45b826a68037904e2c4b7a9e2de7c4a798bd3.diff
LOG: [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.
Added:
Modified:
llvm/lib/AsmParser/LLParser.cpp
llvm/test/Assembler/opaque-ptr.ll
Removed:
################################################################################
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 432ec151cf8ae..4281193caf851 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<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()) +
diff --git a/llvm/test/Assembler/opaque-ptr.ll b/llvm/test/Assembler/opaque-ptr.ll
index ad292f880c56d..c4171fa778a5d 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
+}
More information about the llvm-commits
mailing list