diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2018-01-18 00:20:03 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2018-01-18 00:20:03 +0000 |
| commit | e1d705303225ec0c8be29974dc8dc04aabc86281 (patch) | |
| tree | dbff5a6955a894e8eb06a4a1dc6c7dd5b0f97c81 /clang/lib/CodeGen | |
| parent | e769fb73b583441e68c322a1a7811561b0c58c60 (diff) | |
| download | bcm5719-llvm-e1d705303225ec0c8be29974dc8dc04aabc86281.tar.gz bcm5719-llvm-e1d705303225ec0c8be29974dc8dc04aabc86281.zip | |
Use an enum value instead of a string.
The old StringSwitch use was also broken. It assumed that a
StringSwitch returns Optional<T> instead of T and was missing a
.Default.
llvm-svn: 322792
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/BackendUtil.cpp | 19 |
1 files changed, 2 insertions, 17 deletions
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index ef974946e1d..c7557236573 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -362,21 +362,6 @@ getCodeModel(const CodeGenOptions &CodeGenOpts) { return static_cast<llvm::CodeModel::Model>(CodeModel); } -static llvm::Reloc::Model getRelocModel(const CodeGenOptions &CodeGenOpts) { - // Keep this synced with the equivalent code in - // lib/Frontend/CompilerInvocation.cpp - llvm::Optional<llvm::Reloc::Model> RM; - RM = llvm::StringSwitch<llvm::Reloc::Model>(CodeGenOpts.RelocationModel) - .Case("static", llvm::Reloc::Static) - .Case("pic", llvm::Reloc::PIC_) - .Case("ropi", llvm::Reloc::ROPI) - .Case("rwpi", llvm::Reloc::RWPI) - .Case("ropi-rwpi", llvm::Reloc::ROPI_RWPI) - .Case("dynamic-no-pic", llvm::Reloc::DynamicNoPIC); - assert(RM.hasValue() && "invalid PIC model!"); - return *RM; -} - static TargetMachine::CodeGenFileType getCodeGenFileType(BackendAction Action) { if (Action == Backend_EmitObj) return TargetMachine::CGFT_ObjectFile; @@ -692,7 +677,7 @@ void EmitAssemblyHelper::CreateTargetMachine(bool MustCreateTM) { Optional<llvm::CodeModel::Model> CM = getCodeModel(CodeGenOpts); std::string FeaturesStr = llvm::join(TargetOpts.Features.begin(), TargetOpts.Features.end(), ","); - llvm::Reloc::Model RM = getRelocModel(CodeGenOpts); + llvm::Reloc::Model RM = CodeGenOpts.RelocationModel; CodeGenOpt::Level OptLevel = getCGOptLevel(CodeGenOpts); llvm::TargetOptions Options; @@ -1113,7 +1098,7 @@ static void runThinLTOBackend(ModuleSummaryIndex *CombinedIndex, Module *M, Conf.CPU = TOpts.CPU; Conf.CodeModel = getCodeModel(CGOpts); Conf.MAttrs = TOpts.Features; - Conf.RelocModel = getRelocModel(CGOpts); + Conf.RelocModel = CGOpts.RelocationModel; Conf.CGOptLevel = getCGOptLevel(CGOpts); initTargetOptions(Conf.Options, CGOpts, TOpts, LOpts, HeaderOpts); Conf.SampleProfile = std::move(SampleProfile); |

