[PATCH] D114195: [lld/mac] Crash even less on undefined symbols with --icf=all
Nico Weber via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 19 06:23:57 PST 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbc20bcb39e02: [lld/mac] Crash even less on undefined symbols with --icf=all (authored by thakis).
Herald added a project: LLVM.
Changed prior to commit:
https://reviews.llvm.org/D114195?vs=388318&id=388486#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D114195/new/
https://reviews.llvm.org/D114195
Files:
lld/MachO/ICF.cpp
lld/test/MachO/invalid/undefined-symbol.s
Index: lld/test/MachO/invalid/undefined-symbol.s
===================================================================
--- lld/test/MachO/invalid/undefined-symbol.s
+++ lld/test/MachO/invalid/undefined-symbol.s
@@ -20,9 +20,17 @@
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
Index: lld/MachO/ICF.cpp
===================================================================
--- lld/MachO/ICF.cpp
+++ lld/MachO/ICF.cpp
@@ -114,7 +114,8 @@
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);
@@ -275,7 +276,7 @@
} else {
hash += defined->value;
}
- } else if (!isa<Undefined>(sym))
+ } else if (!isa<Undefined>(sym)) // ICF runs before Undefined diags.
llvm_unreachable("foldIdenticalSections symbol kind");
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D114195.388486.patch
Type: text/x-patch
Size: 1206 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211119/8ca5f8f7/attachment.bin>
More information about the llvm-commits
mailing list