[all-commits] [llvm/llvm-project] 93164d: [llvm][AArch64] Fix BTI after returns_twice when c...

David Spickett via All-commits all-commits at lists.llvm.org
Wed Feb 15 07:30:51 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 93164dba086df98d50bccf210e3e65115342c483
      https://github.com/llvm/llvm-project/commit/93164dba086df98d50bccf210e3e65115342c483
  Author: David Spickett <david.spickett at linaro.org>
  Date:   2023-02-15 (Wed, 15 Feb 2023)

  Changed paths:
    M llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
    M llvm/lib/Target/AArch64/GISel/AArch64CallLowering.cpp
    M llvm/test/CodeGen/AArch64/setjmp-bti.ll

  Log Message:
  -----------
  [llvm][AArch64] Fix BTI after returns_twice when call has no attributes

Previously we were looking for the returns twice attribute by manually
getting the function attributes from the call. This meant that we only
found attributes on the call itself, not what it was calling.

So if you had:
%call1 = call i32 @setjmp(ptr noundef null)

We would not BTI protect that even though setjmp clearly needs it.

Clang happens to produce:
%call = call i32 @setjmp(ptr noundef null) #0 ; returns_twice

So all valid calls were protected. This is not guaranteed,
the frontend may choose not to put attributes on the call.

It is undefined behaviour to call setjmp indirectly
(https://pubs.opengroup.org/onlinepubs/9699919799/functions/setjmp.html)
but as I misused the APIs here I think it's worth fixing up regardless.

Added comments to the test file where the IR differs from what
clang would output.

Reviewed By: nikic

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




More information about the All-commits mailing list