Use int3 trap padding between functions instead of trapsleds with a leading jump. Index: include/llvm/CodeGen/AsmPrinter.h --- include/llvm/CodeGen/AsmPrinter.h.orig +++ include/llvm/CodeGen/AsmPrinter.h @@ -434,6 +434,11 @@ class AsmPrinter : public MachineFunctionPass { (publi /// correctness. void emitAlignment(Align Alignment, const GlobalObject *GV = nullptr) const; + /// Emit an alignment directive to the specified power of two boundary, + /// like emitAlignment, but call emitTrapToAlignment to fill with + /// trap instructions instead of NOPs. + void emitTrapAlignment(Align Alignment, const GlobalObject *GO = nullptr) const; + /// Lower the specified LLVM Constant to an MCExpr. virtual const MCExpr *lowerConstant(const Constant *CV); @@ -499,6 +504,11 @@ class AsmPrinter : public MachineFunctionPass { (publi virtual void emitInstruction(const MachineInstr *) { llvm_unreachable("EmitInstruction not implemented"); } + + /// Emit an alignment directive to the specified power + /// of two boundary, but use Trap instructions for alignment + /// sections that should never be executed. + virtual void emitTrapToAlignment(Align Alignment) const; /// Return the symbol for the specified constant pool entry. virtual MCSymbol *GetCPISymbol(unsigned CPID) const;