[all-commits] [llvm/llvm-project] 22467e: Add function attribute "patchable-function-prefix"...

Fangrui Song via All-commits all-commits at lists.llvm.org
Thu Jan 23 17:03:04 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 22467e259507f5ead2a87d989251b4c951a587e4
      https://github.com/llvm/llvm-project/commit/22467e259507f5ead2a87d989251b4c951a587e4
  Author: Fangrui Song <maskray at google.com>
  Date:   2020-01-23 (Thu, 23 Jan 2020)

  Changed paths:
    M llvm/include/llvm/CodeGen/AsmPrinter.h
    M llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
    M llvm/lib/IR/Verifier.cpp
    M llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
    M llvm/lib/Target/ARM/ARMMCInstLower.cpp
    M llvm/test/CodeGen/AArch64/patchable-function-entry-bti.ll
    M llvm/test/CodeGen/AArch64/patchable-function-entry.ll
    M llvm/test/Verifier/invalid-patchable-function-entry.ll

  Log Message:
  -----------
  Add function attribute "patchable-function-prefix" to support -fpatchable-function-entry=N,M where M>0

Similar to the function attribute `prefix` (prefix data),
"patchable-function-prefix" inserts data (M NOPs) before the function
entry label.

-fpatchable-function-entry=2,1 (1 NOP before entry, 1 NOP after entry)
will look like:

```
  .type	foo, at function
.Ltmp0:               # @foo
  nop
foo:
.Lfunc_begin0:
  # optional `bti c` (AArch64 Branch Target Identification) or
  # `endbr64` (Intel Indirect Branch Tracking)
  nop

  .section  __patchable_function_entries,"awo", at progbits,get,unique,0
  .p2align  3
  .quad .Ltmp0
```

-fpatchable-function-entry=N,0 + -mbranch-protection=bti/-fcf-protection=branch has two reasonable
placements (https://gcc.gnu.org/ml/gcc-patches/2020-01/msg01185.html):

```
(a)         (b)

func:       func:
.Ltmp0:     bti c
  bti c     .Ltmp0:
  nop       nop
```

(a) needs no additional code. If the consensus is to go for (b), we will
need more code in AArch64BranchTargets.cpp / X86IndirectBranchTracking.cpp .

Differential Revision: https://reviews.llvm.org/D73070


  Commit: 01da05b71aa72c15a518d3407682a3775db63808
      https://github.com/llvm/llvm-project/commit/01da05b71aa72c15a518d3407682a3775db63808
  Author: Fangrui Song <maskray at google.com>
  Date:   2020-01-23 (Thu, 23 Jan 2020)

  Changed paths:
    A llvm/test/CodeGen/X86/patchable-function-entry-ibt.ll
    M llvm/test/CodeGen/X86/patchable-function-entry.ll

  Log Message:
  -----------
  [X86][test] Add tests for -fpatchable-function-entry=N,M (where M>0) and its interaction with -fcf-protection=branch

Reviewed By: nickdesaulniers

Differential Revision: https://reviews.llvm.org/D73071


  Commit: 69bf40c45fd7f6dfe11b47de42571d8bff5ef94f
      https://github.com/llvm/llvm-project/commit/69bf40c45fd7f6dfe11b47de42571d8bff5ef94f
  Author: Fangrui Song <maskray at google.com>
  Date:   2020-01-23 (Thu, 23 Jan 2020)

  Changed paths:
    M clang/include/clang/Basic/AttrDocs.td
    M clang/include/clang/Basic/CodeGenOptions.def
    M clang/include/clang/Basic/DiagnosticDriverKinds.td
    M clang/include/clang/Driver/CC1Options.td
    M clang/include/clang/Driver/Options.td
    M clang/lib/CodeGen/CodeGenFunction.cpp
    M clang/lib/Driver/ToolChains/Clang.cpp
    M clang/lib/Frontend/CompilerInvocation.cpp
    M clang/lib/Sema/SemaDeclAttr.cpp
    M clang/test/CodeGen/patchable-function-entry.c
    M clang/test/Driver/fpatchable-function-entry.c
    M clang/test/Sema/patchable-function-entry-attr.c

  Log Message:
  -----------
  [Driver][CodeGen] Support -fpatchable-function-entry=N,M and __attribute__((patchable_function_entry(N,M))) where M>0

Reviewed By: nickdesaulniers

Differential Revision: https://reviews.llvm.org/D73072


Compare: https://github.com/llvm/llvm-project/compare/f394d22fa82d...69bf40c45fd7


More information about the All-commits mailing list