Visual Studio Developer Center > Visual Studio Forums > Phoenix > Null Reference exception when travser a flow graph
Ask a questionAsk a question
 

QuestionNull Reference exception when travser a flow graph

  • Monday, June 01, 2009 8:19 AMzhong hao Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    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 } }
    When I execute the above code snippet, I get a null reference exeption at the line marked as "error". The error message says as follows:

    Phoenix Assertion Failure: d:\enlistments\sdk_june08\src\phx\dataflow\traverser.
    cpp, Line 377
      this->BlockDataArray != nullptr : Called Walker::Initialize before Traverse
      in (Data) <unnamed unit> during IR Unit Function Phases
      in (PEModule) F:\tmp1\test\test\bin\Debug\test.exe
      in (Program) <unnamed unit>
    Phoenix Assertion Failure: d:\enlistments\sdk_june08\src\phx\dataflow\traverser.
    cpp, Line 378
      this->Direction != Dataflow::Direction::IllegalSentinel
      in (Data) <unnamed unit> during IR Unit Function Phases
      in (PEModule) F:\tmp1\test\test\bin\Debug\test.exe
      in (Program) <unnamed unit>

    Can anyone give me some suggestions on why I get such an error message?
    • Edited byzhong hao Monday, June 01, 2009 8:31 AM
    •  

All Replies

  • Thursday, June 04, 2009 2:08 AMAndy Ayers - MSFTModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    The assert is trying to tell you that you left out a needed call. But it's worded a little strangely:

     this->BlockDataArray != nullptr : Called Walker::Initialize before Traverse

    it should really say "you must call Walker.Initialize before you call Walker.Traverse". 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.




    Architect - Microsoft Phoenix Project
  • Wednesday, June 10, 2009 6:31 AMzhong hao Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Many thanks. I add such a call to my code. Now I have no assertion errors. However, it still does not work.
    It seems that some IR units have no names. How can I build those names?

    Phoenix Assertion Failure: d:\enlistments\sdk_june08\gen\rdk\phx\pdl-host\32\gen
    -phx-pdl-phx.inl, Line 7155
      this->IsFunctionUnit
      in (Data) <unnamed unit> during IR Unit Function Phases
      in (PEModule) F:\tmp1\test\test\bin\Debug\test.exe
      in (Program) <unnamed unit>
  • Thursday, June 11, 2009 7:06 AMAndy Ayers - MSFTModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    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.


    Architect - Microsoft Phoenix Project