Skip to content
This repository has been archived by the owner on Jan 17, 2019. It is now read-only.

Commit

Permalink
LTO: Drop comdats when converting definitions to declarations.
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D42715

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@323844 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
pcc committed Jan 31, 2018
1 parent 0b03560 commit b359cf7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/Transforms/IPO/FunctionImport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,10 +618,12 @@ void llvm::convertToDeclaration(GlobalValue &GV) {
if (Function *F = dyn_cast<Function>(&GV)) {
F->deleteBody();
F->clearMetadata();
F->setComdat(nullptr);
} else if (GlobalVariable *V = dyn_cast<GlobalVariable>(&GV)) {
V->setInitializer(nullptr);
V->setLinkage(GlobalValue::ExternalLinkage);
V->clearMetadata();
V->setComdat(nullptr);
} else
// For now we don't resolve or drop aliases. Once we do we'll
// need to add support here for creating either a function or
Expand Down
3 changes: 2 additions & 1 deletion test/LTO/Resolution/X86/not-prevailing.ll
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

define weak i32 @foo() {
$foo = comdat any
define weak i32 @foo() comdat {
ret i32 65
}

Expand Down

0 comments on commit b359cf7

Please sign in to comment.