@@ -77,9 +77,10 @@ uint32_t ICF::getHash(SectionChunk *C) {
77
77
// 2017) says that /opt:icf folds both functions and read-only data.
78
78
// Despite that, the MSVC linker folds only functions. We found
79
79
// a few instances of programs that are not safe for data merging.
80
- // Therefore, we merge only functions just like the MSVC tool. However, we merge
81
- // identical .xdata sections, because the address of unwind information is
82
- // insignificant to the user program and the Visual C++ linker does this.
80
+ // Therefore, we merge only functions just like the MSVC tool. However, we also
81
+ // merge read-only sections in a couple of cases where the address of the
82
+ // section is insignificant to the user program and the behaviour matches that
83
+ // of the Visual C++ linker.
83
84
bool ICF::isEligible (SectionChunk *C) {
84
85
// Non-comdat chunks, dead chunks, and writable chunks are not elegible.
85
86
bool Writable = C->getOutputCharacteristics () & llvm::COFF::IMAGE_SCN_MEM_WRITE;
@@ -90,8 +91,12 @@ bool ICF::isEligible(SectionChunk *C) {
90
91
if (C->getOutputCharacteristics () & llvm::COFF::IMAGE_SCN_MEM_EXECUTE)
91
92
return true ;
92
93
93
- // .xdata unwind info sections are eligble.
94
- return C->getSectionName ().split (' $' ).first == " .xdata" ;
94
+ // .xdata unwind info sections are eligible.
95
+ if (C->getSectionName ().split (' $' ).first == " .xdata" )
96
+ return true ;
97
+
98
+ // So are vtables.
99
+ return C->Sym && C->Sym ->getName ().startswith (" ??_7" );
95
100
}
96
101
97
102
// Split an equivalence class into smaller classes.
0 commit comments