[all-commits] [llvm/llvm-project] 745443: [zero-call-used-regs] Mark only non-debug instruct...

Shivam Gupta via All-commits all-commits at lists.llvm.org
Tue Jan 24 21:33:51 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 7454439674a4a78b9fc9dc9ffba7a60717ee310b
      https://github.com/llvm/llvm-project/commit/7454439674a4a78b9fc9dc9ffba7a60717ee310b
  Author: Shivam Gupta <shivam98.tkg at gmail.com>
  Date:   2023-01-25 (Wed, 25 Jan 2023)

  Changed paths:
    M llvm/lib/CodeGen/PrologEpilogInserter.cpp
    A llvm/test/CodeGen/X86/zero-call-used-regs-debug-info.mir

  Log Message:
  -----------
  [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




More information about the All-commits mailing list