Null Reference exception when travser a flow graph<pre><br/>foreach (Phx.Unit unit in oldModuleUnit.ChildUnits) { if (unit.IsFunctionUnit) { Phx.FunctionUnit functionUnit = ((Phx.FunctionUnit)unit); Phx.FunctionUnitState raiseToState = Phx.FunctionUnit.LowLevelIRBeforeLayoutFunctionUnitState; functionUnit = oldModuleUnit.Raise(functionUnit.FunctionSymbol, raiseToState); functionUnit.BuildFlowGraph(); Phx.Dataflow.MemoryLivenessWalker walker = Phx.Dataflow.MemoryLivenessWalker.New(functionUnit.Lifetime); walker.Traverse(Phx.Dataflow.TraversalKind.Iterative, functionUnit); //error } }<br/></pre> When I execute the above code snippet, I get a null reference exeption at the line marked as &quot;error&quot;. The error message says as follows:<br/><br/>Phoenix Assertion Failure: d:\enlistments\sdk_june08\src\phx\dataflow\traverser.<br/>cpp, Line 377<br/>  this-&gt;BlockDataArray != nullptr : Called Walker::Initialize before Traverse<br/>  in (Data) &lt;unnamed unit&gt; during IR Unit Function Phases<br/>  in (PEModule) F:\tmp1\test\test\bin\Debug\test.exe<br/>  in (Program) &lt;unnamed unit&gt;<br/>Phoenix Assertion Failure: d:\enlistments\sdk_june08\src\phx\dataflow\traverser.<br/>cpp, Line 378<br/>  this-&gt;Direction != Dataflow::Direction::IllegalSentinel<br/>  in (Data) &lt;unnamed unit&gt; during IR Unit Function Phases<br/>  in (PEModule) F:\tmp1\test\test\bin\Debug\test.exe<br/>  in (Program) &lt;unnamed unit&gt;<br/><br/>Can anyone give me some suggestions on why I get such an error message?© 2009 Microsoft Corporation. All rights reserved.Thu, 11 Jun 2009 07:06:15 Za7c7401d-265a-4c9f-8507-4a16115d993ahttp://social.msdn.microsoft.com/Forums/en-US/phoenix/thread/a7c7401d-265a-4c9f-8507-4a16115d993a#a7c7401d-265a-4c9f-8507-4a16115d993ahttp://social.msdn.microsoft.com/Forums/en-US/phoenix/thread/a7c7401d-265a-4c9f-8507-4a16115d993a#a7c7401d-265a-4c9f-8507-4a16115d993azhong haohttp://social.msdn.microsoft.com/Profile/en-US/?user=zhong%20haoNull Reference exception when travser a flow graph<pre><br/>foreach (Phx.Unit unit in oldModuleUnit.ChildUnits) { if (unit.IsFunctionUnit) { Phx.FunctionUnit functionUnit = ((Phx.FunctionUnit)unit); Phx.FunctionUnitState raiseToState = Phx.FunctionUnit.LowLevelIRBeforeLayoutFunctionUnitState; functionUnit = oldModuleUnit.Raise(functionUnit.FunctionSymbol, raiseToState); functionUnit.BuildFlowGraph(); Phx.Dataflow.MemoryLivenessWalker walker = Phx.Dataflow.MemoryLivenessWalker.New(functionUnit.Lifetime); walker.Traverse(Phx.Dataflow.TraversalKind.Iterative, functionUnit); //error } }<br/></pre> When I execute the above code snippet, I get a null reference exeption at the line marked as &quot;error&quot;. The error message says as follows:<br/><br/>Phoenix Assertion Failure: d:\enlistments\sdk_june08\src\phx\dataflow\traverser.<br/>cpp, Line 377<br/>  this-&gt;BlockDataArray != nullptr : Called Walker::Initialize before Traverse<br/>  in (Data) &lt;unnamed unit&gt; during IR Unit Function Phases<br/>  in (PEModule) F:\tmp1\test\test\bin\Debug\test.exe<br/>  in (Program) &lt;unnamed unit&gt;<br/>Phoenix Assertion Failure: d:\enlistments\sdk_june08\src\phx\dataflow\traverser.<br/>cpp, Line 378<br/>  this-&gt;Direction != Dataflow::Direction::IllegalSentinel<br/>  in (Data) &lt;unnamed unit&gt; during IR Unit Function Phases<br/>  in (PEModule) F:\tmp1\test\test\bin\Debug\test.exe<br/>  in (Program) &lt;unnamed unit&gt;<br/><br/>Can anyone give me some suggestions on why I get such an error message?Mon, 01 Jun 2009 08:19:59 Z2009-06-01T08:31:50Zhttp://social.msdn.microsoft.com/Forums/en-US/phoenix/thread/a7c7401d-265a-4c9f-8507-4a16115d993a#286589b7-e432-4584-a3d8-4ee0357be94ehttp://social.msdn.microsoft.com/Forums/en-US/phoenix/thread/a7c7401d-265a-4c9f-8507-4a16115d993a#286589b7-e432-4584-a3d8-4ee0357be94eAndy Ayers - MSFThttp://social.msdn.microsoft.com/Profile/en-US/?user=Andy%20Ayers%20-%20MSFTNull Reference exception when travser a flow graphThe assert is trying to tell you that you left out a needed call. But it's worded a little strangely:<br/><br/> this-&gt;BlockDataArray != nullptr : Called Walker::Initialize before Traverse<br/><br/>it should really say &quot;you must call Walker.Initialize before you call Walker.Traverse&quot;. The fix is thus to add a call walker.Initialize(direction, functionUnit) before you call walker.Traverse. Direction for liveness should be Phx.Dataflow.Direction.Backward.<br/><br/><br/><br/><hr class="sig">Architect - Microsoft Phoenix ProjectThu, 04 Jun 2009 02:08:44 Z2009-06-04T02:08:44Zhttp://social.msdn.microsoft.com/Forums/en-US/phoenix/thread/a7c7401d-265a-4c9f-8507-4a16115d993a#2a51ca7b-1202-46e6-a200-aa9563eef611http://social.msdn.microsoft.com/Forums/en-US/phoenix/thread/a7c7401d-265a-4c9f-8507-4a16115d993a#2a51ca7b-1202-46e6-a200-aa9563eef611zhong haohttp://social.msdn.microsoft.com/Profile/en-US/?user=zhong%20haoNull Reference exception when travser a flow graphMany thanks. I add such a call to my code. Now I have no assertion errors. However, it still does not work.<br/>It seems that some IR units have no names. How can I build those names?<br/><br/>Phoenix Assertion Failure: d:\enlistments\sdk_june08\gen\rdk\phx\pdl-host\32\gen<br/>-phx-pdl-phx.inl, Line 7155<br/>  this-&gt;IsFunctionUnit<br/>  in (Data) &lt;unnamed unit&gt; during IR Unit Function Phases<br/>  in (PEModule) F:\tmp1\test\test\bin\Debug\test.exe<br/>  in (Program) &lt;unnamed unit&gt;Wed, 10 Jun 2009 06:31:22 Z2009-06-10T06:31:22Zhttp://social.msdn.microsoft.com/Forums/en-US/phoenix/thread/a7c7401d-265a-4c9f-8507-4a16115d993a#885091cc-9fc0-4be8-a7ac-e87e456aac5dhttp://social.msdn.microsoft.com/Forums/en-US/phoenix/thread/a7c7401d-265a-4c9f-8507-4a16115d993a#885091cc-9fc0-4be8-a7ac-e87e456aac5dAndy Ayers - MSFThttp://social.msdn.microsoft.com/Profile/en-US/?user=Andy%20Ayers%20-%20MSFTNull Reference exception when travser a flow graph<p>Make sure your code is only looking at function units (you have such a test in your code sample above). There are other kinds of units, eg DataUnits, that do not contain code.</p><hr class="sig">Architect - Microsoft Phoenix ProjectThu, 11 Jun 2009 07:06:15 Z2009-06-11T07:06:15Z