Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LLVM] Make changes needed for opaque pointers #9138

Merged
merged 6 commits into from Sep 29, 2021
Merged

[LLVM] Make changes needed for opaque pointers #9138

merged 6 commits into from Sep 29, 2021

Conversation

kparzysz-quic
Copy link
Contributor

  • Pass value type to all Create.*Load and Create.*GEP functions.
  • Create type TypedPointer to keep both the address and the pointee's type when buffer pointers etc. are created.
  • Eliminate calls to getPointerElementType, except one in creating debug info (that seems necessary for the time being).

- Pass value type to all Create.*Load and Create.*GEP functions.
- Create type TypedPointer to keep both the address and the pointee's
  type when buffer pointers etc. are created.
- Eliminate calls to getPointerElementType, except one in creating
  debug info (that seems necessary for the time being).
@jroesch
Copy link
Member

jroesch commented Sep 29, 2021

Changes over all make sense, is this to prep for another change? was confused about "opaque pointer"

@kparzysz-quic
Copy link
Contributor Author

kparzysz-quic commented Sep 29, 2021

LLVM IR is eliminating types in pointers, so there will only be ptr for a pointer type (i.e. pointers will be "opaque"), instead of i32* or float*. This will require passing pointer type in addition to the pointer itself to a bunch of LLVM IR creation functions, plus functions like getPointerElementType will be removed.

This is an ongoing change in LLVM, but it's a pervasive one with a lot of impact on downstream consumers.

Edit: Link to a document about this effort:
https://github.com/llvm/llvm-project/blob/main/llvm/docs/OpaquePointers.rst

@kparzysz-quic
Copy link
Contributor Author

More changes related to that will be needed, and I'm planning to keep making them as the LLVM IR evolves.

@jroesch
Copy link
Member

jroesch commented Sep 29, 2021

https://github.com/llvm/llvm-project/blob/main/llvm/docs/OpaquePointers.rst

Ah I didn't know about this, is this fallout related to the semantic changes in the IR? I'll check out the docs as well. LGTM thanks for educating me on this one.

@jroesch jroesch merged commit df50fa3 into apache:main Sep 29, 2021
@kparzysz-quic
Copy link
Contributor Author

Since memory in LLVM is generally untyped, specific data types are provided at the time of accessing the memory, or computing addresses. For example getelementptr needs to know the "starting type" (i.e. the type associated with the input pointer) in order to properly calculate the address corresponding to the index arguments. In the past, this information was included in the pointer type, i.e. from i32*, you could easily infer that the pointee was a i32. With this information removed from pointers, these instructions need that detailed type information passed in separately.

The fallout comes from the fact that many functions in LLVM now need the extra type information passed to them. This mostly applies to the IR builder functions, but any code using LLVM may be subject to changes, if it relied on getting pointee type information from the pointer type itself.

@kparzysz-quic kparzysz-quic deleted the llvm-typed-pointer branch September 29, 2021 17:11
AndrewZhaoLuo added a commit to AndrewZhaoLuo/tvm that referenced this pull request Sep 29, 2021
* main:
  Fix flaky NMS test by making sure scores are unique (apache#9140)
  [Relay] Merge analysis/context_analysis.cc and transforms/device_annotation.cc (apache#9038)
  [LLVM] Make changes needed for opaque pointers (apache#9138)
  Arm(R) Ethos(TM)-U NPU codegen integration (apache#8849)
  [CI] Split Integration tests out of first phase of pipeline (apache#9128)
  [Meta Schedule][M3b] Runner (apache#9111)
  Fix Google Mock differences between Ubuntu 18.04 and 16.04 (apache#9141)
  [TIR] add loop partition hint pragma (apache#9121)
  fix things (apache#9146)
  [Meta Schedule][M3a] SearchStrategy (apache#9132)
  [Frontend][PyTorch] support for quantized conv_transpose2d op (apache#9133)
  [UnitTest] Parametrized test_conv2d_int8_intrinsics (apache#9143)
  [OpenCL] Remove redundant visit statement in CodeGen. (apache#9144)
  [BYOC] support arbitrary input dims for add/mul/relu of dnnl c_src codegen (apache#9127)
  [Relay][ConvertLayout] Support for qnn.conv2d_transpose (apache#9139)
  add nn.global_avgpool to fq2i (apache#9137)
  [UnitTests] Enable minimum testing on Vulkan target in CI (apache#9093)
  [Torch] Support returning quantized weights and bias for BYOC use cases (apache#9135)
  [Relay] Prepare for new plan_devices.cc (part II) (apache#9130)
  [microTVM][Zephyr] Add MIMXRT1050 board support (apache#9068)
AndrewZhaoLuo added a commit to AndrewZhaoLuo/tvm that referenced this pull request Sep 30, 2021
* main: (80 commits)
  Introduce centralised name transformation functions (apache#9088)
  [OpenCL] Add vectorization to cuda conv2d_nhwc schedule (apache#8636)
  [6/6] Arm(R) Ethos(TM)-U NPU codegen integration with `tvmc` (apache#8854)
  [microTVM] Add wrapper for creating project using a MLF (apache#9090)
  Fix typo (apache#9156)
  [Hotfix][Testing] Wait for RPCServer to be established (apache#9150)
  Update find cublas so it search default path if needed. (apache#9149)
  [TIR][LowerMatchBuffer] Fix lowering strides when source region has higher dimension than the buffer (apache#9145)
  Fix flaky NMS test by making sure scores are unique (apache#9140)
  [Relay] Merge analysis/context_analysis.cc and transforms/device_annotation.cc (apache#9038)
  [LLVM] Make changes needed for opaque pointers (apache#9138)
  Arm(R) Ethos(TM)-U NPU codegen integration (apache#8849)
  [CI] Split Integration tests out of first phase of pipeline (apache#9128)
  [Meta Schedule][M3b] Runner (apache#9111)
  Fix Google Mock differences between Ubuntu 18.04 and 16.04 (apache#9141)
  [TIR] add loop partition hint pragma (apache#9121)
  fix things (apache#9146)
  [Meta Schedule][M3a] SearchStrategy (apache#9132)
  [Frontend][PyTorch] support for quantized conv_transpose2d op (apache#9133)
  [UnitTest] Parametrized test_conv2d_int8_intrinsics (apache#9143)
  ...
Comment on lines +874 to +877
#if TVM_LLVM_VERSION >= 130
<< llvm::Intrinsic::getBaseName(id).str();
#else
<< llvm::Intrinsic::getName(id, return_type, {});
<< llvm::Intrinsic::getName(id, {});
Copy link
Contributor

@csullivan csullivan Oct 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

release/181/llvm-10.0.0/bin/llvm-config --version
13.0.0

Using a copy of the hexagon llvm libraries from early this summer (rev 181) this now triggers a compile error. Did you mean > 130 instead of >= here?

mehrdadh added a commit to mehrdadh/tvm that referenced this pull request Dec 1, 2021
ylc pushed a commit to ylc/tvm that referenced this pull request Jan 7, 2022
* [LLVM] Make changes needed for opaque pointers

- Pass value type to all Create.*Load and Create.*GEP functions.
- Create type TypedPointer to keep both the address and the pointee's
  type when buffer pointers etc. are created.
- Eliminate calls to getPointerElementType, except one in creating
  debug info (that seems necessary for the time being).

* Fix typo in CodeGenCPU::CreateStructRefPtr

* Fix type extraction in CodeGenLLVM::AddAliasInfo

* Fix types in ramp-1 vector loads/stores

* Fix getting intrinsic name in error message

* Return valid pointer from PackClosureData when no data to pack
ylc pushed a commit to ylc/tvm that referenced this pull request Jan 13, 2022
* [LLVM] Make changes needed for opaque pointers

- Pass value type to all Create.*Load and Create.*GEP functions.
- Create type TypedPointer to keep both the address and the pointee's
  type when buffer pointers etc. are created.
- Eliminate calls to getPointerElementType, except one in creating
  debug info (that seems necessary for the time being).

* Fix typo in CodeGenCPU::CreateStructRefPtr

* Fix type extraction in CodeGenLLVM::AddAliasInfo

* Fix types in ramp-1 vector loads/stores

* Fix getting intrinsic name in error message

* Return valid pointer from PackClosureData when no data to pack
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants