LTO: Change signature of LTOCodeGenerator::setCodePICModel() to take a Reloc::Model.
This allows us to remove a bunch of code in LTOCodeGenerator and llvm-lto
and has the side effect of improving error handling in the libLTO C API.
llvm-svn: 245756
diff --git a/llvm/tools/lto/lto.cpp b/llvm/tools/lto/lto.cpp
index 5c712f1..aebb1c6 100644
--- a/llvm/tools/lto/lto.cpp
+++ b/llvm/tools/lto/lto.cpp
@@ -269,8 +269,22 @@
}
bool lto_codegen_set_pic_model(lto_code_gen_t cg, lto_codegen_model model) {
- unwrap(cg)->setCodePICModel(model);
- return false;
+ switch (model) {
+ case LTO_CODEGEN_PIC_MODEL_STATIC:
+ unwrap(cg)->setCodePICModel(Reloc::Static);
+ return false;
+ case LTO_CODEGEN_PIC_MODEL_DYNAMIC:
+ unwrap(cg)->setCodePICModel(Reloc::PIC_);
+ return false;
+ case LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC:
+ unwrap(cg)->setCodePICModel(Reloc::DynamicNoPIC);
+ return false;
+ case LTO_CODEGEN_PIC_MODEL_DEFAULT:
+ unwrap(cg)->setCodePICModel(Reloc::Default);
+ return false;
+ }
+ sLastErrorString = "Unknown PIC model";
+ return true;
}
void lto_codegen_set_cpu(lto_code_gen_t cg, const char *cpu) {