Skip to content

[REFACTOR][IR] Simplify CallingConv attribute access#19799

Merged
MasterJH5574 merged 2 commits into
apache:mainfrom
tqchen:tvm-simplify-callingconv-getattr-usage
Jun 16, 2026
Merged

[REFACTOR][IR] Simplify CallingConv attribute access#19799
MasterJH5574 merged 2 commits into
apache:mainfrom
tqchen:tvm-simplify-callingconv-getattr-usage

Conversation

@tqchen

@tqchen tqchen commented Jun 16, 2026

Copy link
Copy Markdown
Member

Summary

CallingConv already participates in TVM FFI integral enum conversion, so keeping call sites on manual integer casts adds noise without changing behavior. This was not possible before the TVM FFI Any support but now we natively support enum class int value conversion with Any, so we can simplify the codepath

Main changes:

  • Read tvm::attr::kCallingConv as CallingConv directly
  • Compare optional/defaulted values against CallingConv enum values
  • Store CallingConv enum values directly where the cleanup touches attr writes

CallingConv already has integral enum support in the FFI layer, so call sites can read and write the calling convention attribute without manually round-tripping through integer casts.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the retrieval and comparison of calling conventions (CallingConv) across various backend codegens and TIR transform passes, replacing int64_t casts with direct CallingConv enum types. The review feedback suggests improving error handling in the Metal, OpenCL, Vulkan, and WebGPU codegens by explicitly checking if the calling convention attribute is present before comparing its value, which would provide more specific and informative error messages.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/backend/metal/codegen/codegen_metal.cc Outdated
Comment thread src/backend/opencl/codegen/codegen_opencl.cc Outdated
Comment thread src/backend/vulkan/codegen/spirv_utils.cc Outdated
Comment thread src/backend/webgpu/codegen/codegen_webgpu.cc Outdated
Backend codegen requires an explicit device-kernel calling convention. Split the checks so missing attributes and unexpected CallingConv values produce distinct diagnostics while keeping enum-based attribute access.
@MasterJH5574

Copy link
Copy Markdown
Contributor

@tvm-bot rerun

@MasterJH5574 MasterJH5574 merged commit 649388e into apache:main Jun 16, 2026
8 checks passed
MasterJH5574 pushed a commit to MasterJH5574/tvm that referenced this pull request Jun 16, 2026
CallingConv already participates in TVM FFI integral enum conversion, so
keeping call sites on manual integer casts adds noise without changing
behavior. This was not possible before the TVM FFI Any support but now
we natively support enum class int value conversion with Any, so we can
simplify the codepath

Main changes:

- Read `tvm::attr::kCallingConv` as `CallingConv` directly
- Compare optional/defaulted values against `CallingConv` enum values
- Store CallingConv enum values directly where the cleanup touches attr
writes
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.

3 participants