Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 21, 2025

LLVM 20 deprecates Type::getPointerTo() in favor of PointerType::getUnqual(), causing compilation failures with -Werror=deprecated-declarations.

Changes

  • Replace Type::getPointerTo()PointerType::getUnqual() in 4 locations:
    • getTensorPtrType() - opaque struct pointer creation
    • getInt64PtrType() - int64 pointer type helper
    • compileFunctionDeclarations() - tensor pointer parameters (2 occurrences)
// Before
return llvm::Type::getInt64Ty(context)->getPointerTo();

// After  
return llvm::PointerType::getUnqual(llvm::Type::getInt64Ty(context));

The new API has been available since LLVM 18.1 (project minimum) and maintains identical semantics (address space 0).

Original prompt

This section details on the original issue you should resolve

<issue_title>csrc/host_ir/jit.cpp:138:72: error: ‘llvm::PointerType* llvm::Type::getPointerTo(unsigned int) const’ is deprecated</issue_title>
<issue_description>When I ran time MAX_JOBS=1 LLVM_DIR=/usr/lib/llvm-20/lib/cmake NVFUSER_BUILD_NO_TEST=1 NVFUSER_BUILD_NO_BENCHMARK=1 NVFUSER_BUILD_NO_CUTLASS=1 uv pip install -v --no-build-isolation -e ./python, I encountered this error:

/home/mkozuki/ghq/github.com/NVIDIA/Fuser/csrc/host_ir/jit.cpp: In function ‘llvm::Type* nvfuser::getTensorPtrType(llvm::LLVMContext&)’:
/home/mkozuki/ghq/github.com/NVIDIA/Fuser/csrc/host_ir/jit.cpp:138:72: error: ‘llvm::PointerType* llvm::Type::getPointerTo(unsigned int) const’ is deprecated: Use PointerType::get instead [-Werror=deprecated-declarations]
  138 |   return llvm::StructType::create(context, kAtTensorType)->getPointerTo();
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
In file included from /usr/include/llvm-20/llvm/IR/DerivedTypes.h:23,
                 from /usr/include/llvm-20/llvm/IR/DataLayout.h:27,
                 from /usr/include/llvm-20/llvm/IR/Module.h:24,
                 from /usr/include/llvm-20/llvm/ExecutionEngine/Orc/ThreadSafeModule.h:17,
                 from /usr/include/llvm-20/llvm/ExecutionEngine/Orc/Mangling.h:17,
                 from /usr/include/llvm-20/llvm/ExecutionEngine/Orc/Layer.h:17,
                 from /usr/include/llvm-20/llvm/ExecutionEngine/Orc/IRCompileLayer.h:18,
                 from /usr/include/llvm-20/llvm/ExecutionEngine/Orc/CompileUtils.h:16,
                 from /home/mkozuki/ghq/github.com/NVIDIA/Fuser/csrc/host_ir/jit.cpp:12:
/usr/include/llvm-20/llvm/IR/Type.h:490:16: note: declared here
  490 |   PointerType *getPointerTo(unsigned AddrSpace = 0) const;
      |                ^~~~~~~~~~~~
/home/mkozuki/ghq/github.com/NVIDIA/Fuser/csrc/host_ir/jit.cpp: In function ‘llvm::Type* nvfuser::getInt64PtrType(llvm::LLVMContext&)’:
/home/mkozuki/ghq/github.com/NVIDIA/Fuser/csrc/host_ir/jit.cpp:148:55: error: ‘llvm::PointerType* llvm::Type::getPointerTo(unsigned int) const’ is deprecated: Use PointerType::get instead [-Werror=deprecated-declarations]
  148 |   return llvm::Type::getInt64Ty(context)->getPointerTo();
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/usr/include/llvm-20/llvm/IR/Type.h:490:16: note: declared here
  490 |   PointerType *getPointerTo(unsigned AddrSpace = 0) const;
      |                ^~~~~~~~~~~~
/home/mkozuki/ghq/github.com/NVIDIA/Fuser/csrc/host_ir/jit.cpp: In function ‘void nvfuser::compileFunctionDeclarations(llvm::Module*, llvm::LLVMContext&)’:
/home/mkozuki/ghq/github.com/NVIDIA/Fuser/csrc/host_ir/jit.cpp:714:33: error: ‘llvm::PointerType* llvm::Type::getPointerTo(unsigned int) const’ is deprecated: Use PointerType::get instead [-Werror=deprecated-declarations]
  714 |        tensor_type->getPointerTo(),
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~^~
/usr/include/llvm-20/llvm/IR/Type.h:490:16: note: declared here
  490 |   PointerType *getPointerTo(unsigned AddrSpace = 0) const;
      |                ^~~~~~~~~~~~
/home/mkozuki/ghq/github.com/NVIDIA/Fuser/csrc/host_ir/jit.cpp:716:33: error: ‘llvm::PointerType* llvm::Type::getPointerTo(unsigned int) const’ is deprecated: Use PointerType::get instead [-Werror=deprecated-declarations]
  716 |        tensor_type->getPointerTo(),
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~^~
/usr/include/llvm-20/llvm/IR/Type.h:490:16: note: declared here
  490 |   PointerType *getPointerTo(unsigned AddrSpace = 0) const;
      |                ^~~~~~~~~~~~

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: crcrpar <16191443+crcrpar@users.noreply.github.com>
@crcrpar
Copy link
Collaborator

crcrpar commented Nov 21, 2025

!build

Copilot AI changed the title [WIP] Fix deprecated pointer type usage in jit.cpp Fix deprecated LLVM Type::getPointerTo() for LLVM 20 compatibility Nov 21, 2025
Copilot AI requested a review from crcrpar November 21, 2025 14:08
@crcrpar crcrpar marked this pull request as ready for review November 21, 2025 14:09
@github-actions
Copy link

github-actions bot commented Nov 21, 2025

Auto-merge Status

✅ Internal CI is finished
❌ No failed checks (nvfuser-ci/jit_binary_tests_sanitizer_20_H100_3/3, nvfuser-ci/jit_python_distributed_tests_20_GB200, nvfuser-ci/jit_python_distributed_tests_20_GB200, nvfuser-ci/jit_python_distributed_tests_20_GB200, nvfuser-ci/jit_python_distributed_tests_20_GB200, nvfuser-ci/jit_python_distributed_tests_20_GB200, PR Agent tools, dynamic-type-meson, clang-build-23, lintrunner, clang-tidy, check-license)
✅ PR is mergeable
ℹ️ PR mergeable_state: unstable

Description

  • Replace 4 deprecated Type::getPointerTo() calls with PointerType::getUnqual() in jit.cpp

  • Fix compilation errors with LLVM 20 deprecation warnings

  • Update getTensorPtrType() function to use new PointerType API

  • Update getInt64PtrType() function to use new PointerType API

  • Update compileFunctionDeclarations() function pointer type declarations

Changes walkthrough

Relevant files
Bug fix
jit.cpp
Replace deprecated getPointerTo() with PointerType::getUnqual()

csrc/host_ir/jit.cpp

  • Replace deprecated Type::getPointerTo() with PointerType::getUnqual()
    in 4 locations
  • Update getTensorPtrType() function (line ~138) to use new PointerType
    API
  • Update getInt64PtrType() function (line ~148) to use new PointerType
    API
  • Update compileFunctionDeclarations() function pointer type
    declarations (lines ~714, ~716)
  • Maintain address space 0 (default) semantics consistent with existing
    code
  • +5/-4     

    PR Reviewer Guide

    Here are some key observations to aid the review process:

    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review
    Build Verification Needed

    The PR description indicates plans to build and test the code, but no actual build verification or test results are provided. The changes replace deprecated LLVM 20 API calls with modern equivalents, but verification that the code compiles successfully with LLVM 20 is essential before merging.

      return llvm::PointerType::getUnqual(
          llvm::StructType::create(context, kAtTensorType));
    }
    
    llvm::ArrayType* getInt64StaticArrayType(
        llvm::LLVMContext& context,
        size_t size) {
      return llvm::ArrayType::get(llvm::Type::getInt64Ty(context), size);
    }
    
    llvm::Type* getInt64PtrType(llvm::LLVMContext& context) {
      return llvm::PointerType::getUnqual(llvm::Type::getInt64Ty(context));
    Address Space Consistency

    The changes correctly use PointerType::getUnqual() which defaults to address space 0, matching the original getPointerTo() behavior. However, verify that no address space assumptions are made elsewhere in the codebase that might be affected by this change.

    {int64_type,
     llvm::PointerType::getUnqual(tensor_type),
     int64_type,
     llvm::PointerType::getUnqual(tensor_type),

    @greptile-apps
    Copy link
    Contributor

    greptile-apps bot commented Nov 21, 2025

    Greptile Overview

    Greptile Summary

    This PR replaces deprecated LLVM API Type::getPointerTo() with PointerType::getUnqual() to fix compilation errors with LLVM 20 when -Werror=deprecated-declarations is enabled.

    Changes made:

    • getTensorPtrType() (line 138-139) - replaced opaque struct pointer creation
    • getInt64PtrType() (line 149) - replaced int64 pointer type helper
    • compileFunctionDeclarations() (lines 715, 717) - replaced tensor pointer parameters for launch_kernel function signature

    The new API maintains identical semantics (address space 0) and has been available since LLVM 18.1, which matches the project's minimum LLVM version requirement. The change is consistent with the existing usage in getInt8PtrType() (line 122), which already uses PointerType::getUnqual().

    Confidence Score: 5/5

    • This PR is safe to merge with no risk
    • The changes are purely mechanical API replacements for deprecated LLVM functions. The new API (PointerType::getUnqual()) has identical semantics to the old API (Type::getPointerTo()) with default address space 0, has been available since LLVM 18.1 (matching the project's minimum version), and the pattern is already used consistently elsewhere in the same file (line 122, 130). All 4 replacements are syntactically correct and maintain the same type safety.
    • No files require special attention

    Important Files Changed

    File Analysis

    Filename Score Overview
    csrc/host_ir/jit.cpp 5/5 Updated 4 locations to use PointerType::getUnqual() instead of deprecated Type::getPointerTo() for LLVM 20 compatibility - changes are straightforward API replacements

    Sequence Diagram

    sequenceDiagram
        participant Code as nvfuser Code
        participant OldAPI as Type::getPointerTo()
        participant NewAPI as PointerType::getUnqual()
        participant LLVM as LLVM IR Type System
        
        Note over Code,LLVM: Before (LLVM 19 and earlier)
        Code->>OldAPI: type->getPointerTo()
        OldAPI->>LLVM: Create pointer type (address space 0)
        LLVM-->>Code: Return PointerType*
        
        Note over Code,LLVM: After (LLVM 18.1+ compatible, LLVM 20 required)
        Code->>NewAPI: PointerType::getUnqual(type)
        NewAPI->>LLVM: Create pointer type (address space 0)
        LLVM-->>Code: Return PointerType*
        
        Note over Code,LLVM: Changes applied to:
        Note over Code,LLVM: 1. getTensorPtrType() - line 138
        Note over Code,LLVM: 2. getInt64PtrType() - line 149
        Note over Code,LLVM: 3. launch_kernel params - lines 715, 717
    
    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.

    1 file reviewed, no comments

    Edit Code Review Agent Settings | Greptile

    @crcrpar crcrpar added the enable-auto-merge Auto-merge a PR when: 1) PR mergeable 2) Internal CI complete 3) No failures label Nov 21, 2025
    @crcrpar
    Copy link
    Collaborator

    crcrpar commented Nov 22, 2025

    !test

    @wujingyue wujingyue requested a review from mdavis36 November 22, 2025 05:15
    @crcrpar
    Copy link
    Collaborator

    crcrpar commented Nov 24, 2025

    Would you expect me to merge this or will you merge this?

    @wujingyue
    Copy link
    Collaborator

    Would you expect me to merge this or will you merge this?

    We expect authors to merge their changes, but I'll do it for you this time. Good question -- I didn't realize we follow a different convention than Thunder.

    @wujingyue wujingyue merged commit 9e7f2ad into main Nov 24, 2025
    62 of 73 checks passed
    @wujingyue wujingyue deleted the copilot/fix-deprecated-pointer-type-error branch November 24, 2025 19:19
    @github-actions github-actions bot removed the enable-auto-merge Auto-merge a PR when: 1) PR mergeable 2) Internal CI complete 3) No failures label Nov 24, 2025
    IvanYashchuk added a commit to IvanYashchuk/Fuser that referenced this pull request Jan 14, 2026
    …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 added a commit to IvanYashchuk/Fuser that referenced this pull request Jan 14, 2026
    …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.
    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.

    csrc/host_ir/jit.cpp:138:72: error: ‘llvm::PointerType* llvm::Type::getPointerTo(unsigned int) const’ is deprecated

    4 participants