<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/56493>56493</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[RS4GC] Assertion `PointerToBase.count(Derived)' failed.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
max-quazan
</td>
</tr>
</table>
<pre>
https://godbolt.org/z/o9GPb53qv
Run `opt -S -passes=rewrite-statepoints-for-gc` on test
```
define void @bar() #0 gc "statepoint-example" personality i32* ()* @zot {
bb:
call void @llvm.memcpy.element.unordered.atomic.p1i32.p1i32.i64(i32 addrspace(1)* elementtype(i32) align 8 undef, i32 addrspace(1)* elementtype(i32) align 16 bitcast (i8 addrspace(1)* getelementptr inbounds (i8, i8 addrspace(1)* null, i64 16) to i32 addrspace(1)*), i64 undef, i32 4) #3 [ "deopt"() ]
ret void
}
; Function Attrs: willreturn
declare i32* @zot() #1
; Function Attrs: argmemonly nosync nounwind willreturn
declare void @llvm.memcpy.element.unordered.atomic.p1i32.p1i32.i64(i32 addrspace(1)* nocapture writeonly, i32 addrspace(1)* nocapture readonly, i64, i32 immarg) #2
```
Stack trace
```
opt: /root/llvm-project/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp:1705: makeStatepointExplicitImpl(llvm::CallBase*, const llvm::SmallVectorImpl<llvm::Value*>&, const llvm::SmallVectorImpl<llvm::Value*>&, {anonymous}::PartiallyConstructedSafepointRecord&, std::vector<{anonymous}::DeferredReplacement>&, const PointerToBaseTy&)::<lambda(llvm::Value*)>: Assertion `PointerToBase.count(Derived)' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -S -passes=rewrite-statepoints-for-gc <source>
#0 0x000055c9d31a406f PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
#1 0x000055c9d31a1a9c SignalHandler(int) Signals.cpp:0:0
#2 0x00007f52da7963c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x143c0)
#3 0x00007f52da26303b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4303b)
#4 0x00007f52da242859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#5 0x00007f52da242729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#6 0x00007f52da254006 (/lib/x86_64-linux-gnu/libc.so.6+0x34006)
#7 0x000055c9d3089bdb makeStatepointExplicitImpl(llvm::CallBase*, llvm::SmallVectorImpl<llvm::Value*> const&, llvm::SmallVectorImpl<llvm::Value*> const&, (anonymous namespace)::PartiallyConstructedSafepointRecord&, std::vector<(anonymous namespace)::DeferredReplacement, std::allocator<(anonymous namespace)::DeferredReplacement>>&, llvm::MapVector<llvm::Value*, llvm::Value*, llvm::DenseMap<llvm::Value*, unsigned int, llvm::DenseMapInfo<llvm::Value*, void>, llvm::detail::DenseMapPair<llvm::Value*, unsigned int>>, std::vector<std::pair<llvm::Value*, llvm::Value*>, std::allocator<std::pair<llvm::Value*, llvm::Value*>>>> const&)::'lambda'(llvm::Value*)::operator()(llvm::Value*) const RewriteStatepointsForGC.cpp:0:0
#8 0x000055c9d308dc95 makeStatepointExplicitImpl(llvm::CallBase*, llvm::SmallVectorImpl<llvm::Value*> const&, llvm::SmallVectorImpl<llvm::Value*> const&, (anonymous namespace)::PartiallyConstructedSafepointRecord&, std::vector<(anonymous namespace)::DeferredReplacement, std::allocator<(anonymous namespace)::DeferredReplacement>>&, llvm::MapVector<llvm::Value*, llvm::Value*, llvm::DenseMap<llvm::Value*, unsigned int, llvm::DenseMapInfo<llvm::Value*, void>, llvm::detail::DenseMapPair<llvm::Value*, unsigned int>>, std::vector<std::pair<llvm::Value*, llvm::Value*>, std::allocator<std::pair<llvm::Value*, llvm::Value*>>>> const&) (.isra.1112) RewriteStatepointsForGC.cpp:0:0
#9 0x000055c9d309a4a3 insertParsePoints(llvm::Function&, llvm::DominatorTree&, llvm::TargetTransformInfo&, llvm::SmallVectorImpl<llvm::CallBase*>&, llvm::MapVector<llvm::Value*, llvm::Value*, llvm::DenseMap<llvm::Value*, unsigned int, llvm::DenseMapInfo<llvm::Value*, void>, llvm::detail::DenseMapPair<llvm::Value*, unsigned int>>, std::vector<std::pair<llvm::Value*, llvm::Value*>, std::allocator<std::pair<llvm::Value*, llvm::Value*>>>>&, llvm::MapVector<llvm::Value*, bool, llvm::DenseMap<llvm::Value*, unsigned int, llvm::DenseMapInfo<llvm::Value*, void>, llvm::detail::DenseMapPair<llvm::Value*, unsigned int>>, std::vector<std::pair<llvm::Value*, bool>, std::allocator<std::pair<llvm::Value*, bool>>>>&) RewriteStatepointsForGC.cpp:0:0
#10 0x000055c9d309d0a0 llvm::RewriteStatepointsForGC::runOnFunction(llvm::Function&, llvm::DominatorTree&, llvm::TargetTransformInfo&, llvm::TargetLibraryInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x349d0a0)
#11 0x000055c9d309dbf8 llvm::RewriteStatepointsForGC::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x349dbf8)
#12 0x000055c9d34d4e01 llvm::detail::PassModel<llvm::Module, llvm::RewriteStatepointsForGC, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x38d4e01)
#13 0x000055c9d2925594 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2d25594)
#14 0x000055c9d08d4498 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::StringRef>, llvm::ArrayRef<llvm::PassPlugin>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xcd4498)
#15 0x000055c9d0810e1a main (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xc10e1a)
#16 0x00007f52da2440b3 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x240b3)
#17 0x000055c9d08c75aa _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xcc75aa)
Compiler returned: 139
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztWd1z4jYQ_2ucFw2M_AX4IQ8kJG2nvSkTMvfKyJYg6smSK8m5cH99V7IBm4NcSNJO20mGGGzt_vZ717JzRTeXD9ZWJoinQXQLn7WiuRJ2qPQazr7Bv8p-mudp_OdjgGcBnjbHu1qiYIRVZdFggQYVMYYByEyzr5pbNjCWWFYpLq0ZrJQerAugRkoiy4xtgUa4_fhTylZcMvSoOEVBgnOig2gSRBkKohijdQHf0R51wJ5IWQkGF1HFtFGSCG43iMdREE1Rw-p_JfibsigYXzVi8tyZ6n8iVBAhdhKFeCyHJSuLajNkgpVM2mEtlaZMMzokVpW8GFYhSGiPfJSAHPiFCKXaVKQAdSZhK7iFsJuKNVTOFlByLdEE1RLMDaJr9ArucIRybgtirDOTT47yr5ltISqrEZe5ApGmYfByj7PJWgi_PEpAjpNp1Skd_bEh7ZmTtEGLUZBeuahRBmkC39t4prOt_zWz3v1tQoxn3RQL4it0W8vCckibqbXaJSn6yoUAtlrLbdoUgmi2C7wP9z5zwh8jEr2GqCspNkgqs5EFfNXyK5f0pLC_KWWkKkgF0hjyReRUei5H9uSaEbqjdiIaJl6WxJWx90TU80S_9prjwpLiC7LaSTlG5aIYu9q61cr5-NaZP6i0-oMV21P3xXM43msiDVR-aeBkAYXm6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