compiler: fix data extraction and add dead global elimination