gpu-compute: fix segfault when constructing GPUExecContext

the GPUExecContext context currently stores a reference to its parent WF's
GPUISA object, however there are some special instructions that do not have
an associated WF. when these objects are constructed they set their WF pointer
to null, which causes the GPUExecContext to segfault when trying to
dereference
the WF pointer to get at the WF's GPUISA object. here we change the GPUISA
reference in the GPUExecContext class to a pointer so that it may be set to
null.
This commit is contained in:
Tony Gutierrez 2016-11-21 15:40:03 -05:00
parent a0d4019abd
commit 14deacf86e
2 changed files with 6 additions and 4 deletions

View file

@ -37,7 +37,7 @@
#include "gpu-compute/wavefront.hh" #include "gpu-compute/wavefront.hh"
GPUExecContext::GPUExecContext(ComputeUnit *_cu, Wavefront *_wf) GPUExecContext::GPUExecContext(ComputeUnit *_cu, Wavefront *_wf)
: cu(_cu), wf(_wf), gpuISA(_wf->gpuISA()) : cu(_cu), wf(_wf), gpuISA(_wf ? &_wf->gpuISA() : nullptr)
{ {
} }
@ -56,11 +56,13 @@ GPUExecContext::wavefront()
TheGpuISA::MiscReg TheGpuISA::MiscReg
GPUExecContext::readMiscReg(int opIdx) const GPUExecContext::readMiscReg(int opIdx) const
{ {
return gpuISA.readMiscReg(opIdx); assert(gpuISA);
return gpuISA->readMiscReg(opIdx);
} }
void void
GPUExecContext::writeMiscReg(int opIdx, TheGpuISA::MiscReg operandVal) GPUExecContext::writeMiscReg(int opIdx, TheGpuISA::MiscReg operandVal)
{ {
gpuISA.writeMiscReg(opIdx, operandVal); assert(gpuISA);
gpuISA->writeMiscReg(opIdx, operandVal);
} }

View file

@ -55,7 +55,7 @@ class GPUExecContext
protected: protected:
ComputeUnit *cu; ComputeUnit *cu;
Wavefront *wf; Wavefront *wf;
TheGpuISA::GPUISA &gpuISA; TheGpuISA::GPUISA *gpuISA;
}; };
#endif // __GPU_EXEC_CONTEXT_HH__ #endif // __GPU_EXEC_CONTEXT_HH__