Revert "Reland [AArch64][MachineOutliner] Return address signing for outlined functions"
authorOliver Stannard <oliver.stannard@linaro.org>
Wed, 11 Dec 2019 12:03:12 +0000 (12:03 +0000)
committerOliver Stannard <oliver.stannard@linaro.org>
Wed, 11 Dec 2019 12:06:20 +0000 (12:06 +0000)
commit6ae3d310bd94a338f2c121b19e7995dc72ca46dc
treec2e7f00c74567d9c6f462f6270449b75455ddc34
parent1fed9a0c0c3e74c21dfbd1edf18411a33b742f52
Revert "Reland [AArch64][MachineOutliner] Return address signing for outlined functions"

This reverts commit cec2d5c17457722113580251c8a045fa9aca9b1b.

Reverting because this is still creating outlined functions with return
address signing instructions with mismatches SP values. For example:

  int *volatile v;

  void foo(int x) {
    int a[x];
    v = &a[0];
    v = &a[0];
    v = &a[0];
    v = &a[0];
    v = &a[0];
    v = &a[0];
  }

  void bar(int x) {
    int a[x];
    v = 0;
    v = &a[0];
    v = &a[0];
    v = &a[0];
    v = &a[0];
    v = &a[0];
  }

This generates these two outlined functions, both of which modify SP
between the paciasp and retaa instructions:

  $ clang --target=aarch64-arm-none-eabi -march=armv8.3-a -c test2.c -o - -S -Oz -mbranch-protection=pac-ret+leaf
  ...
  OUTLINED_FUNCTION_0:                    // @OUTLINED_FUNCTION_0
          .cfi_sections .debug_frame
          .cfi_startproc
  // %bb.0:
          paciasp
          .cfi_negate_ra_state
          mov     w8, w0
          lsl     x8, x8, #2
          add     x8, x8, #15             // =15
          mov     x9, sp
          and     x8, x8, #0x7fffffff0
          sub     x8, x9, x8
          mov     x29, sp
          mov     sp, x8
          adrp    x9, v
          retaa
  ...
  OUTLINED_FUNCTION_1:                    // @OUTLINED_FUNCTION_1
          .cfi_startproc
  // %bb.0:
          paciasp
          .cfi_negate_ra_state
          str     x8, [x9, :lo12:v]
          str     x8, [x9, :lo12:v]
          str     x8, [x9, :lo12:v]
          str     x8, [x9, :lo12:v]
          str     x8, [x9, :lo12:v]
          mov     sp, x29
          retaa
12 files changed:
llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-cfi.ll [deleted file]
llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-diff-scope-same-key.ll [deleted file]
llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-non-leaf.ll [deleted file]
llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-regsave.mir [deleted file]
llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-same-scope-diff-key.ll [deleted file]
llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-same-scope-same-key-a.ll [deleted file]
llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-same-scope-same-key-b.ll [deleted file]
llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-sp-mod.mir [deleted file]
llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-subtarget.ll [deleted file]
llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-thunk.ll [deleted file]
llvm/test/CodeGen/AArch64/machine-outliner-retaddr-sign-v8-3.ll [deleted file]