[PATCH] D138757: [zero-call-used-regs] Mark only non-debug instruction's register as used
Shivam Gupta via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 27 05:40:51 PST 2022
xgupta created this revision.
xgupta added reviewers: probinson, dblaikie, void, nickdesaulniers.
Herald added a subscriber: hiraditya.
Herald added a project: All.
xgupta requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
zero-call-used-regs pass generate an xor instruction to help mitigate
return-oriented programming exploits via zeroing out used registers. But
in this below test case with -g option there is dbg.value instruction
associating the register with the debug-info description of the formal
parameter d, which makes the register appear used, therefore it zero the
register edi in -g case and makes binary different from without -g option.
The pass should be looking only at the non-debug uses.
$ cat test.c
char a[];
int b;
__attribute__((zero_call_used_regs("used"))) char c(int d) {
*a = ({
int e = d;
b;
});
}
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D138757
Files:
llvm/lib/CodeGen/PrologEpilogInserter.cpp
Index: llvm/lib/CodeGen/PrologEpilogInserter.cpp
===================================================================
--- llvm/lib/CodeGen/PrologEpilogInserter.cpp
+++ llvm/lib/CodeGen/PrologEpilogInserter.cpp
@@ -1234,6 +1234,9 @@
if (!MO.isReg())
continue;
+ if (MI.isDebugInstr())
+ continue;
+
MCRegister Reg = MO.getReg();
if (AllocatableSet[Reg] && !MO.isImplicit() &&
(MO.isDef() || MO.isUse()))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138757.478090.patch
Type: text/x-patch
Size: 485 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221127/9261267c/attachment.bin>
More information about the llvm-commits
mailing list