From a71002e7f1be2382d4014763124b936d75cf61fd Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Sun, 14 Aug 2016 00:01:27 +0000 Subject: [PATCH] Fix bitcode auto-upgrade when using bitcode lazy loading The auto-upgrade path could be called before the VST (global names) was fully parsed, and thus intrinsic names were not available and the autoupgrade logic could not operate. Fix link failures with ThinLTO. This is a recommit of r278610 with a different fix. llvm-svn: 278615 --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 4 +++- llvm/test/ThinLTO/X86/Inputs/autoupgrade.bc | Bin 0 -> 1024 bytes llvm/test/ThinLTO/X86/autoupgrade.ll | 23 +++++++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 llvm/test/ThinLTO/X86/Inputs/autoupgrade.bc create mode 100644 llvm/test/ThinLTO/X86/autoupgrade.ll diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 9bb8b2f..3084410 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -3682,7 +3682,9 @@ std::error_code BitcodeReader::parseModule(uint64_t ResumeBit, // have been seen yet. In this case, just finish the parse now. if (SeenValueSymbolTable) { NextUnreadBit = Stream.GetCurrentBitNo(); - return std::error_code(); + // After the VST has been parsed, we need to make sure intrinsic name + // are auto-upgraded. + return globalCleanup(); } break; case bitc::USELIST_BLOCK_ID: diff --git a/llvm/test/ThinLTO/X86/Inputs/autoupgrade.bc b/llvm/test/ThinLTO/X86/Inputs/autoupgrade.bc new file mode 100644 index 0000000000000000000000000000000000000000..578b33796fa39f6f845ce95fed57e0ef00ef1572 GIT binary patch literal 1024 zcmX|APiWg#7=Nm4JvDY@xfYwV%0{+RmP25kvo`h=4_oSjOEPe}P|7Z~LmIL}hvFE= zaeI&>HP2mqa7!6xlwq@Ou))A%JM7Ryngk{~w|HTc973pxTgu3SDIN4s*q)MXAH47P zz4!h9_}K)n!{<2(00e-L?`|JR`z-U_%z%h(2d|)wf zGj3SUQEVu3i_q<-taP8(vNENzA0Cr#*(99}abem$))SISi3%skqor>^Ur6dCn2OWC zk&I6i%WduH=N8{6HQ@%piesKE#lRQ6%iVu4ku6HK;J0&FN0>SF7`Pz-(2M1epFS>3 zU$?mYcXiBm^?HRnFKac-7pU(8JdOR|yS7S-udHHCJ43^~ z3UdSK%q&veXrT(PmB_H7g-hhHs`Xw@GFMtmq03yUFu52kq+qs1JyW4lgL4ARx2Sy; z7Fd|8!Fl0G`x6T@DwMy%wf#rSBWBe{WM5w%ee zvPnh_Ia(&8&3rklz^gP|Odv&p1%=Gzks_eJrjyyLFzuk@v!G+Q%XE{>5WC^o@$p+e z&sy3$6TBhb)5Mk>`I#KKr;X^O*z9t-6udeMhi6d+a}_BSq@?iZVD6O_hh0$7B^u4S zQKpI(tHr_nF0=oH`FoYw3zAbto$u87<^kVM^ACLdM$z*iO+Bv25krnt5BM+Z;oCAE zym)*49h~&_lK2NHHrDOGeu|WfD5GfES(s0utQ%!(sPECoj(y;Gkz_g*W;f<&3(Oww zLKyID-}kP?y_-IMyXf71!gt!9KMC)Qdm`MB-@l`Y&1C;kBPq0yhj~2b@9)>z~p)oN#uTbq4yM0$*q} zVUW@^?F87)da(Tf%wgHA<2=Lqr