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

    <tr>
        <th>Summary</th>
        <td>
            [OpenMPOpt] Segmentation fault in Attributor / AAKernelInfoCallSite with function pointer in target region
        </td>
    </tr>

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

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

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

<pre>
    Starting with "[OpenMPOpt] Allow indirect calls in AAKernelInfoCallSite (#65836)" we see one of our internal tests fail.

I have removed some of the macros that were in the original test together with some AMDGCN specific stuff.
The resulting file still triggers the segmentation fault we are seeing in the original test.

```
0.      Program arguments: /home/janplehr/git/trunk17.0/botbuild/bin/opt -passes=lto<O3> target-func-ptr.cpp.tmp.amdgcn-amd-amdhsa.gfx90a.postlink.bc
 #0 0x000055edfdf23d1f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/janplehr/git/trunk17.0/botbuild/bin/opt+0x4278d1f)
 #1 0x000055edfdf21284 SignalHandler(int) Signals.cpp:0:0
 #2 0x00007fb97fe1f420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x000055edfc8e3c5b llvm::IRPosition::getAnchorScope() const AMDGPUAttributor.cpp:0:0
 #4 0x000055edfd9c991a (anonymous namespace)::AAKernelInfo const* llvm::Attributor::getOrCreateAAFor<(anonymous namespace)::AAKernelInfo>(llvm::IRPosition, llvm::AbstractAttribute const*, llvm::DepClassTy, bool, bool) (.constprop.0) OpenMPOpt.cpp:0:0
 #5 0x000055edfd9cc9d2 (anonymous namespace)::AAKernelInfoCallSite::updateImpl(llvm::Attributor&)::'lambda'(llvm::Function*, int)::operator()(llvm::Function*, int) const OpenMPOpt.cpp:0:0
 #6 0x000055edfd9cd3f4 (anonymous namespace)::AAKernelInfoCallSite::updateImpl(llvm::Attributor&) OpenMPOpt.cpp:0:0
 #7 0x000055edfd8a981a llvm::AbstractAttribute::update(llvm::Attributor&) (/home/janplehr/git/trunk17.0/botbuild/bin/opt+0x3bfe81a)
 #8 0x000055edfd8c0944 llvm::Attributor::updateAA(llvm::AbstractAttribute&) (/home/janplehr/git/trunk17.0/botbuild/bin/opt+0x3c15944)
 #9 0x000055edfd8c958e llvm::Attributor::runTillFixpoint() (/home/janplehr/git/trunk17.0/botbuild/bin/opt+0x3c1e58e)
#10 0x000055edfd8dda9a llvm::Attributor::run() (/home/janplehr/git/trunk17.0/botbuild/bin/opt+0x3c32a9a)
#11 0x000055edfd9c2749 (anonymous namespace)::OpenMPOpt::runAttributor(bool) (.part.0) OpenMPOpt.cpp:0:0
#12 0x000055edfd9c6da9 (anonymous namespace)::OpenMPOpt::run(bool) OpenMPOpt.cpp:0:0
#13 0x000055edfd9c7e63 llvm::OpenMPOptPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/janplehr/git/trunk17.0/botbuild/bin/opt+0x3d1ce63)
#14 0x000055edfe139ad6 llvm::detail::PassModel<llvm::Module, llvm::OpenMPOptPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) PassBuilder.cpp:0:0
#15 0x000055edfd8168ad llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/janplehr/git/trunk17.0/botbuild/bin/opt+0x3b6b8ad)
#16 0x000055edfc2edde5 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/home/ja
nplehr/git/trunk17.0/botbuild/bin/opt+0x2642de5)
#17 0x000055edfc2fb786 main (/home/janplehr/git/trunk17.0/botbuild/bin/opt+0x2650786)
#18 0x00007fb97f89d083 __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:342:3
#19 0x000055edfc2e0c2e _start (/home/janplehr/git/trunk17.0/botbuild/bin/opt+0x2635c2e)
Segmentation fault (core dumped)
```

I got an IR file out of the original source (thanks for the help with that), that I then ran with `opt -passes='lto<O3>'` to get the stack trace.
The IR file and the original source is attached in the zip file.

[target-func-ptr.zip](https://github.com/llvm/llvm-project/files/12587682/target-func-ptr.zip)

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMWFtz27oR_jXwC8YaEryIfPADbR-1nlM3ntjtqwYEliQSEOAAYGzn13cA6kIqit2kPjPVSOIFwO633y4uu9Ra0SqAK5RdI0K-cA2mAeMQISi7vaCj67S5-jJI6MxFrfnr1aOjxgnV4mfhOhz6XX8aQN0_fBocym5xJaV-xkJxYYA5zKiUFguFq-pPMArknWr0DZXyUTjAiBSIJHlWJDkiJSIEPwO2AFgrwLrBejRYKAdGUYkdWGdxQ4VcoegWRdX0f4c7-g2wgV5_A46t7sNQ1wHuKTPaYtdRh5_BgMfh32sjWrEXiZ1uwXVgJpPC-Or-9m83_8R2ACYawbB1Y9PstD51XpkdZaChERKwdUJK7IxoWzA2qLDQ9qAcdUIr3NBRegSYmmCeH3gOysIulEe7b3iMVjh8HoxuDe0xNe3oNViUVBiRTad7QGTzhargLUQ2rXCIbJwZ1dd4vYoQ2dTa1aOQ3N8KhchGDw5fDtRasCi5lU6j5OZTgpI_sKOmBXfZjIpdDs6s2DCsXD-saM9bpi5pz_2vs3TVNi9lRFeDtk4K9XVVswkwRiSJcPQSRVGUZcAb3pCExw2W8luPkgollX21082DEco9Osq-PhnKAJHi2MnQ5622zgDtEckRufERgUg5Bc9v243IdfSSknXB48bH3gFzfII5JkWKH0WrqPw7VVyCQaTYQZheW88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