def _replace_datalayout(llvmir):
 lines = llvmir.splitlines()
 for (i, ln) in enumerate(lines):
  if ln.startswith('target datalayout'):
   tmp = 'target datalayout = "{0}"'
   lines[i] = tmp.format(default_data_layout)
   break
 return '\n'.join(lines)

def _replace_datalayout ( llvmir ) : lines = llvmir . splitlines ( ) for ( i , ln ) in enumerate ( lines ) : if ln . startswith ( 'target datalayout' ) : tmp = 'target datalayout = "{0}"' lines [ i ] = tmp . format ( default_data_layout ) break return '\n' . join ( lines )
find the line containing the datalayout and replace it .