[all-commits] [llvm/llvm-project] 506276: [XRay] Set hasSideEffects flag of PATCHABLE_FUNCTI...

Fangrui Song via All-commits all-commits at lists.llvm.org
Fri Jan 24 10:39:12 PST 2020


  Branch: refs/heads/release/10.x
  Home:   https://github.com/llvm/llvm-project
  Commit: 50627622856e631bd522cefd84efe2c8070ef75e
      https://github.com/llvm/llvm-project/commit/50627622856e631bd522cefd84efe2c8070ef75e
  Author: Fangrui Song <maskray at google.com>
  Date:   2020-01-24 (Fri, 24 Jan 2020)

  Changed paths:
    M llvm/include/llvm/Target/Target.td

  Log Message:
  -----------
  [XRay] Set hasSideEffects flag of PATCHABLE_FUNCTION_{ENTER,EXIT}

Otherwise they may be picked as the delay slot by mips-delay-slot-filler, if we move patchable-function before mips-delay-slot-filler.

(cherry picked from commit a72d15e37c5e066f597f13a8ba60aff214ac992d)


  Commit: 6c1e479db225897cbbff7894ffe77824c03ab8fd
      https://github.com/llvm/llvm-project/commit/6c1e479db225897cbbff7894ffe77824c03ab8fd
  Author: Fangrui Song <maskray at google.com>
  Date:   2020-01-24 (Fri, 24 Jan 2020)

  Changed paths:
    M llvm/lib/CodeGen/TargetPassConfig.cpp
    M llvm/test/CodeGen/AArch64/O0-pipeline.ll
    M llvm/test/CodeGen/AArch64/O3-pipeline.ll
    A llvm/test/CodeGen/AArch64/patchable-function-entry-bti.ll
    M llvm/test/CodeGen/ARM/O3-pipeline.ll
    M llvm/test/CodeGen/X86/O0-pipeline.ll
    M llvm/test/CodeGen/X86/O3-pipeline.ll

  Log Message:
  -----------
  [CodeGen] Move fentry-insert, xray-instrumentation and patchable-function before addPreEmitPass()

This intention is to move patchable-function before aarch64-branch-targets
(configured in AArch64PassConfig::addPreEmitPass) so that we emit BTI before NOPs
(see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92424).

This also allows addPreEmitPass() passes to know the precise instruction sizes if they want.

Tried x86-64 Debug/Release builds of ccls with -fxray-instrument -fxray-instruction-threshold=1.
No output difference with this commit and the previous commit.

(cherry picked from commit 9a24488cb67a90f889529987275c5e411ce01dda)


  Commit: 0e2eea29cc4f360fc95638fbfc8aca24cec3fc5f
      https://github.com/llvm/llvm-project/commit/0e2eea29cc4f360fc95638fbfc8aca24cec3fc5f
  Author: Fangrui Song <i at maskray.me>
  Date:   2020-01-24 (Fri, 24 Jan 2020)

  Changed paths:
    M llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
    M llvm/test/CodeGen/AArch64/patchable-function-entry-bti.ll
    M llvm/test/CodeGen/AArch64/patchable-function-entry.ll
    M llvm/test/CodeGen/X86/patchable-function-entry.ll

  Log Message:
  -----------
  [AsmPrinter] Don't emit __patchable_function_entries entry if "patchable-function-entry"="0"

Add improve tests

(cherry picked from commit d232c215669cb57f5eb4ead40a4a336220dbc429)


  Commit: bf04730dee1b74c8e7661c671484eff93c1f5a77
      https://github.com/llvm/llvm-project/commit/bf04730dee1b74c8e7661c671484eff93c1f5a77
  Author: Fangrui Song <maskray at google.com>
  Date:   2020-01-24 (Fri, 24 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

(cherry picked from commit 22467e259507f5ead2a87d989251b4c951a587e4)


  Commit: 6f4edc606b2088bcac066640d5107d2042c203c1
      https://github.com/llvm/llvm-project/commit/6f4edc606b2088bcac066640d5107d2042c203c1
  Author: Fangrui Song <maskray at google.com>
  Date:   2020-01-24 (Fri, 24 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

(cherry picked from commit 01da05b71aa72c15a518d3407682a3775db63808)


  Commit: 5d1fe1a1a9f18c5009e9e282b755e52c5e7ce5a2
      https://github.com/llvm/llvm-project/commit/5d1fe1a1a9f18c5009e9e282b755e52c5e7ce5a2
  Author: Fangrui Song <maskray at google.com>
  Date:   2020-01-24 (Fri, 24 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

(cherry picked from commit 69bf40c45fd7f6dfe11b47de42571d8bff5ef94f)


  Commit: 4d5a200f31d565cf7762a3cde30375f5d8a309c6
      https://github.com/llvm/llvm-project/commit/4d5a200f31d565cf7762a3cde30375f5d8a309c6
  Author: Fangrui Song <maskray at google.com>
  Date:   2020-01-24 (Fri, 24 Jan 2020)

  Changed paths:
    M llvm/lib/CodeGen/PatchableFunction.cpp
    A llvm/test/CodeGen/AArch64/patchable-function-entry-empty.mir

  Log Message:
  -----------
  [PatchableFunction] Allow empty entry MachineBasicBlock

Reviewed By: nickdesaulniers

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

(cherry picked from commit 50a3ff30e1587235d1830fec9694c1239302ab9f)


Compare: https://github.com/llvm/llvm-project/compare/39c349e8fc7f...4d5a200f31d5


More information about the All-commits mailing list