@@ -909,6 +909,23 @@ void PPCAsmPrinter::emitInstruction(const MachineInstr *MI) {
909909 // Lower multi-instruction pseudo operations.
910910 switch (MI->getOpcode ()) {
911911 default : break ;
912+ case TargetOpcode::PATCHABLE_FUNCTION_ENTER: {
913+ assert (!Subtarget->isAIXABI () &&
914+ " AIX does not support patchable function entry!" );
915+ // PATCHABLE_FUNCTION_ENTER on little endian is for XRAY support which is
916+ // handled in PPCLinuxAsmPrinter.
917+ if (MAI->isLittleEndian ())
918+ return ;
919+ const Function &F = MF->getFunction ();
920+ unsigned Num = 0 ;
921+ (void )F.getFnAttribute (" patchable-function-entry" )
922+ .getValueAsString ()
923+ .getAsInteger (10 , Num);
924+ if (!Num)
925+ return ;
926+ emitNops (Num);
927+ return ;
928+ }
912929 case TargetOpcode::DBG_VALUE:
913930 llvm_unreachable (" Should be handled target independently" );
914931 case TargetOpcode::STACKMAP:
@@ -1780,7 +1797,7 @@ void PPCLinuxAsmPrinter::emitInstruction(const MachineInstr *MI) {
17801797
17811798 switch (MI->getOpcode ()) {
17821799 default :
1783- return PPCAsmPrinter::emitInstruction (MI) ;
1800+ break ;
17841801 case TargetOpcode::PATCHABLE_FUNCTION_ENTER: {
17851802 // .begin:
17861803 // b .end # lis 0, FuncId[16..32]
@@ -1793,6 +1810,9 @@ void PPCLinuxAsmPrinter::emitInstruction(const MachineInstr *MI) {
17931810 //
17941811 // Update compiler-rt/lib/xray/xray_powerpc64.cc accordingly when number
17951812 // of instructions change.
1813+ // XRAY is only supported on PPC Linux little endian.
1814+ if (!MAI->isLittleEndian ())
1815+ break ;
17961816 MCSymbol *BeginOfSled = OutContext.createTempSymbol ();
17971817 MCSymbol *EndOfSled = OutContext.createTempSymbol ();
17981818 OutStreamer->emitLabel (BeginOfSled);
@@ -1909,6 +1929,7 @@ void PPCLinuxAsmPrinter::emitInstruction(const MachineInstr *MI) {
19091929 llvm_unreachable (" Tail call is handled in the normal case. See comments "
19101930 " around this assert." );
19111931 }
1932+ return PPCAsmPrinter::emitInstruction (MI);
19121933}
19131934
19141935void PPCLinuxAsmPrinter::emitStartOfAsmFile (Module &M) {
0 commit comments