@@ -356,23 +356,23 @@ class MD5Stream : public llvm::raw_ostream {
356
356
357
357
// / Computes the MD5 hash of the llvm \p Module including the compiler version
358
358
// / and options which influence the compilation.
359
- static void getHashOfModule (MD5::MD5Result &Result, const IRGenOptions &Opts,
360
- const llvm::Module *Module,
361
- llvm::TargetMachine *TargetMachine,
362
- version::Version const & effectiveLanguageVersion) {
359
+ static MD5::MD5Result getHashOfModule (const IRGenOptions &Opts,
360
+ const llvm::Module *Module) {
363
361
// Calculate the hash of the whole llvm module.
364
362
MD5Stream HashStream;
365
363
llvm::WriteBitcodeToFile (*Module, HashStream);
366
364
367
365
// Update the hash with the compiler version. We want to recompile if the
368
366
// llvm pipeline of the compiler changed.
369
- HashStream << version::getSwiftFullVersion (effectiveLanguageVersion );
367
+ HashStream << version::getSwiftFullVersion ();
370
368
371
369
// Add all options which influence the llvm compilation but are not yet
372
370
// reflected in the llvm module itself.
373
371
Opts.writeLLVMCodeGenOptionsTo (HashStream);
374
372
375
- HashStream.final (Result);
373
+ MD5::MD5Result result;
374
+ HashStream.final (result);
375
+ return result;
376
376
}
377
377
378
378
// / Returns false if the hash of the current module \p HashData matches the
@@ -477,27 +477,24 @@ bool swift::performLLVM(const IRGenOptions &Opts,
477
477
llvm::GlobalVariable *HashGlobal,
478
478
llvm::Module *Module,
479
479
llvm::TargetMachine *TargetMachine,
480
- const version::Version &effectiveLanguageVersion,
481
480
StringRef OutputFilename,
482
481
UnifiedStatsReporter *Stats) {
483
482
484
483
if (Opts.UseIncrementalLLVMCodeGen && HashGlobal) {
485
484
// Check if we can skip the llvm part of the compilation if we have an
486
485
// existing object file which was generated from the same llvm IR.
487
- MD5::MD5Result Result;
488
- getHashOfModule (Result, Opts, Module, TargetMachine,
489
- effectiveLanguageVersion);
486
+ auto hash = getHashOfModule (Opts, Module);
490
487
491
488
LLVM_DEBUG (
492
489
if (DiagMutex) DiagMutex->lock ();
493
490
SmallString<32 > ResultStr;
494
- MD5::stringifyResult (Result , ResultStr);
491
+ MD5::stringifyResult (hash , ResultStr);
495
492
llvm::dbgs () << OutputFilename << " : MD5=" << ResultStr << ' \n ' ;
496
493
if (DiagMutex) DiagMutex->unlock ();
497
494
);
498
495
499
- ArrayRef<uint8_t > HashData (reinterpret_cast <uint8_t *>(&Result ),
500
- sizeof (Result ));
496
+ ArrayRef<uint8_t > HashData (reinterpret_cast <uint8_t *>(&hash ),
497
+ sizeof (hash ));
501
498
if (Opts.OutputKind == IRGenOutputKind::ObjectFile &&
502
499
!Opts.PrintInlineTree &&
503
500
!needsRecompile (OutputFilename, HashData, HashGlobal, DiagMutex)) {
@@ -1003,7 +1000,6 @@ GeneratedModule IRGenRequest::evaluate(Evaluator &evaluator,
1003
1000
// Since no out module hash was set, we need to performLLVM.
1004
1001
if (performLLVM (Opts, IGM.Context .Diags , nullptr , IGM.ModuleHash ,
1005
1002
IGM.getModule (), IGM.TargetMachine .get (),
1006
- IGM.Context .LangOpts .EffectiveLanguageVersion ,
1007
1003
IGM.OutputFilename , IGM.Context .Stats ))
1008
1004
return GeneratedModule::null ();
1009
1005
}
@@ -1038,7 +1034,6 @@ struct LLVMCodeGenThreads {
1038
1034
embedBitcode (IGM->getModule (), parent.irgen ->Opts );
1039
1035
performLLVM (parent.irgen ->Opts , IGM->Context .Diags , diagMutex,
1040
1036
IGM->ModuleHash , IGM->getModule (), IGM->TargetMachine .get (),
1041
- IGM->Context .LangOpts .EffectiveLanguageVersion ,
1042
1037
IGM->OutputFilename , IGM->Context .Stats );
1043
1038
if (IGM->Context .Diags .hadAnyError ())
1044
1039
return ;
@@ -1389,7 +1384,6 @@ swift::createSwiftModuleObjectFile(SILModule &SILMod, StringRef Buffer,
1389
1384
ASTSym->setAlignment (llvm::MaybeAlign (serialization::SWIFTMODULE_ALIGNMENT));
1390
1385
::performLLVM (Opts, Ctx.Diags, nullptr , nullptr , IGM.getModule(),
1391
1386
IGM.TargetMachine.get(),
1392
- Ctx.LangOpts.EffectiveLanguageVersion,
1393
1387
OutputPath, Ctx.Stats);
1394
1388
}
1395
1389
@@ -1407,7 +1401,6 @@ bool swift::performLLVM(const IRGenOptions &Opts, ASTContext &Ctx,
1407
1401
embedBitcode (Module, Opts);
1408
1402
if (::performLLVM (Opts, Ctx.Diags , nullptr , nullptr , Module,
1409
1403
TargetMachine.get (),
1410
- Ctx.LangOpts .EffectiveLanguageVersion ,
1411
1404
OutputFilename, Ctx.Stats ))
1412
1405
return true ;
1413
1406
return false ;
0 commit comments