[all-commits] [llvm/llvm-project] 1fd23a: [LangRef] Add elementtype attribute

Nikita Popov via All-commits all-commits at lists.llvm.org
Thu Jul 15 09:04:43 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1fd23a065bf729836dd52ef1ad3c84c449735a56
      https://github.com/llvm/llvm-project/commit/1fd23a065bf729836dd52ef1ad3c84c449735a56
  Author: Nikita Popov <nikita.ppv at gmail.com>
  Date:   2021-07-15 (Thu, 15 Jul 2021)

  Changed paths:
    M llvm/docs/LangRef.rst

  Log Message:
  -----------
  [LangRef] Add elementtype attribute

This adds an elementtype(<ty>) attribute, which can be used to
attach an element type to a pointer typed argument. It is similar
to byval/byref in purpose, but unlike those does not carry any
specific semantics by itself. However, certain intrinsics may
require it and interpret it in specific ways.

The in-tree use cases for this that I'm currently aware of are:

    call ptr @llvm.preserve.array.access.index.p0.p0(ptr elementtype(%ty) %base, i32 %dim, i32 %index)
    call ptr @llvm.preserve.struct.access.index.p0.p0(ptr elementtype(%ty) %base, i32 %gep_index, i32 %di_index)
    call token @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr elementtype(void ()) @foo, i32 0, i32 0, i32 0, i32 0, ptr addrspace(1) %obj)

Notably, the gc.statepoint case needs a function as element type,
in which case the workaround of adding a separate %ty undef
argument would not work, as arguments cannot be unsized.

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


  Commit: c191035f421b5dc69873cba8885fee41e984cc5d
      https://github.com/llvm/llvm-project/commit/c191035f421b5dc69873cba8885fee41e984cc5d
  Author: Nikita Popov <nikita.ppv at gmail.com>
  Date:   2021-07-15 (Thu, 15 Jul 2021)

  Changed paths:
    M llvm/include/llvm/AsmParser/LLToken.h
    M llvm/include/llvm/Bitcode/LLVMBitCodes.h
    M llvm/include/llvm/IR/Attributes.h
    M llvm/include/llvm/IR/Attributes.td
    M llvm/lib/AsmParser/LLLexer.cpp
    M llvm/lib/Bitcode/Reader/BitcodeReader.cpp
    M llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
    M llvm/lib/IR/Attributes.cpp
    M llvm/lib/IR/Verifier.cpp
    M llvm/lib/Transforms/Utils/CodeExtractor.cpp
    M llvm/test/Bitcode/attributes.ll
    A llvm/test/Verifier/elementtype.ll
    M llvm/test/Verifier/opaque-ptr.ll

  Log Message:
  -----------
  [IR] Add elementtype attribute

This implements the elementtype attribute specified in D105407. It
just adds the attribute and the specified verifier rules, but
doesn't yet make use of it anywhere.

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


Compare: https://github.com/llvm/llvm-project/compare/04b75c05b033...c191035f421b


More information about the All-commits mailing list