Author: Florian Hahn Date: 2021-01-23T12:11:58Z New Revision: 08dbcc14e254396cd5765994cab97274003611bb
URL: https://github.com/llvm/llvm-project/commit/08dbcc14e254396cd5765994cab97274003611bb DIFF: https://github.com/llvm/llvm-project/commit/08dbcc14e254396cd5765994cab97274003611bb.diff LOG: [LTO] Store target attributes as vector of strings (NFC). The target features are obtained as a list of features/attributes. Instead of storing them in a single string, store the vector. This matches lto::Config's behavior and simplifies the transition to lto::backend(). Reviewed By: tejohnson Differential Revision: https://reviews.llvm.org/D95224 Added: Modified: llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h llvm/lib/LTO/LTOCodeGenerator.cpp llvm/tools/llvm-lto/llvm-lto.cpp llvm/tools/lto/lto.cpp Removed: ################################################################################ diff --git a/llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h b/llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h index a817969abc58..f76cc5fbed49 100644 --- a/llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h +++ b/llvm/include/llvm/LTO/legacy/LTOCodeGenerator.h @@ -93,7 +93,7 @@ struct LTOCodeGenerator { void setFileType(CodeGenFileType FT) { FileType = FT; } void setCpu(StringRef MCpu) { this->MCpu = std::string(MCpu); } - void setAttr(StringRef MAttr) { this->MAttr = std::string(MAttr); } + void setAttrs(std::vector<std::string> MAttrs) { this->MAttrs = MAttrs; } void setOptLevel(unsigned OptLevel); void setShouldInternalize(bool Value) { ShouldInternalize = Value; } @@ -223,7 +223,7 @@ struct LTOCodeGenerator { std::vector<std::string> CodegenOptions; std::string FeatureStr; std::string MCpu; - std::string MAttr; + std::vector<std::string> MAttrs; std::string NativeObjectPath; TargetOptions Options; CodeGenOpt::Level CGOptLevel = CodeGenOpt::Default; diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp index cb30db193259..bdde2baffb40 100644 --- a/llvm/lib/LTO/LTOCodeGenerator.cpp +++ b/llvm/lib/LTO/LTOCodeGenerator.cpp @@ -361,7 +361,7 @@ bool LTOCodeGenerator::determineTarget() { // Construct LTOModule, hand over ownership of module and target. Use MAttr as // the default set of features. - SubtargetFeatures Features(MAttr); + SubtargetFeatures Features(join(MAttrs, "")); Features.getDefaultSubtargetFeatures(Triple); FeatureStr = Features.getString(); // Set a default CPU for Darwin triples. diff --git a/llvm/tools/llvm-lto/llvm-lto.cpp b/llvm/tools/llvm-lto/llvm-lto.cpp index ad6b78bc46a6..912a88dfbd54 100644 --- a/llvm/tools/llvm-lto/llvm-lto.cpp +++ b/llvm/tools/llvm-lto/llvm-lto.cpp @@ -1011,12 +1011,7 @@ int main(int argc, char **argv) { CodeGen.setCpu(codegen::getMCPU().c_str()); CodeGen.setOptLevel(OptLevel - '0'); - - auto MAttrs = codegen::getMAttrs(); - if (!MAttrs.empty()) { - std::string attrs = join(MAttrs, ","); - CodeGen.setAttr(attrs); - } + CodeGen.setAttrs(codegen::getMAttrs()); if (auto FT = codegen::getExplicitFileType()) CodeGen.setFileType(FT.getValue()); diff --git a/llvm/tools/lto/lto.cpp b/llvm/tools/lto/lto.cpp index 81f64df403ab..b48bc922bc4b 100644 --- a/llvm/tools/lto/lto.cpp +++ b/llvm/tools/lto/lto.cpp @@ -146,11 +146,7 @@ DEFINE_SIMPLE_CONVERSION_FUNCTIONS(LTOModule, lto_module_t) // 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); - } + CG->setAttrs(codegen::getMAttrs()); if (OptLevel < '0' || OptLevel > '3') report_fatal_error("Optimization level must be between 0 and 3"); _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits