[all-commits] [llvm/llvm-project] dfcf69: [X86] Fix fentry handling in X86IndirectBranchTrac...

João Moreira via All-commits all-commits at lists.llvm.org
Mon Dec 6 20:10:20 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: dfcf69770bc522b9e411c66454934a37c1f35332
      https://github.com/llvm/llvm-project/commit/dfcf69770bc522b9e411c66454934a37c1f35332
  Author: Joao Moreira <joao.moreira at intel.com>
  Date:   2021-12-07 (Tue, 07 Dec 2021)

  Changed paths:
    M llvm/lib/Target/X86/X86IndirectBranchTracking.cpp
    A llvm/test/CodeGen/X86/fentry-ibt.ll

  Log Message:
  -----------
  [X86] Fix fentry handling in X86IndirectBranchTracking.cpp

When compiling with indirect branch tracking and fentry (-fcf-protection=branch -mfentry -pg) the X86IndirectBranchTrackingPass will attempt to place endbr in basic blocks, checking for Calls/IsCallReturnTwice. For calling the function IsCallReturnTwice(), the pass attempts to retrieve the first operand of the respective machine instruction. Since FENTRY_CALL is considered a call, and it does not have any argument, the condition inside the pass will attempt to call IsCallReturnTwice on the machine instruction, but since it does not have operands, it will lead into a crash.

Kudos to Alyssa Milburn for helping in the issue triage. The diff brings a test, but to reproduce the problem, follow the steps below.

```
echo "int main() {};" > repro.c
clang repro.c -fcf-protection=branch -mfentry -pg
```

Reviewed By: craig.topper

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




More information about the All-commits mailing list