systemc-clang icon indicating copy to clipboard operation
systemc-clang copied to clipboard

Excessive statements after return of a thread state

Open zhuanhao-wu opened this issue 1 year ago • 0 comments

https://github.com/intel/systemc-compiler/blob/main/tests/method/test_const_prop_loop.cpp

The thread seems to have an excessive block of statements for state 1 after the first return statement.

void threadProc() 
{
    unsigned slot = 0;
    wait();
    
    while (true) 
    {
        slot = (slot == 2) ? 0 : slot + 1;
        wait();
    } 
}

hSwitchCase  NONAME [
  hLiteral 1 NOLIST
  hIfStmt  NONAME [
    hLiteral 1 NOLIST
    hCStmt  NONAME NOLIST
  ]
  hLiteral 0 NOLIST
  hBinop = [
    hVarref slot_threadProc_thread_0 NOLIST
    hCondop  NONAME [
      hBinop == [
        hVarref slot_threadProc_thread_0 NOLIST
        hLiteral 2 NOLIST
      ]
      hLiteral 0 NOLIST
      hBinop + [
        hVarref slot_threadProc_thread_0 NOLIST
        hLiteral 1 NOLIST
      ]
    ]
  ]
  hBinop = [
    hVarref _next_state_threadProc# NOLIST
    hLiteral 2 NOLIST
  ]
  hReturnStmt  NONAME NOLIST
	  hBinop + [  // here: the following statements are after return and should not be generated
    hVarref slot_threadProc_thread_0 NOLIST
    hLiteral 1 NOLIST
  ]
	hBinop = [
    hVarref slot_threadProc_thread_0 NOLIST
    hCondop  NONAME [
      hBinop == [
        hVarref slot_threadProc_thread_0 NOLIST
        hLiteral 2 NOLIST
      ]
      hLiteral 0 NOLIST
      hBinop + [
        hVarref slot_threadProc_thread_0 NOLIST
        hLiteral 1 NOLIST
      ]
    ]
  ]
  hBinop = [
    hVarref _next_state_threadProc# NOLIST
    hLiteral 2 NOLIST
  ]
  hReturnStmt  NONAME NOLIST
]

zhuanhao-wu avatar Oct 03 '22 17:10 zhuanhao-wu