Index: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp =================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp @@ -2831,6 +2831,13 @@ return Error::success(); } +static void inferDSOLocal(GlobalValue *GV) { + // infer dso_local from linkage and visibility if it is not encoded. + if (GV->hasLocalLinkage() || + (!GV->hasDefaultVisibility() && !GV->hasExternalWeakLinkage())) + GV->setDSOLocal(true); +} + Error BitcodeReader::parseGlobalVarRecord(ArrayRef Record) { // v1: [pointer type, isconst, initid, linkage, alignment, section, // visibility, threadlocal, unnamed_addr, externally_initialized, @@ -2923,6 +2930,7 @@ if (Record.size() > 13) { NewGV->setDSOLocal(getDecodedDSOLocal(Record[13])); } + inferDSOLocal(NewGV); return Error::success(); } @@ -3007,6 +3015,7 @@ if (Record.size() > 15) { Func->setDSOLocal(getDecodedDSOLocal(Record[15])); } + inferDSOLocal(Func); ValueList.push_back(Func); @@ -3083,6 +3092,8 @@ } if (OpNum != Record.size()) NewGA->setDSOLocal(getDecodedDSOLocal(Record[OpNum++])); + inferDSOLocal(NewGA); + ValueList.push_back(NewGA); IndirectSymbolInits.push_back(std::make_pair(NewGA, Val)); return Error::success(); Index: llvm/trunk/test/Bitcode/infer_dso_local.ll =================================================================== --- llvm/trunk/test/Bitcode/infer_dso_local.ll +++ llvm/trunk/test/Bitcode/infer_dso_local.ll @@ -0,0 +1,3 @@ +; RUN: opt -verify %S/Inputs/infer_dso_local.bc | llvm-dis | FileCheck %s + +; CHECK: define linkonce_odr hidden void @test()