Index: lib/Target/AMDGPU/AMDGPUMCInstLower.cpp =================================================================== --- lib/Target/AMDGPU/AMDGPUMCInstLower.cpp +++ lib/Target/AMDGPU/AMDGPUMCInstLower.cpp @@ -113,7 +113,7 @@ SmallVector BBStr; raw_svector_ostream Str(BBStr); - const MachineBasicBlock *MBB = MI->getOperand(1).getMBB(); + const MachineBasicBlock *MBB = MI->getOperand(0).getMBB(); const MCSymbolRefExpr *Expr = MCSymbolRefExpr::create(MBB->getSymbol(), OutContext); Expr->print(Str, MAI); Index: lib/Target/AMDGPU/SIInstructions.td =================================================================== --- lib/Target/AMDGPU/SIInstructions.td +++ lib/Target/AMDGPU/SIInstructions.td @@ -1936,7 +1936,7 @@ // Dummy terminator instruction to use after control flow instructions // replaced with exec mask operations. def SI_MASK_BRANCH : InstSI < - (outs SReg_64:$dst), (ins brtarget:$target)> { + (outs), (ins brtarget:$target, SReg_64:$dst)> { let isBranch = 1; let isTerminator = 1; let isBarrier = 1; Index: lib/Target/AMDGPU/SILowerControlFlow.cpp =================================================================== --- lib/Target/AMDGPU/SILowerControlFlow.cpp +++ lib/Target/AMDGPU/SILowerControlFlow.cpp @@ -219,8 +219,9 @@ Skip(MI, MI.getOperand(2)); // Insert a pseudo terminator to help keep the verifier happy. - BuildMI(MBB, &MI, DL, TII->get(AMDGPU::SI_MASK_BRANCH), Reg) - .addOperand(MI.getOperand(2)); + BuildMI(MBB, &MI, DL, TII->get(AMDGPU::SI_MASK_BRANCH)) + .addOperand(MI.getOperand(2)) + .addReg(Reg); MI.eraseFromParent(); } @@ -251,8 +252,9 @@ Skip(MI, MI.getOperand(2)); // Insert a pseudo terminator to help keep the verifier happy. - BuildMI(MBB, &MI, DL, TII->get(AMDGPU::SI_MASK_BRANCH), Dst) - .addOperand(MI.getOperand(2)); + BuildMI(MBB, &MI, DL, TII->get(AMDGPU::SI_MASK_BRANCH)) + .addOperand(MI.getOperand(2)) + .addReg(Dst); MI.eraseFromParent(); }