Skip to content

Conversation

@IvanYashchuk
Copy link
Collaborator

@IvanYashchuk IvanYashchuk commented Jan 14, 2026

Summary

Replace PointerType::getUnqual(Type*) with PointerType::getUnqual(LLVMContext&) to fix build errors with newer LLVM versions that have deprecated the typed pointer APIs in favor of opaque pointers.

The typed pointer overload is deprecated and pending removal. The context-only overload has been available since LLVM 18.1 and maintains identical semantics (address space 0) for opaque pointers.

Changes

  • jit.cpp: Update getInt8PtrType(), getInt8PtrDynamicArrayType(), getTensorPtrType(), and getInt64PtrType() helper functions
  • jit_tensor_utils.cpp: Update packTensorArgument() BitCast operations

Test plan

  • Fixed files compile successfully
  • Full build completes without errors
  • import nvfuser works correctly

Tested with: LLVM 21.1.5 (deprecation warnings become errors in LLVM 20+ with -Werror)

Fixes regression from #5576 which only partially addressed the issue.
Related to #5575

Copilot AI review requested due to automatic review settings January 14, 2026 16:16
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates LLVM pointer type creation from the deprecated typed pointer API (PointerType::getUnqual(Type*)) to the opaque pointer API (PointerType::getUnqual(LLVMContext&)) to ensure compatibility with LLVM 18.1+, which has deprecated typed pointers in favor of opaque pointers.

Changes:

  • Updated four helper functions in jit.cpp to use context-only overload
  • Updated two CreateBitCast operations in jit_tensor_utils.cpp to use context-only overload
  • Added explanatory comments for all changes

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
csrc/host_ir/jit.cpp Updated getInt8PtrType(), getInt8PtrDynamicArrayType(), getTensorPtrType(), and getInt64PtrType() to use opaque pointer API
csrc/host_ir/jit_tensor_utils.cpp Updated two CreateBitCast operations in packTensorArgument() to use opaque pointer API

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 14, 2026

Greptile Summary

This PR completes the LLVM opaque pointer migration by replacing the deprecated PointerType::getUnqual(Type*) API with PointerType::getUnqual(LLVMContext&). The typed pointer overload was deprecated in LLVM and is pending removal, while the context-only overload properly supports opaque pointers introduced in LLVM 15+ and required in LLVM 20+.

Changes:

  • Updated 4 helper functions in jit.cpp to use context-only pointer API
  • Updated 2 BitCast operations in jit_tensor_utils.cpp for consistency
  • Removed unnecessary StructType::create() call in getTensorPtrType() since opaque pointers don't need typed struct references

Context:
This fixes a regression from #5576, which only partially migrated from Type::getPointerTo() to PointerType::getUnqual(Type*). The current PR completes the migration to the fully opaque pointer API that's required for LLVM 20+ compatibility.

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • The changes are straightforward API replacements that maintain identical semantics (address space 0 pointers). All pointer type helpers now consistently use the opaque pointer API, which has been available since LLVM 18.1 and is the recommended approach for LLVM 20+. No deprecated APIs remain in the modified files.
  • No files require special attention

Important Files Changed

Filename Overview
csrc/host_ir/jit.cpp Updated 4 helper functions (getInt8PtrType, getInt8PtrDynamicArrayType, getTensorPtrType, getInt64PtrType) to use opaque pointer API with context-only overload
csrc/host_ir/jit_tensor_utils.cpp Updated 2 CreateBitCast calls in packTensorArgument to use opaque pointer API for zero-dim tensors and runtime tensor structs

Sequence Diagram

sequenceDiagram
    participant Client as Client Code
    participant Helpers as Helper Functions
    participant LLVM_Old as LLVM Typed Pointer API
    participant LLVM_New as LLVM Opaque Pointer API
    
    Note over Client,LLVM_New: Before PR #5820
    Client->>Helpers: getInt8PtrType(context)
    Helpers->>LLVM_Old: PointerType::getUnqual(Int8Ty)
    LLVM_Old-->>Helpers: Typed pointer (deprecated)
    Helpers-->>Client: i8* type
    
    Note over Client,LLVM_New: After PR #5820
    Client->>Helpers: getInt8PtrType(context)
    Helpers->>LLVM_New: PointerType::getUnqual(context)
    LLVM_New-->>Helpers: Opaque pointer
    Helpers-->>Client: ptr type
    
    Note over Client,LLVM_New: BitCast Operations
    Client->>Helpers: packTensorArgument(...)
    Helpers->>LLVM_Old: CreateBitCast(ptr, getUnqual(Int8Ty))
    LLVM_Old-->>Helpers: Typed cast (deprecated)
    
    Helpers->>LLVM_New: CreateBitCast(ptr, getUnqual(context))
    LLVM_New-->>Helpers: Opaque cast
    Helpers-->>Client: Packed tensor
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

…compatibility

Replace PointerType::getUnqual(Type*) with PointerType::getUnqual(LLVMContext&)
to fix build errors with newer LLVM versions that have deprecated the typed
pointer APIs in favor of opaque pointers.

The typed pointer overload `PointerType::getUnqual(Type*)` is deprecated and
pending removal. The context-only overload has been available since LLVM 18.1
and maintains identical semantics (address space 0) for opaque pointers.

Changes:
- jit.cpp: Update getInt8PtrType(), getInt8PtrDynamicArrayType(),
  getTensorPtrType(), and getInt64PtrType() helper functions
- jit_tensor_utils.cpp: Update packTensorArgument() BitCast operations

Fixes regression from PR NVIDIA#5576 which only partially addressed the issue by
changing Type::getPointerTo() to PointerType::getUnqual(Type*), but that API
is also deprecated.
@IvanYashchuk IvanYashchuk force-pushed the fix-llvm-deprecated-pointer-api branch from 98be20b to 95c9b97 Compare January 14, 2026 16:26
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 14, 2026

Greptile found no issues!

From now on, if a review finishes and we haven't found any issues, we will not post anything, but you can confirm that we reviewed your changes in the status check section.

This feature can be toggled off in your Code Review Settings by deselecting "Create a status check for each PR".

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.

1 participant