first cut at backport of bitcode writer