[PATCH] D129505: [GISel] Check useLoadStackGuardNode() before generating LOAD_STACK_GUARD

Kai Nacke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 11 14:05:39 PDT 2022


Kai added inline comments.


================
Comment at: llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp:2083
+    if (TLI.useLoadStackGuardNode()) {
+      GuardVal = MRI->createGenericVirtualRegister(PtrTy);
+      getStackGuard(GuardVal, MIRBuilder);
----------------
arsenm wrote:
> Kai wrote:
> > arsenm wrote:
> > > Don't see why getStackGuard doesn't just return the virtual register it creates itself
> > Sorry, do you mean that getStackGuard() should create the virtual register? Currently it uses the register passed as argument.
> > I guess that should work as LLVM always uses a pointer as type for the stack guard value.
> Yes. These APIs that take output registers are a bit awkward
That is not as trivial as it seems.
In `emitSPDescriptorParent()`, the type of the guard value is deliberately changed to a scalar similar in size of a pointer, to match the type of the `G_LOAD` instruction loading the guard value from the stack slot. 
That is very nicely demonstrated in test case AArch64/GlobalISel/irtranslator-delayed-stack-protector.ll.
I can make this change but I would prefer to do it in a separate change, as it is really a different goal ("unifying use of getStackGuard()").


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

https://reviews.llvm.org/D129505



More information about the llvm-commits mailing list