Skip to content

Commit 665100d

Browse files
committed
[IRGen] Teach defineAlias to replace useds.
Previously, it was possible to alias an old LinkEntity which was marked used (i.e. in LLVMUsed) or compiler used (i.e. in LLVMCompilerUsed). The result of defining such an alias was a failure downstream when writing out the lists of globals. Here, the old value is removed from the list before it is invalidated.
1 parent f74502e commit 665100d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

lib/IRGen/GenDecl.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3853,6 +3853,19 @@ llvm::GlobalValue *IRGenModule::defineAlias(LinkEntity entity,
38533853
if (entry) {
38543854
auto existingVal = cast<llvm::GlobalValue>(entry);
38553855

3856+
for (auto iterator = std::begin(LLVMUsed); iterator < std::end(LLVMUsed); ++iterator) {
3857+
llvm::Value *thisValue = *iterator;
3858+
if (thisValue == existingVal) {
3859+
LLVMUsed.erase(iterator);
3860+
}
3861+
}
3862+
for (auto iterator = std::begin(LLVMCompilerUsed); iterator < std::end(LLVMCompilerUsed); ++iterator) {
3863+
llvm::Value *thisValue = *iterator;
3864+
if (thisValue == existingVal) {
3865+
LLVMCompilerUsed.erase(iterator);
3866+
}
3867+
}
3868+
38563869
// FIXME: MC breaks when emitting alias references on some platforms
38573870
// (rdar://problem/22450593 ). Work around this by referring to the aliasee
38583871
// instead.

0 commit comments

Comments
 (0)