Index: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h =================================================================== --- llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h +++ llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h @@ -123,7 +123,7 @@ /// name is misleading). This function should be called before /// LTOCodeGenerator::compilexxx(), and /// LTOCodeGenerator::writeMergedModules(). - void setCodeGenDebugOptions(ArrayRef Opts); + void setCodeGenDebugOptions(ArrayRef Opts); /// Parse the options set in setCodeGenDebugOptions. /// Index: llvm/lib/LTO/LTOCodeGenerator.cpp =================================================================== --- llvm/lib/LTO/LTOCodeGenerator.cpp +++ llvm/lib/LTO/LTOCodeGenerator.cpp @@ -632,9 +632,9 @@ return true; } -void LTOCodeGenerator::setCodeGenDebugOptions(ArrayRef Options) { +void LTOCodeGenerator::setCodeGenDebugOptions(ArrayRef Options) { for (StringRef Option : Options) - CodegenOptions.push_back(std::string(Option)); + CodegenOptions.push_back(Option.str()); } void LTOCodeGenerator::parseCodeGenDebugOptions() { Index: llvm/tools/lto/lto.cpp =================================================================== --- llvm/tools/lto/lto.cpp +++ llvm/tools/lto/lto.cpp @@ -474,17 +474,20 @@ } void lto_codegen_debug_options(lto_code_gen_t cg, const char *opt) { - std::vector Options; + SmallVector Options; for (std::pair o = getToken(opt); !o.first.empty(); o = getToken(o.second)) - Options.push_back(o.first.data()); + Options.push_back(o.first); unwrap(cg)->setCodeGenDebugOptions(Options); } void lto_codegen_debug_options_array(lto_code_gen_t cg, const char *const *options, int number) { - unwrap(cg)->setCodeGenDebugOptions(makeArrayRef(options, number)); + SmallVector Options; + for (int i = 0; i < number; ++i) + Options.push_back(options[i]); + unwrap(cg)->setCodeGenDebugOptions(makeArrayRef(Options)); } unsigned int lto_api_version() { return LTO_API_VERSION; }