[llvm] [CodeGen] Use byte offsets and ptradd in ShadowStackGCLowering (PR #178436)

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 8 02:05:11 PDT 2026


isuckatcs wrote:

Hmm, it looks like this intrinsic is documented at 2 different places.

1. https://llvm.org/docs/GarbageCollection.html#using-llvm-gcwrite
2. https://llvm.org/docs/LangRef.html#llvm-gcroot-intrinsic

> a call to this intrinsic stores a null pointer into the “ptrloc” location

Well, it is no longer true as of #199367. We should probably update that section. I still wonder if storing a pointer is the right thing to do though.

In the second doc, the arguments section says the following:

> The first argument specifies the address of a stack object that contains the root pointer.

To be fair, it says a stack object that **contains** the root pointer, not a stack object that **is** the root pointer.

The GCLoweringPass also [treats the allocas themselves as the roots](https://github.com/llvm/llvm-project/blob/9f5548da33ffdb282225bc03e17c0702c4c31884/llvm/lib/CodeGen/GCRootLowering.cpp#L236), while with this change the shadow-stack strategy no longer does, so the 2 passes are not in synch anymore.

> and has many limitations like exactly that baked in the design

It was this change that baked it in, didn't it? Non-pointer roots worked perfectly fine before it. The example snippet I wrote is accepted before LLVM 23. Even in 23 it is not rejected, just miscompiles IIUC (there is 1 call to `@llvm.gcroot`, yet we end up with 2 roots) .

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


More information about the llvm-commits mailing list