@@ -5189,7 +5189,7 @@ void llvm::embedBitcodeInModule(llvm::Module &M, llvm::MemoryBufferRef Buf,
51895189 std::vector<uint8_t > YkModuleData;
51905190 if (YkAllocLLVMBCSection) {
51915191 // Write length field.
5192- size_t ModuleDataSize = ModuleData.size ();
5192+ uint64_t ModuleDataSize = ModuleData.size ();
51935193 uint8_t *Bytes = reinterpret_cast <uint8_t *>(&ModuleDataSize);
51945194 for (size_t I = 0 ; I < sizeof (ModuleDataSize); I++)
51955195 YkModuleData.push_back (Bytes[I]);
@@ -5208,9 +5208,18 @@ void llvm::embedBitcodeInModule(llvm::Module &M, llvm::MemoryBufferRef Buf,
52085208 llvm::GlobalVariable *GV = new llvm::GlobalVariable (
52095209 M, ModuleConstant->getType (), true , SymLinkage, ModuleConstant);
52105210 GV->setSection (getSectionNameForBitcode (T));
5211- // Set alignment to 1 to prevent padding between two contributions from input
5212- // sections after linking.
5213- GV->setAlignment (Align (1 ));
5211+
5212+ if (YkAllocLLVMBCSection) {
5213+ // For Yk there will only ever be one embedded (LTO'd) module. This gives
5214+ // us the freedom to align the section so that we can read our size header
5215+ // without issue.
5216+ GV->setAlignment (Align (sizeof (uint64_t )));
5217+ } else {
5218+ // Set alignment to 1 to prevent padding between two contributions from input
5219+ // sections after linking.
5220+ GV->setAlignment (Align (1 ));
5221+ }
5222+
52145223 UsedArray.push_back (
52155224 ConstantExpr::getPointerBitCastOrAddrSpaceCast (GV, UsedElementType));
52165225 if (llvm::GlobalVariable *Old =
0 commit comments