[PATCH] D84414: [RISCV] Support Shadow Call Stack
Fangrui Song via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 23 12:42:47 PDT 2020
MaskRay added inline comments.
================
Comment at: llvm/lib/Target/RISCV/RISCVFrameLowering.cpp:33-37
+ std::vector<CalleeSavedInfo> &CSI = MF.getFrameInfo().getCalleeSavedInfo();
+ if (std::none_of(CSI.begin(), CSI.end(), [](CalleeSavedInfo &CSR) {
+ return CSR.getReg() == RISCV::X1;
+ }))
+ return;
----------------
jrtc27 wrote:
> ```
> if (find(CSI, RISCV::X1) == CSI.end())
> return;
> ```
> (using `llvm::find` as a convenient wrapper around `std::find`, ie shorthand for `std::find(CSI.begin(), CSI.end(), RISCV::X1)`). Though personally I'd prefer to see X1 come from `RI.getRARegister()` rather than be hard-coded; other functions in this file already hard-code it, but in our CHERI fork we need to replace RISCV::X1 with RISCV::C1 everywhere so have changed those. Having said that, CHERI renders a shadow call stack unnecessary, so I don't particularly care if it's broken there, personally. But I still think it's nicer code.
`!llvm::is_contained(CSI, RISCV::X1)`
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D84414/new/
https://reviews.llvm.org/D84414
More information about the cfe-commits
mailing list