[llvm] r264000 - AMDGPU: Fix dangling references introduced by r263982

Nicolai Haehnle via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 21 15:54:02 PDT 2016


Author: nha
Date: Mon Mar 21 17:54:02 2016
New Revision: 264000

URL: http://llvm.org/viewvc/llvm-project?rev=264000&view=rev
Log:
AMDGPU: Fix dangling references introduced by r263982

Fixes Valgrind errors on the test cases that were reported as failing
by buildbots.

Modified:
    llvm/trunk/lib/Target/AMDGPU/SIWholeQuadMode.cpp

Modified: llvm/trunk/lib/Target/AMDGPU/SIWholeQuadMode.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/SIWholeQuadMode.cpp?rev=264000&r1=263999&r2=264000&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/SIWholeQuadMode.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/SIWholeQuadMode.cpp Mon Mar 21 17:54:02 2016
@@ -184,14 +184,16 @@ char SIWholeQuadMode::scanInstructions(c
 void SIWholeQuadMode::propagateInstruction(const MachineInstr &MI,
                                            std::vector<WorkItem>& Worklist) {
   const MachineBasicBlock &MBB = *MI.getParent();
-  InstrInfo &II = Instructions[&MI];
+  InstrInfo II = Instructions[&MI]; // take a copy to prevent dangling references
   BlockInfo &BI = Blocks[&MBB];
 
   // Control flow-type instructions that are followed by WQM computations
   // must themselves be in WQM.
   if ((II.OutNeeds & StateWQM) && !(II.Needs & StateWQM) &&
-      (MI.isBranch() || MI.isTerminator() || MI.getOpcode() == AMDGPU::SI_KILL))
+      (MI.isBranch() || MI.isTerminator() || MI.getOpcode() == AMDGPU::SI_KILL)) {
+    Instructions[&MI].Needs = StateWQM;
     II.Needs = StateWQM;
+  }
 
   // Propagate to block level
   BI.Needs |= II.Needs;
@@ -253,7 +255,7 @@ void SIWholeQuadMode::propagateInstructi
 
 void SIWholeQuadMode::propagateBlock(const MachineBasicBlock &MBB,
                                      std::vector<WorkItem>& Worklist) {
-  BlockInfo &BI = Blocks[&MBB];
+  BlockInfo BI = Blocks[&MBB]; // take a copy to prevent dangling references
 
   // Propagate through instructions
   if (!MBB.empty()) {




More information about the llvm-commits mailing list