Skip to content

Commit 2dc874b

Browse files
authored
Merge pull request #8250 from compnerd/hash
IRGen: fix construction of ArrayRef
2 parents 79bf6e4 + 70771a8 commit 2dc874b

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/IRGen/IRGen.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,8 @@ bool swift::performLLVM(IRGenOptions &Opts, DiagnosticEngine *Diags,
377377
if (DiagMutex) DiagMutex->unlock();
378378
);
379379

380-
ArrayRef<uint8_t> HashData(Result, sizeof(MD5::MD5Result));
380+
ArrayRef<uint8_t> HashData(reinterpret_cast<uint8_t *>(&Result),
381+
sizeof(Result));
381382
if (Opts.OutputKind == IRGenOutputKind::ObjectFile &&
382383
!Opts.PrintInlineTree &&
383384
!needsRecompile(OutputFilename, HashData, HashGlobal, DiagMutex)) {

lib/IRGen/IRGenModule.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,8 +1058,8 @@ bool IRGenModule::finalize() {
10581058
// We have to create the variable now (before we emit the global lists).
10591059
// But we want to calculate the hash later because later we can do it
10601060
// multi-threaded.
1061-
llvm::MD5::MD5Result zero = { 0 };
1062-
ArrayRef<uint8_t> ZeroArr(zero, sizeof(llvm::MD5::MD5Result));
1061+
llvm::MD5::MD5Result zero{};
1062+
ArrayRef<uint8_t> ZeroArr(reinterpret_cast<uint8_t *>(&zero), sizeof(zero));
10631063
auto *ZeroConst = llvm::ConstantDataArray::get(Module.getContext(), ZeroArr);
10641064
ModuleHash = new llvm::GlobalVariable(Module, ZeroConst->getType(), true,
10651065
llvm::GlobalValue::PrivateLinkage,

0 commit comments

Comments
 (0)