Create phi nodes for swifterror values at the end of the phi instructions list

ISel makes assumption about the order of phi nodes.

rdar://28190150

llvm-svn: 281095
This commit is contained in:
Arnold Schwaighofer 2016-09-09 21:18:47 +00:00
parent 432d3d2619
commit 7d7b4b4014
2 changed files with 20 additions and 1 deletions

View File

@ -1253,7 +1253,7 @@ static void mergeIncomingSwiftErrors(FunctionLoweringInfo *FuncInfo,
FuncInfo->SwiftErrorMap[FuncInfo->MBB].push_back(VReg);
MachineInstrBuilder SwiftErrorPHI = BuildMI(*FuncInfo->MBB,
FuncInfo->MBB->begin(), SDB->getCurDebugLoc(),
FuncInfo->InsertPt, SDB->getCurDebugLoc(),
TII->get(TargetOpcode::PHI), VReg);
for (const_pred_iterator PI = pred_begin(LLVMBB), PE = pred_end(LLVMBB);
PI != PE; ++PI) {

View File

@ -357,3 +357,22 @@ handler2:
ret float 1.0
}
%swift.refcounted = type opaque
; This test checks that we don't create bad phi nodes as part of swifterror
; isel. We used to fail machine ir verification.
; CHECK-APPLE: _swifterror_isel
; CHECK-O0: _swifterror_isel
define void @swifterror_isel(%swift.refcounted*) {
entry:
%swifterror = alloca swifterror %swift_error*, align 8
br i1 undef, label %5, label %1
%2 = phi i16 [ %4, %1 ], [ undef, %entry ]
%3 = call i1 undef(i16 %2, %swift.refcounted* swiftself %0, %swift_error** nocapture swifterror %swifterror)
%4 = load i16, i16* undef, align 2
br label %1
ret void
}