Trying to infer the 'returned' attribute if an argument is already
'returned' can lead to verification failure: inference might determine
that a different argument is passed through which would result in two
different arguments marked as 'returned'.
This fixes PR30350.
llvm-svn: 281221
if (F->getReturnType()->isVoidTy())
continue;
+ // There is nothing to do if an argument is already marked as 'returned'.
+ if (any_of(F->args(),
+ [](const Argument &Arg) { return Arg.hasReturnedAttr(); }))
+ continue;
+
auto FindRetArg = [&]() -> Value * {
Value *RetArg = nullptr;
for (BasicBlock &BB : *F)
cond.end: ; preds = %entry
ret i32 %p
}
+
+; CHECK: define i32 @test2(i32 %p1, i32 returned %p2)
+define i32 @test2(i32 %p1, i32 returned %p2) {
+ %_tmp4 = icmp eq i32 %p1, %p2
+ br i1 %_tmp4, label %bb2, label %bb1
+
+bb2: ; preds = %0
+ ret i32 %p1
+
+bb1: ; preds = %bb1, %0
+ br label %bb1
+}