[PATCH] D88309: [LTO][Legacy] Add API to set result type to assembly
wael yehia via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 25 10:29:19 PDT 2020
w2yehia added a comment.
@steven_wu what about the alternative solution where we make libLTO query the `--filetype` command line option. This will not require adding a new function to the API, but it does change the behavior of existing functions (lto_codegen_write_merged_modules, lto_codegen_compile, lto_codegen_optimize, lto_codegen_compile_optimized, lto_codegen_compile_to_file)
diff --git a/llvm/tools/lto/lto.cpp b/llvm/tools/lto/lto.cpp
index b680714..8251f7b 100644
--- a/llvm/tools/lto/lto.cpp
+++ b/llvm/tools/lto/lto.cpp
@@ -157,20 +157,23 @@
// Convert the subtarget features into a string to pass to LTOCodeGenerator.
static void lto_add_attrs(lto_code_gen_t cg) {
LTOCodeGenerator *CG = unwrap(cg);
auto MAttrs = codegen::getMAttrs();
if (!MAttrs.empty()) {
std::string attrs = join(MAttrs, ",");
CG->setAttr(attrs);
}
+ if (auto FT = codegen::getExplicitFileType())
+ CG->setFileType(FT.getValue());
+
if (OptLevel < '0' || OptLevel > '3')
report_fatal_error("Optimization level must be between 0 and 3");
CG->setOptLevel(OptLevel - '0');
CG->setFreestanding(EnableFreestanding);
}
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D88309/new/
https://reviews.llvm.org/D88309
More information about the llvm-commits
mailing list