O'Reilly logo

LLVM Cookbook by Suyog Sarda, Mayur Pandey

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Inserting the prologue-epilogue code

Inserting the prologue-epilogue code involves stack unwinding, finalizing the function layout, saving callee-saved registers and emitting the prologue and epilogue code. It also replaces abstract frame indexes with appropriate references. This pass runs after the register allocation phase.

How to do it…

The skeleton and the important functions defined in the PrologueEpilogueInserter class are as follows:

  • The prologue epilogue inserter pass runs on a machine function, hence it inherits the MachineFunctionPass class. Its constructor initializes the pass:
    class PEI : public MachineFunctionPass {
      public:
        static char ID;
        PEI() : MachineFunctionPass(ID) {
          initializePEIPass(*PassRegistry::getPassRegistry());
        }
  • There are ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required