[PATCH] D129016: [PowerPC] implemented @llvm.ppc.kill.canary to corrupt stack guard

Kai Nacke via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 5 06:55:22 PDT 2022


Kai added a comment.

Did you consider to make this more generalized? From skimming through the change, I see only 2 ppc-specific things:

- Loading of the canary word
- Value of `XORWord`

The first bullet is solved by the the other inline comment I made.
The second bullet can be solved by using all 64 bits. If a 32 bit value is used, the upper bits are ignored because the `VT` should be `MVT::i32` in this case.



================
Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:11154-11156
+    GlobalValue *GV = (Subtarget.isAIXABI())
+                          ? M->getGlobalVariable(AIXSSPCanaryWordName)
+                          : M->getNamedValue("__stack_chk_guard");
----------------
I think this can be simplified using `getSDagStackGuard()`.


================
Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:11157
+                          : M->getNamedValue("__stack_chk_guard");
+    if (GV == nullptr) { // linux uses LOAD_STACK_GUARD node instead of having a
+                         // canary word global value
----------------
pscoro wrote:
> Addressing a comment from the previous review, GV != nullptr can not be an assert because linux implements stack guard loading differently than aix. This review now also supports linux as well
You can simplify the code by reordering the conditions:


```
if (useLoadStackGuardNode()) {
  // LOAD_STACK_GUARD
} else if (Value *GV = getSDagStackGuard(M)) {
  // AIX implementation
} else
  llvm_unreachable("Unhandled stack guard case");
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129016



More information about the cfe-commits mailing list