[ThinLTO] WeakAny fixes/cleanup
Ensure WeakAny variables are imported as ExternalWeak declarations. To
handle WeakAny more consistently and fix this issue:
1) Update helper doImportAsDefinition to properly flag WeakAny variables
and aliases as not importing defintions.
Update callers of doImportAsDefinition to remove now redundant checks for
WeakAny aliases, or ignore aliases, as appropriate.
2) Add any !doImportAsDefinition GVs to DoNotLinkFromSource set during
linking of the GV prototype, where we usually add GVs to the
DoNotLinkFromSource set for other reasons.
Remove now unnecessary adding of WeakAny aliases to
DoNotLinkFromSource set from copyGlobalAliasProto.
Remove now unnecessary guard against linking non-imported function
bodies from ModuleLinker::run.
llvm-svn: 252626
diff --git a/llvm/test/Linker/funcimport.ll b/llvm/test/Linker/funcimport.ll
index 97a34ff..2efbc29 100644
--- a/llvm/test/Linker/funcimport.ll
+++ b/llvm/test/Linker/funcimport.ll
@@ -85,6 +85,7 @@
; reference should turned into an external_weak declaration.
; RUN: llvm-link %t2.bc -functionindex=%t3.thinlto.bc -import=callweakfunc:%t.bc -import=weakfunc:%t.bc -S 2>&1 | FileCheck %s --check-prefix=IMPORTWEAKFUNC
; IMPORTWEAKFUNC: Ignoring import request for weak-any function weakfunc
+; IMPORTWEAKFUNC: @weakvar = extern_weak global i32, align 4
; IMPORTWEAKFUNC: declare extern_weak void @weakfunc
; IMPORTWEAKFUNC: define available_externally void @callweakfunc
@@ -158,6 +159,7 @@
ret void
}
+@weakvar = weak global i32 1, align 4
define weak void @weakfunc() #0 {
entry:
ret void