Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An error occurred when slicing C++ code using llvm-slicedr : Declaration may not be in a Comdat! #461

Open
ambrosecm opened this issue Dec 11, 2024 · 5 comments

Comments

@ambrosecm
Copy link

An error occurs when I slice C++ code following the documentation flow: Declaration may not be in a Comdat! . The complete error information is as follows

How can I solve this problem

SC: Matched '_ZN11HeifContext14read_from_fileEPKc()' to: 
    call void @_ZN11HeifContext14read_from_fileEPKc(%class.Error* sret %8, %class.HeifContext* %14, i8* %15), !dbg !17783
 ... and  1 more
[llvm-slicer] cutoff 1 diverging blocks and 488 completely removed
[llvm-slicer] CPU time of pointer analysis: 7.940000e-04 s
[llvm-slicer] CPU time of data dependence analysis: 1.750000e-04 s
[llvm-slicer] CPU time of control dependence analysis: 4.700000e-05 s
[llvm-slicer] Finding dependent nodes took 0 sec 0 ms
[llvm-slicer] Slicing dependence graph took 0 sec 0 ms
[llvm-slicer] Sliced away 11 from 49 nodes in DG
Declaration may not be in a Comdat!
void (%"class.std::set"*)* @_ZNSt3setIjSt4lessIjESaIjEED2Ev
Declaration may not be in a Comdat!
void (%"class.std::_Sp_counted_ptr_inplace"*)* @_ZNSt23_Sp_counted_ptr_inplaceI19StreamReader_memorySaIS0_ELN9__gnu_cxx12_Lock_policyE2EED2Ev
Declaration may not be in a Comdat!
void (%"class.std::_Sp_counted_ptr_inplace"*)* @_ZNSt23_Sp_counted_ptr_inplaceI19StreamReader_memorySaIS0_ELN9__gnu_cxx12_Lock_policyE2EED0Ev
Declaration may not be in a Comdat!
void (%"class.std::_Sp_counted_ptr_inplace"*)* @_ZNSt23_Sp_counted_ptr_inplaceI19StreamReader_memorySaIS0_ELN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv
Declaration may not be in a Comdat!
void (%"class.std::_Sp_counted_ptr_inplace"*)* @_ZNSt23_Sp_counted_ptr_inplaceI19StreamReader_memorySaIS0_ELN9__gnu_cxx12_Lock_policyE2EE10_M_destroyEv
Declaration may not be in a Comdat!
i8* (%"class.std::_Sp_counted_ptr_inplace"*, %"class.std::type_info"*)* @_ZNSt23_Sp_counted_ptr_inplaceI19StreamReader_memorySaIS0_ELN9__gnu_cxx12_Lock_policyE2EE14_M_get_deleterERKSt9type_info
Declaration may not be in a Comdat!
void (%"class.std::_Sp_counted_base"*)* @_ZNSt16_Sp_counted_baseILN9__gnu_cxx12_Lock_policyE2EED2Ev
Declaration may not be in a Comdat!
void (%"class.std::_Sp_counted_base"*)* @_ZNSt16_Sp_counted_baseILN9__gnu_cxx12_Lock_policyE2EED0Ev
Declaration may not be in a Comdat!
void (%"class.std::_Sp_counted_base"*)* @_ZNSt16_Sp_counted_baseILN9__gnu_cxx12_Lock_policyE2EE10_M_destroyEv
Declaration may not be in a Comdat!
void (%"class.std::_Sp_counted_ptr_inplace.231"*)* @_ZNSt23_Sp_counted_ptr_inplaceI11HeifContextSaIS0_ELN9__gnu_cxx12_Lock_policyE2EED2Ev
Declaration may not be in a Comdat!
void (%"class.std::_Sp_counted_ptr_inplace.231"*)* @_ZNSt23_Sp_counted_ptr_inplaceI11HeifContextSaIS0_ELN9__gnu_cxx12_Lock_policyE2EED0Ev
Declaration may not be in a Comdat!
void (%"class.std::_Sp_counted_ptr_inplace.231"*)* @_ZNSt23_Sp_counted_ptr_inplaceI11HeifContextSaIS0_ELN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv
Declaration may not be in a Comdat!
void (%"class.std::_Sp_counted_ptr_inplace.231"*)* @_ZNSt23_Sp_counted_ptr_inplaceI11HeifContextSaIS0_ELN9__gnu_cxx12_Lock_policyE2EE10_M_destroyEv
Declaration may not be in a Comdat!
i8* (%"class.std::_Sp_counted_ptr_inplace.231"*, %"class.std::type_info"*)* @_ZNSt23_Sp_counted_ptr_inplaceI11HeifContextSaIS0_ELN9__gnu_cxx12_Lock_policyE2EE14_M_get_deleterERKSt9type_info
Declaration may not be in a Comdat!
void (%"class.std::_Sp_counted_ptr_inplace.244"*)* @_ZNSt23_Sp_counted_ptr_inplaceI17StreamReader_CApiSaIS0_ELN9__gnu_cxx12_Lock_policyE2EED2Ev
Declaration may not be in a Comdat!
void (%"class.std::_Sp_counted_ptr_inplace.244"*)* @_ZNSt23_Sp_counted_ptr_inplaceI17StreamReader_CApiSaIS0_ELN9__gnu_cxx12_Lock_policyE2EED0Ev
Declaration may not be in a Comdat!
void (%"class.std::_Sp_counted_ptr_inplace.244"*)* @_ZNSt23_Sp_counted_ptr_inplaceI17StreamReader_CApiSaIS0_ELN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv
Declaration may not be in a Comdat!
void (%"class.std::_Sp_counted_ptr_inplace.244"*)* @_ZNSt23_Sp_counted_ptr_inplaceI17StreamReader_CApiSaIS0_ELN9__gnu_cxx12_Lock_policyE2EE10_M_destroyEv
Declaration may not be in a Comdat!
i8* (%"class.std::_Sp_counted_ptr_inplace.244"*, %"class.std::type_info"*)* @_ZNSt23_Sp_counted_ptr_inplaceI17StreamReader_CApiSaIS0_ELN9__gnu_cxx12_Lock_policyE2EE14_M_get_deleterERKSt9type_info
Declaration may not be in a Comdat!
void (%"class.std::_Sp_counted_ptr_inplace.257"*)* @_ZNSt23_Sp_counted_ptr_inplaceI14HeifPixelImageSaIS0_ELN9__gnu_cxx12_Lock_policyE2EED2Ev
Declaration may not be in a Comdat!
void (%"class.std::_Sp_counted_ptr_inplace.257"*)* @_ZNSt23_Sp_counted_ptr_inplaceI14HeifPixelImageSaIS0_ELN9__gnu_cxx12_Lock_policyE2EED0Ev
Declaration may not be in a Comdat!
void (%"class.std::_Sp_counted_ptr_inplace.257"*)* @_ZNSt23_Sp_counted_ptr_inplaceI14HeifPixelImageSaIS0_ELN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv
Declaration may not be in a Comdat!
void (%"class.std::_Sp_counted_ptr_inplace.257"*)* @_ZNSt23_Sp_counted_ptr_inplaceI14HeifPixelImageSaIS0_ELN9__gnu_cxx12_Lock_policyE2EE10_M_destroyEv
Declaration may not be in a Comdat!
i8* (%"class.std::_Sp_counted_ptr_inplace.257"*, %"class.std::type_info"*)* @_ZNSt23_Sp_counted_ptr_inplaceI14HeifPixelImageSaIS0_ELN9__gnu_cxx12_Lock_policyE2EE14_M_get_deleterERKSt9type_info
Declaration may not be in a Comdat!
void (%"class.std::_Sp_counted_ptr_inplace.270"*)* @_ZNSt23_Sp_counted_ptr_inplaceI17color_profile_rawSaIS0_ELN9__gnu_cxx12_Lock_policyE2EED2Ev
Declaration may not be in a Comdat!
void (%"class.std::_Sp_counted_ptr_inplace.270"*)* @_ZNSt23_Sp_counted_ptr_inplaceI17color_profile_rawSaIS0_ELN9__gnu_cxx12_Lock_policyE2EED0Ev
Declaration may not be in a Comdat!
void (%"class.std::_Sp_counted_ptr_inplace.270"*)* @_ZNSt23_Sp_counted_ptr_inplaceI17color_profile_rawSaIS0_ELN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv
Declaration may not be in a Comdat!
void (%"class.std::_Sp_counted_ptr_inplace.270"*)* @_ZNSt23_Sp_counted_ptr_inplaceI17color_profile_rawSaIS0_ELN9__gnu_cxx12_Lock_policyE2EE10_M_destroyEv
Declaration may not be in a Comdat!
i8* (%"class.std::_Sp_counted_ptr_inplace.270"*, %"class.std::type_info"*)* @_ZNSt23_Sp_counted_ptr_inplaceI17color_profile_rawSaIS0_ELN9__gnu_cxx12_Lock_policyE2EE14_M_get_deleterERKSt9type_info
Declaration may not be in a Comdat!
void (%class.color_profile*)* @_ZN13color_profileD2Ev
Declaration may not be in a Comdat!
void (%class.color_profile*)* @_ZN13color_profileD0Ev
Declaration may not be in a Comdat!
void (%"class.std::_Sp_counted_ptr_inplace.281"*)* @_ZNSt23_Sp_counted_ptr_inplaceI18color_profile_nclxSaIS0_ELN9__gnu_cxx12_Lock_policyE2EED2Ev
Declaration may not be in a Comdat!
void (%"class.std::_Sp_counted_ptr_inplace.281"*)* @_ZNSt23_Sp_counted_ptr_inplaceI18color_profile_nclxSaIS0_ELN9__gnu_cxx12_Lock_policyE2EED0Ev
Declaration may not be in a Comdat!
void (%"class.std::_Sp_counted_ptr_inplace.281"*)* @_ZNSt23_Sp_counted_ptr_inplaceI18color_profile_nclxSaIS0_ELN9__gnu_cxx12_Lock_policyE2EE10_M_disposeEv
Declaration may not be in a Comdat!
void (%"class.std::_Sp_counted_ptr_inplace.281"*)* @_ZNSt23_Sp_counted_ptr_inplaceI18color_profile_nclxSaIS0_ELN9__gnu_cxx12_Lock_policyE2EE10_M_destroyEv
Declaration may not be in a Comdat!
i8* (%"class.std::_Sp_counted_ptr_inplace.281"*, %"class.std::type_info"*)* @_ZNSt23_Sp_counted_ptr_inplaceI18color_profile_nclxSaIS0_ELN9__gnu_cxx12_Lock_policyE2EE14_M_get_deleterERKSt9type_info
[llvm-slicer] ERROR: Verifying module failed, the IR is not valid
[llvm-slicer] Saving anyway so that you can check it
@mchalupa
Copy link
Owner

DG does not support C++ in general. But to solve this particular issue might be possible, you could try forbidding slicing away functions that are mentioned in Comdat. Or event simpler, try not removing any unused functions or globals, a starting point would be this method:

void removeUnusedFromModule() {
.

@ambrosecm
Copy link
Author

Thank you for your answer. What should I do specifically, should I modify the source code of DG?

@mchalupa
Copy link
Owner

Thank you for your answer. What should I do specifically, should I modify the source code of DG?

Yes, that is what I meant. For starters, you may try removing all calls to the method removeUnusedFromModule.

@ambrosecm
Copy link
Author

Wouldn't doing this have a impact on the slicing effect? Will it might include a lot of code that shouldn't be there?

@mchalupa
Copy link
Owner

mchalupa commented Dec 12, 2024

Nope, this method removes only functions and globals that are not used in the reachable part of the sliced code. It does just a kind of a cleanup.

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

No branches or pull requests

2 participants