@@ -5189,7 +5189,7 @@ void llvm::embedBitcodeInModule(llvm::Module &M, llvm::MemoryBufferRef Buf,
5189
5189
std::vector<uint8_t > YkModuleData;
5190
5190
if (YkAllocLLVMBCSection) {
5191
5191
// Write length field.
5192
- size_t ModuleDataSize = ModuleData.size ();
5192
+ uint64_t ModuleDataSize = ModuleData.size ();
5193
5193
uint8_t *Bytes = reinterpret_cast <uint8_t *>(&ModuleDataSize);
5194
5194
for (size_t I = 0 ; I < sizeof (ModuleDataSize); I++)
5195
5195
YkModuleData.push_back (Bytes[I]);
@@ -5208,9 +5208,18 @@ void llvm::embedBitcodeInModule(llvm::Module &M, llvm::MemoryBufferRef Buf,
5208
5208
llvm::GlobalVariable *GV = new llvm::GlobalVariable (
5209
5209
M, ModuleConstant->getType (), true , SymLinkage, ModuleConstant);
5210
5210
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
+
5214
5223
UsedArray.push_back (
5215
5224
ConstantExpr::getPointerBitCastOrAddrSpaceCast (GV, UsedElementType));
5216
5225
if (llvm::GlobalVariable *Old =
0 commit comments