Skip to content

Commit a7260f9

Browse files
committed
LLVM 6: Adapt to LLVM CodeModel cmdline option now exposed as llvm::Optional
1 parent fcbf99d commit a7260f9

File tree

6 files changed

+22
-5
lines changed

6 files changed

+22
-5
lines changed

driver/cache.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,13 @@ void outputIR2ObjRelevantCmdlineArgs(llvm::raw_ostream &hash_os) {
312312
#else
313313
hash_os << opts::getRelocModel();
314314
#endif
315+
#if LDC_LLVM_VER >= 600
316+
const auto codeModel = opts::getCodeModel();
317+
if (codeModel.hasValue())
318+
hash_os << codeModel.getValue();
319+
#else
315320
hash_os << opts::getCodeModel();
321+
#endif
316322
hash_os << opts::disableFPElim();
317323
}
318324

driver/cl_options-llvm.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ Optional<Reloc::Model> getRelocModel() { return ::getRelocModel(); }
3333
Reloc::Model getRelocModel() { return ::RelocModel; }
3434
#endif
3535

36+
#if LDC_LLVM_VER >= 600
37+
Optional<CodeModel::Model> getCodeModel() { return ::getCodeModel(); }
38+
#else
3639
CodeModel::Model getCodeModel() { return ::CMModel; }
40+
#endif
3741

3842
cl::boolOrDefault disableFPElim() {
3943
return ::DisableFPElim.getNumOccurrences() == 0
@@ -67,6 +71,12 @@ TargetOptions InitTargetOptionsFromCodeGenFlags() {
6771
return ::InitTargetOptionsFromCodeGenFlags();
6872
}
6973

70-
CodeModel::Model GetCodeModelFromCMModel() { return CMModel; }
74+
#if LDC_LLVM_VER >= 600
75+
Optional<CodeModel::Model> GetCodeModelFromCMModel() {
76+
return ::getCodeModel();
77+
}
78+
#else
79+
CodeModel::Model GetCodeModelFromCMModel() { return ::CMModel; }
80+
#endif
7181
}
7282
#endif // LDC_WITH_LLD && LDC_LLVM_VER >= 500

driver/cl_options-llvm.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ llvm::Optional<llvm::Reloc::Model> getRelocModel();
2323
#else
2424
llvm::Reloc::Model getRelocModel();
2525
#endif
26+
#if LDC_LLVM_VER >= 600
27+
llvm::Optional<llvm::CodeModel::Model> getCodeModel();
28+
#else
2629
llvm::CodeModel::Model getCodeModel();
30+
#endif
2731
llvm::cl::boolOrDefault disableFPElim();
2832
bool disableRedZone();
2933
bool printTargetFeaturesHelp();

driver/main.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,8 +1036,7 @@ int cppmain(int argc, char **argv) {
10361036

10371037
gTargetMachine = createTargetMachine(
10381038
mTargetTriple, arch, opts::getCPUStr(), opts::getFeaturesStr(), bitness,
1039-
floatABI, relocModel, opts::getCodeModel(), codeGenOptLevel(),
1040-
disableLinkerStripDead);
1039+
floatABI, relocModel, codeGenOptLevel(), disableLinkerStripDead);
10411040

10421041
opts::setDefaultMathOptions(gTargetMachine->Options);
10431042

driver/targetmachine.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,6 @@ createTargetMachine(const std::string targetTriple, const std::string arch,
351351
#else
352352
llvm::Reloc::Model relocModel,
353353
#endif
354-
const llvm::CodeModel::Model codeModel,
355354
const llvm::CodeGenOpt::Level codeGenOptLevel,
356355
const bool noLinkerStripDead) {
357356
// Determine target triple. If the user didn't explicitly specify one, use

driver/targetmachine.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ createTargetMachine(std::string targetTriple, std::string arch, std::string cpu,
6262
#else
6363
llvm::Reloc::Model relocModel,
6464
#endif
65-
llvm::CodeModel::Model codeModel,
6665
llvm::CodeGenOpt::Level codeGenOptLevel,
6766
bool noLinkerStripDead);
6867

0 commit comments

Comments
 (0)