<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/145408>145408</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [DirectX] Segfault in PointerTypeAnalisis.cpp `classifyPointerType`
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          farzonl
      </td>
    </tr>
</table>

<pre>
    One of the recent changes that landed is causing an AV in `llvm/lib/Target/DirectX/DirectXIRPasses/PointerTypeAnalysis.cpp:35` 

Four of the DML tests are now crashing.

```cpp
if (!Inst->getResultElementType()->isPointerTy()) 
```
The `getResultElementType()` is a nullptr on this instruction 

```llvm
%arrayidx.i30 = getelementptr inbounds nuw %struct.RawStruct8D, ptr %outputSizesLocal.i, i32 0, i32 %20`
```

repro 
```bash
lldb -- clang-dxc DirectML/Product/Shaders/Generated/OneHot_256_uint16_native_int32_native_4.hlsl -E CSMain -T cs_6_2  -enable-16bit-types  -O3 -D DXC_COMPILER=1 -D __SHADER_TARGET_MAJOR=6 -D __SHADER_TARGET_MINOR=2 -Vd -I DirectML/Product/Shaders/ -Fo validation/OneHot_256_uint16_native_int32_native_4.dat
```

```cpp
Stack Traces:
#0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+)
 #1 llvm::sys::CleanupOnSignal(unsigned long) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+)
 #2 CrashRecoverySignalHandler(int) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+)
 #3 (/usr/lib/system/libsystem_platform.dylib+)
 #4 llvm::dxil::PointerTypeAnalysis::run(llvm::Module const&) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+)
 #5 llvm::dxil::PointerTypeAnalysis::run(llvm::Module const&) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+)
 #6 (anonymous namespace)::DXILPrepareModule::runOnModule(llvm::Module&) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+)
 #7 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+)
 #8 clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::__1::unique_ptr<llvm::raw_pwrite_stream, std::__1::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+)
 #9 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+)
#10 clang::ParseAST(clang::Sema&, bool, bool) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+)
#11 clang::CodeGenAction::ExecuteAction() (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+)
#12 clang::FrontendAction::Execute() (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+)
#13 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+)
#14 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+)
#15 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+)
#16 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+)
#17 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__1::optional<llvm::StringRef>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, bool*) const::$_0>(long) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+)
#18 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+)
#19 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__1::optional<llvm::StringRef>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, bool*) const (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+)
#20 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+)
#21 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*>>&, bool) const (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+)
#22 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*>>&) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+)
#23 clang_main(int, char**, llvm::ToolContext const&) (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+)
#24 main (/Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-21+)
#25 
clang-dxc: error: clang frontend command failed with exit code 139 (use -v to see invocation)
clang version 21.0.0git (git@github.com:llvm/llvm-project.git ab17ff05621f3029c1afae0d62093287f9d1e2b5)
Target: dxilv1.2-unknown-shadermodel6.2-compute
Thread model: posix
InstalledDir: /Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin
Build config: +assertions, +asan
Cause instances: 4
Cause:
0.      Program arguments: /Users/farzonlotfi/Projects/llvm_rel_with_deb_info/bin/clang-dxc ../DirectML/Product/Shaders/Generated/OneHot_256_uint16_native_int32_native_4.hlsl -E CSMain -T cs_6_2  -enable-16bit-types  -O3 -D DXC_COMPILER=1 -D __SHADER_TARGET_MAJOR=6 -D __SHADER_TARGET_MINOR=2 -Vd -I ../DirectML/Product/Shaders/ -Fo /Users/farzonlotfi/Projects/ClangDML/tools/validation/OneHot_256_uint16_native_int32_native_4.dat
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'DXIL Prepare Module' on module '../DirectML/Product/Shaders/Generated/OneHot_256_uint16_native_int32_native_4.hlsl'.
----------------------------------------
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzsWVtv2zoS_jXMy8CGRFm-PORBleM2RbIJbJ-ibwItjWRuaVJLUk58fv2ClJzIuZ0enHUPdrFFgcic0fCbC7-hSGYMryTiJYk_kXh-wRq7VfqyZPp3JcXFRhWHyzuJoEqwWwSNOUoL-ZbJCg3YLbMgmCywAG4gZ43hsgImIfkGXAIZB0Lsd4QuBN8QulgzXaEldDHnGnP7_fnpennPjEFD6OJecWlRrw81JpKJg-FmmNc1iZIoJuMASJCQIFmoRh9RzW9vwKKxBphGkOoBcs3Mlstq2CqTcdD-d3aChJdA6JTQ8FoaOyDRVYV2iaYR9krgDqV1c3uNmZNy8wSpHSR0Bn2rJEjWW3Tevm_IIecGGMhGiNpqUBLslhvg0ljd5JYrCS_Q-tgFCaEx05odePE45FEAJJpDhRbbKZwtLjeqkYUB2TwAoXFrcbhkDyv_NJ0TmoLTJDRWja0bu-K_o7lRORND7oQ8ohAcHwiNaedY30kSJBprrU6c3zCzJUEiRLGBwQBywWQ1KB5zaDN7e-NSqlXR5C7xqy0rULs0f0aJmlksCF3cSfyibEbjcdZwacNxJpnle8y4tBE9_hgNt8IIGFxBurplXMJgDbnJxhkFGKBkG4GDcLzhdmAPNRqAwV0EgznMv6dZend7f31ztSTRPHRjWbb6ksyvltk6WX6-Wme3ydc7Jxy_Kbz-hxdSGHwrYHD9R67BYKFgzwQvmEvr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