[PATCH] D156272: [AArch64] [XRay] Account for XRay event instrs in Branch Relaxation

Daniel Hoekwater via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 25 15:55:44 PDT 2023


dhoekwater created this revision.
dhoekwater added reviewers: paquette, MaskRay.
Herald added subscribers: hiraditya, kristof.beyls, dberris.
Herald added a project: All.
dhoekwater requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

PATCHABLE_TYPED_EVENT_CALL and PATCHABLE_EVENT_CALL are pseudo
instructions that expand to XRay sleds, so getInstSizeInBytes
should reflect the size of the sleds, not the pseudo-instructions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156272

Files:
  llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
  llvm/test/CodeGen/AArch64/branch-relax-xray.ll


Index: llvm/test/CodeGen/AArch64/branch-relax-xray.ll
===================================================================
--- llvm/test/CodeGen/AArch64/branch-relax-xray.ll
+++ llvm/test/CodeGen/AArch64/branch-relax-xray.ll
@@ -39,4 +39,19 @@
 }
 
 declare i32 @bar()
-declare i32 @baz()
\ No newline at end of file
+declare i32 @baz()
+
+;; Construct call site entries for PATCHABLE_EVENT_CALL.
+; DBG:      DW_TAG_subprogram
+; DBG:      DW_AT_name
+; DBG-SAME:            ("customevent")
+; DBG:        DW_TAG_call_site
+; DBG-NEXT:     DW_AT_call_target (DW_OP_reg0 {{.*}})
+; DBG-NEXT:     DW_AT_call_return_pc
+; DBG-EMPTY:
+; DBG:        DW_TAG_call_site
+; DBG-NEXT:     DW_AT_call_target (DW_OP_reg2 {{.*}})
+; DBG-NEXT:     DW_AT_call_return_pc
+
+declare void @llvm.xray.customevent(ptr, i64)
+declare void @llvm.xray.typedevent(i64, ptr, i64)
Index: llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
===================================================================
--- llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
+++ llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
@@ -79,6 +79,7 @@
 unsigned AArch64InstrInfo::getInstSizeInBytes(const MachineInstr &MI) const {
   const MachineBasicBlock &MBB = *MI.getParent();
   const MachineFunction *MF = MBB.getParent();
+  const Function &F = MF->getFunction();
   const MCAsmInfo *MAI = MF->getTarget().getMCAsmInfo();
 
   {
@@ -127,10 +128,17 @@
       NumBytes = 4;
     break;
   case TargetOpcode::PATCHABLE_FUNCTION_ENTER:
+    NumBytes =
+        F.getFnAttributeAsParsedInteger("patchable-function-entry", 9) * 4;
+    break;
   case TargetOpcode::PATCHABLE_FUNCTION_EXIT:
+  case TargetOpcode::PATCHABLE_TYPED_EVENT_CALL:
     // An XRay sled can be 4 bytes of alignment plus a 32-byte block.
     NumBytes = 36;
     break;
+  case TargetOpcode::PATCHABLE_EVENT_CALL:
+    NumBytes = 24;
+    break;
 
   case AArch64::SPACE:
     NumBytes = MI.getOperand(1).getImm();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156272.544133.patch
Type: text/x-patch
Size: 1929 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230725/ff40b75e/attachment.bin>


More information about the llvm-commits mailing list