Follow-up to https://reviews.llvm.org/D112643. Even after that change, we were
still asserting if two separate functions that are eligible for ICF (same size,
same data, same number of relocs, same reloc types, ...) referred to
Undefineds. This fixes that oversight.
Differential Revision: https://reviews.llvm.org/D114195
if (sa->kind() != sb->kind())
return false;
if (!isa<Defined>(sa)) {
- assert(isa<DylibSymbol>(sa));
+ // ICF runs before Undefineds are reported.
+ assert(isa<DylibSymbol>(sa) || isa<Undefined>(sa));
return sa == sb;
}
const auto *da = cast<Defined>(sa);
} else {
hash += defined->value;
}
- } else if (!isa<Undefined>(sym))
+ } else if (!isa<Undefined>(sym)) // ICF runs before Undefined diags.
llvm_unreachable("foldIdenticalSections symbol kind");
}
}
retq
#--- main.s
-.globl _main
.text
+
+_anotherref:
+ callq _foo
+ movq $0, %rax
+ retq
+
+.globl _main
_main:
callq _foo
movq $0, %rax
retq
+
+.subsections_via_symbols