Custom pass that runs before EmitStartOfAsmFile()?

Hi all,

I’m trying to write a custom module-level pass that runs before AsmPrinter::EmitStartOfAsmFile(), since I’d like to have some processed information available once entering this function.

Looking through “Writing an LLVM pass” documentation, it’s not clear to me if this is possible. I’ve also tried putting the pass in different orders (addPreISel, addIRPasses, and etc.). Am I missing something or this is just not possible to do? Any help is appreciated.



Hi Cheng-Chih,

You can add custom passes right before code emit by implementing the ‘addPreEmitPass()’ function of your

target pass config.

An example of this can be found here:


Jeroen Dobbelaere

Thanks Jeroen. Unfortunately that does not solve my problem. It still appears that EmitStartOfAsmFile runs before that.