D74751 added ClearDSOLocalOnDeclarations and dropped dso_local for
isDeclarationForLinker GlobalValues. It missed a case for imported
declarations (doImportAsDefinition is false while isPerformingImport is
true). This can lead to a linker error for a default visibility symbol in
ld.lld -shared.
When ClearDSOLocalOnDeclarations is true, we check
isPerformingImport() && !doImportAsDefinition(&GV) along with
GV.isDeclarationForLinker(). The new condition checks an imported declaration.
This patch fixes a LLVMPolly.so link error using a trunk clang -DLLVM_ENABLE_LTO=Thin.
Is the change of the return linkage type needed for this fix, or is it just the returning of IsImportedDeclaration?
Why not just invoke doImportAsDefinition() in the caller to get this info rather than setting IsImportedDeclaration here? There are also other cases below for other linkage types where we are importing as a declaration but the new var isn't set.