[all-commits] [llvm/llvm-project] 924a1d: [Dwarf] Support `__ptrauth` qualifier in metadata ...

Daniil Kovalev via All-commits all-commits at lists.llvm.org
Mon Mar 18 23:13:40 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 924a1dceb59944fa9051acbbb7d2daac129ee0ef
      https://github.com/llvm/llvm-project/commit/924a1dceb59944fa9051acbbb7d2daac129ee0ef
  Author: Daniil Kovalev <dkovalev at accesssoftek.com>
  Date:   2024-03-19 (Tue, 19 Mar 2024)

  Changed paths:
    M llvm/include/llvm/IR/DIBuilder.h
    M llvm/include/llvm/IR/DebugInfoMetadata.h
    M llvm/lib/AsmParser/LLParser.cpp
    M llvm/lib/Bitcode/Reader/MetadataLoader.cpp
    M llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
    M llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
    M llvm/lib/IR/AsmWriter.cpp
    M llvm/lib/IR/DIBuilder.cpp
    M llvm/lib/IR/DebugInfo.cpp
    M llvm/lib/IR/DebugInfoMetadata.cpp
    M llvm/lib/IR/LLVMContextImpl.h
    M llvm/lib/IR/Verifier.cpp
    M llvm/test/Assembler/debug-info.ll
    A llvm/test/DebugInfo/AArch64/ptrauth.ll
    M llvm/unittests/IR/MetadataTest.cpp
    M mlir/lib/Target/LLVMIR/DebugTranslation.cpp

  Log Message:
  -----------
  [Dwarf] Support `__ptrauth` qualifier in metadata nodes (#83862)

Reland #82363 after fixing build failure
https://lab.llvm.org/buildbot/#/builders/5/builds/41428.

Memory sanitizer detects usage of `RawData` union member which is not
filled directly. Instead, the code relies on filling `Data` union
member, which is a struct consisting of signing schema parameters.

According to https://en.cppreference.com/w/cpp/language/union, this is
UB:
"It is undefined behavior to read from the member of the union that
wasn't most recently written".

Instead of relying on compiler allowing us to do dirty things, do not
use union and only store `RawData`. Particular ptrauth parameters are
obtained on demand via bit operations.

Original PR description below.

Emit `__ptrauth`-qualified types as `DIDerivedType` metadata nodes in IR
with tag `DW_TAG_LLVM_ptrauth_type`, baseType referring to the type
which has the qualifier applied, and the following parameters
representing the signing schema:

- `ptrAuthKey` (integer)
- `ptrAuthIsAddressDiscriminated` (boolean)
- `ptrAuthExtraDiscriminator` (integer)
- `ptrAuthIsaPointer` (boolean)
- `ptrAuthAuthenticatesNullValues` (boolean)

Co-authored-by: Ahmed Bougacha <ahmed at bougacha.org>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list