[PATCH] D66012: [AArch64][Statepoints] Statepoint support for AArch64.

Loïc Ottet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 8 07:12:58 PST 2019


loicottet marked 3 inline comments as done.
loicottet added inline comments.


================
Comment at: llvm/lib/CodeGen/SelectionDAG/InstrEmitter.cpp:816-819
+  // Handle STACKMAP, PATCHPOINT and STATEPOINT specially and then use the
+  // generic code.
+  if (Opc == TargetOpcode::STACKMAP || Opc == TargetOpcode::PATCHPOINT ||
+      Opc == TargetOpcode::STATEPOINT) {
----------------
reames wrote:
> kristof.beyls wrote:
> > It seems strange to me that adding AArch64-target specific support (the purpose of this patch, I presume) needs a generic target-independent change like this.
> > If this is a bug in the target-independent part of statepoint support, I think it'd be best to split this off as a separate patch, with a regression tests demonstrating this issue on a target that already supports statepoints (which I presume is only x86_64 today).
> This does not look correct to me.  I'd definitely demand to see a separate patch with a clear test case justifying this.  
This has indeed nothing to do here. I removed it.


================
Comment at: llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp:445-447
     OutStreamer->EmitAssemblerFlag(MCAF_SubsectionsViaSymbols);
-    emitStackMaps(SM);
   }
+  emitStackMaps(SM);
----------------
reames wrote:
> kristof.beyls wrote:
> > If I understand the semantics of this change, the goal is to emit stack maps not only for MachO targets, but for all targets, such as those using ELF or COFF.
> > This implies that stack maps are not supported for ELF AArch64. According to documentation at https://llvm.org/docs/StackMaps.html stackmaps are also needed for supporting stackmap and patchpoint intrinsics.
> > In the spirit of incremental development, I wonder if it'd be possible to again split this off as a separate patch, introducing stackmap support?
> > I guess to do that, also support for patchpoint and stackmap intrinsics for ELF (and COFF?) targeting AArch64 may be needed, which may be non-trivial? OTOH, it seems those are already supported for MachO AArch64, so maybe it'd be a relatively small/simple thing to do in a separate patch?
> > Do you intend to also support COFF, or only add support for ELF here? If so, the emitStackMaps may still need to be guarded by an if-condition?
> I agree on the separable patch bit.  I think this is pretty straight forward, but a simple test and one line patch would be good.  
I've been able to use statepoint and stackmap intrinsics and emit stack maps using these changes without trouble (for ELF at least). From the git history, it appears that the stack map was originally emitted for all object file formats until the MachO hack was added in be1d1b66. It looks like the stack map emission was included in it by mistake. I'll open a separate patch to fix this.


================
Comment at: llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp:779
         MII->getOpcode() == AArch64::DBG_VALUE ||
+        MII->getOpcode() == TargetOpcode::STATEPOINT ||
         MII->getOpcode() == TargetOpcode::PATCHPOINT ||
----------------
reames wrote:
> This is wrong.  STACKMAP and PATCHPOINT are destructive patching.  STATEPOINT assumes non-destuctive patching.  (i.e. no shadow region, nops explicitly supported and likely replaced before the code ever runs)
Reverted. I misunderstood the patching behaviours of the intrinsics.


================
Comment at: llvm/lib/Target/AArch64/AArch64FrameLowering.cpp:2227-2240
+  if (IgnoreSPUpdates) {
+    /// For Win64 AArch64 EH, the offset to the Unwind object is from the SP
+    /// before the update. This is easily retrieved as it is exactly the offset
+    /// that is set in processFunctionBeforeFrameFinalized.
+    const MachineFrameInfo &MFI = MF.getFrameInfo();
+    LLVM_DEBUG(dbgs() << "Offset from the SP for " << FI << " is "
+                      << MFI.getObjectOffset(FI) << "\n");
----------------
Should this bugfix be part of a separate patch or is it ok to leave it in this PR as it enables correct statepoint operation?


================
Comment at: llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp:185-188
+  case Intrinsic::experimental_gc_statepoint:
+    if ((Idx < 5) || (Imm.getBitWidth() <= 64 && isInt<64>(Imm.getSExtValue())))
+      return TTI::TCC_Free;
+    break;
----------------
Not sure about this, I'd appreciate if someone could confirm this is the way to do it.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66012/new/

https://reviews.llvm.org/D66012





More information about the llvm-commits mailing list