Skip to content

Commit d91bb2f

Browse files
committed
[AsmParser] Check whether use is callee when determining function type
The code ended up treating a use in a call argument as if it were a call. Make sure this is actually the callee use.
1 parent 0a45d17 commit d91bb2f

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

llvm/lib/AsmParser/LLParser.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,9 @@ bool LLParser::validateEndOfModule(bool UpgradeDebugInfo) {
306306
for (const auto &[Name, Info] : make_early_inc_range(ForwardRefVals)) {
307307
auto GetCommonFunctionType = [](Value *V) -> FunctionType * {
308308
FunctionType *FTy = nullptr;
309-
for (User *U : V->users()) {
310-
auto *CB = dyn_cast<CallBase>(U);
311-
if (!CB || (FTy && FTy != CB->getFunctionType()))
309+
for (Use &U : V->uses()) {
310+
auto *CB = dyn_cast<CallBase>(U.getUser());
311+
if (!CB || !CB->isCallee(&U) || (FTy && FTy != CB->getFunctionType()))
312312
return nullptr;
313313
FTy = CB->getFunctionType();
314314
}

llvm/test/Assembler/incomplete-ir-declarations.ll

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
; CHECK: @g1 = external global i8
55
; CHECK: @g2 = external global i8
66
; CHECK: @g3 = external global i8
7+
; CHECK: @g4 = external global i8
78

89
; CHECK: declare void @fn1(i32)
910

@@ -12,9 +13,10 @@ define ptr @test() {
1213
call void @fn1(i32 1)
1314
call void @fn2(i32 2)
1415
call void @fn2(i32 2, i32 3)
15-
load i32, ptr @g1
16-
store i32 0, ptr @g1
17-
load i32, ptr @g1
18-
load i64, ptr @g2
19-
ret ptr @g3
16+
call void @fn2(ptr @g1)
17+
load i32, ptr @g2
18+
store i32 0, ptr @g2
19+
load i32, ptr @g3
20+
load i64, ptr @g3
21+
ret ptr @g4
2022
}

0 commit comments

Comments
 (0)