[clang] [llvm] [PowerPC] Support -fpatchable-function-entry (PR #92997)

Nick Desaulniers via llvm-commits llvm-commits at lists.llvm.org
Wed May 22 10:03:58 PDT 2024


================
@@ -909,6 +909,24 @@ void PPCAsmPrinter::emitInstruction(const MachineInstr *MI) {
   // Lower multi-instruction pseudo operations.
   switch (MI->getOpcode()) {
   default: break;
+  case TargetOpcode::PATCHABLE_FUNCTION_ENTER: {
+    assert(!Subtarget->isAIXABI() &&
+           "AIX does not support patchable function entry!");
+    // PATCHABLE_FUNCTION_ENTER on little endian is for XRAY support which is
+    // handled in PPCLinuxAsmPrinter.
+    if (MAI->isLittleEndian())
+      return;
+    const Function &F = MI->getParent()->getParent()->getFunction();
+    if (F.hasFnAttribute("patchable-function-entry")) {
+      unsigned Num = 0;
+      if (F.getFnAttribute("patchable-function-entry")
----------------
nickdesaulniers wrote:

I think you can also just call getFnAttribute then check isValid on the result.

https://github.com/llvm/llvm-project/pull/92997


More information about the llvm-commits mailing list