1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 04:32:44 +01:00

AMDGPU: Avoid looking for the DebugLoc in end()

The end() iterator isn't a safe thing to dereference.  Pass the DebugLoc
into EmitFetchClause and EmitALUClause to avoid it.

llvm-svn: 278873
This commit is contained in:
Duncan P. N. Exon Smith 2016-08-17 00:06:43 +00:00
parent acae60042a
commit 53cb40dedd

View File

@ -450,27 +450,24 @@ private:
return ClauseFile(&ClauseHead, std::move(ClauseContent)); return ClauseFile(&ClauseHead, std::move(ClauseContent));
} }
void void EmitFetchClause(MachineBasicBlock::iterator InsertPos,
EmitFetchClause(MachineBasicBlock::iterator InsertPos, ClauseFile &Clause, const DebugLoc &DL, ClauseFile &Clause,
unsigned &CfCount) { unsigned &CfCount) {
CounterPropagateAddr(*Clause.first, CfCount); CounterPropagateAddr(*Clause.first, CfCount);
MachineBasicBlock *BB = Clause.first->getParent(); MachineBasicBlock *BB = Clause.first->getParent();
BuildMI(BB, InsertPos->getDebugLoc(), TII->get(AMDGPU::FETCH_CLAUSE)) BuildMI(BB, DL, TII->get(AMDGPU::FETCH_CLAUSE)).addImm(CfCount);
.addImm(CfCount);
for (unsigned i = 0, e = Clause.second.size(); i < e; ++i) { for (unsigned i = 0, e = Clause.second.size(); i < e; ++i) {
BB->splice(InsertPos, BB, Clause.second[i]); BB->splice(InsertPos, BB, Clause.second[i]);
} }
CfCount += 2 * Clause.second.size(); CfCount += 2 * Clause.second.size();
} }
void void EmitALUClause(MachineBasicBlock::iterator InsertPos, const DebugLoc &DL,
EmitALUClause(MachineBasicBlock::iterator InsertPos, ClauseFile &Clause, ClauseFile &Clause, unsigned &CfCount) {
unsigned &CfCount) {
Clause.first->getOperand(0).setImm(0); Clause.first->getOperand(0).setImm(0);
CounterPropagateAddr(*Clause.first, CfCount); CounterPropagateAddr(*Clause.first, CfCount);
MachineBasicBlock *BB = Clause.first->getParent(); MachineBasicBlock *BB = Clause.first->getParent();
BuildMI(BB, InsertPos->getDebugLoc(), TII->get(AMDGPU::ALU_CLAUSE)) BuildMI(BB, DL, TII->get(AMDGPU::ALU_CLAUSE)).addImm(CfCount);
.addImm(CfCount);
for (unsigned i = 0, e = Clause.second.size(); i < e; ++i) { for (unsigned i = 0, e = Clause.second.size(); i < e; ++i) {
BB->splice(InsertPos, BB, Clause.second[i]); BB->splice(InsertPos, BB, Clause.second[i]);
} }
@ -644,17 +641,18 @@ public:
break; break;
} }
case AMDGPU::RETURN: { case AMDGPU::RETURN: {
BuildMI(MBB, MI, MBB.findDebugLoc(MI), getHWInstrDesc(CF_END)); DebugLoc DL = MBB.findDebugLoc(MI);
BuildMI(MBB, MI, DL, getHWInstrDesc(CF_END));
CfCount++; CfCount++;
if (CfCount % 2) { if (CfCount % 2) {
BuildMI(MBB, I, MBB.findDebugLoc(MI), TII->get(AMDGPU::PAD)); BuildMI(MBB, I, DL, TII->get(AMDGPU::PAD));
CfCount++; CfCount++;
} }
MI->eraseFromParent(); MI->eraseFromParent();
for (unsigned i = 0, e = FetchClauses.size(); i < e; i++) for (unsigned i = 0, e = FetchClauses.size(); i < e; i++)
EmitFetchClause(I, FetchClauses[i], CfCount); EmitFetchClause(I, DL, FetchClauses[i], CfCount);
for (unsigned i = 0, e = AluClauses.size(); i < e; i++) for (unsigned i = 0, e = AluClauses.size(); i < e; i++)
EmitALUClause(I, AluClauses[i], CfCount); EmitALUClause(I, DL, AluClauses[i], CfCount);
break; break;
} }
default: default: