liberty/lib/LAMP/LAMPProfiling.cpp
// TODO: this is the wrong way to solve the problem;
// instead, we should force lamp initialization to run before
// the global ctors.
this is the wrong way to solve the problem;
instead, we should force lamp initialization to run before
the global ctors.
this is the wrong way to solve the problem ; instead we should force lamp initialization to run before the global ctors .
void LAMPProfiler::constructGlobalCtors(Module *m, Function *f)
{
  GlobalCtorMap = new map<Function *, bool>();
  GlobalVariable *previous = m->getGlobalVariable("llvm.global_ctors");
  if( previous )
  {
    if( previous->hasInitializer() )
    {
      if( ConstantArray *ca = dyn_cast<ConstantArray>( previous->getInitializer() ) )
      {
        for(User::op_iterator i=ca->op_begin(), e=ca->op_end(); i!=e; ++i)
        {
          Constant *constant = dyn_cast<Constant>(i->get());
          Function *func = dyn_cast<Function>(constant->getOperand(1));
          constructCtors(func);
        }
      }
    }
  }
}
void LAMPProfiler :: constructGlobalCtors ( Module * m , Function * f ) { GlobalCtorMap = new map < Function * , bool > ( ) ; GlobalVariable * previous = m -> getGlobalVariable ( " " ) ; if ( previous ) { if ( previous -> hasInitializer ( ) ) { if ( ConstantArray * ca = dyn_cast < ConstantArray > ( previous -> getInitializer ( ) ) ) { for ( User :: op_iterator i = ca -> op_begin ( ) , e = ca -> op_end ( ) ; i != e ; ++ i ) { Constant * constant = dyn_cast < Constant > ( i -> get ( ) ) ; Function * func = dyn_cast < Function > ( constant -> getOperand ( 1 ) ) ; constructCtors ( func ) ; } } } } }
TODO: this is the wrong way to solve the problem;
instead, we should force lamp initialization to run before
the global ctors.
TODO : this is the wrong way to solve the problem ; instead we should force lamp initialization to run before the global ctors .
// If there was already a constructor list... // and it has an initializer // and if that initializer was an array