[zero-call-used-regs] Mark only non-debug instruction's register as used
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;
});
}
This fixes https://github.com/llvm/llvm-project/issues/57962.
Differential Revision: https://reviews.llvm.org/D138757