This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGe625f9c5d1e2: -fbasic-block-sections=list=: Suppress output if failed to open the file (authored by MaskRay).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D90815/new/ https://reviews.llvm.org/D90815 Files: clang/lib/CodeGen/BackendUtil.cpp clang/test/CodeGen/basic-block-sections.c Index: clang/test/CodeGen/basic-block-sections.c =================================================================== --- clang/test/CodeGen/basic-block-sections.c +++ clang/test/CodeGen/basic-block-sections.c @@ -6,7 +6,9 @@ // RUN: %clang_cc1 -triple x86_64 -S -fbasic-block-sections=all -o - < %s | FileCheck %s --check-prefix=BB_WORLD --check-prefix=BB_ALL // RUN: %clang_cc1 -triple x86_64 -S -fbasic-block-sections=list=%S/Inputs/basic-block-sections.funcnames -o - < %s | FileCheck %s --check-prefix=BB_WORLD --check-prefix=BB_LIST // RUN: %clang_cc1 -triple x86_64 -S -fbasic-block-sections=all -funique-basic-block-section-names -o - < %s | FileCheck %s --check-prefix=UNIQUE -// RUN: not %clang_cc1 -fbasic-block-sections=list= -emit-llvm -o - %s 2>&1 | FileCheck %s --check-prefix=ERROR +// RUN: rm -f %t +// RUN: not %clang_cc1 -fbasic-block-sections=list= -emit-obj -o %t %s 2>&1 | FileCheck %s --check-prefix=ERROR +// RUN: not ls %t int world(int a) { if (a > 10) Index: clang/lib/CodeGen/BackendUtil.cpp =================================================================== --- clang/lib/CodeGen/BackendUtil.cpp +++ clang/lib/CodeGen/BackendUtil.cpp @@ -446,7 +446,7 @@ } } -static void initTargetOptions(DiagnosticsEngine &Diags, +static bool initTargetOptions(DiagnosticsEngine &Diags, llvm::TargetOptions &Options, const CodeGenOptions &CodeGenOpts, const clang::TargetOptions &TargetOpts, @@ -517,11 +517,12 @@ if (Options.BBSections == llvm::BasicBlockSection::List) { ErrorOr<std::unique_ptr<MemoryBuffer>> MBOrErr = MemoryBuffer::getFile(CodeGenOpts.BBSections.substr(5)); - if (!MBOrErr) + if (!MBOrErr) { Diags.Report(diag::err_fe_unable_to_load_basic_block_sections_file) << MBOrErr.getError().message(); - else - Options.BBSectionsFuncListBuf = std::move(*MBOrErr); + return false; + } + Options.BBSectionsFuncListBuf = std::move(*MBOrErr); } Options.EnableMachineFunctionSplitter = CodeGenOpts.SplitMachineFunctions; @@ -572,6 +573,8 @@ Entry.IgnoreSysRoot ? Entry.Path : HSOpts.Sysroot + Entry.Path); Options.MCOptions.Argv0 = CodeGenOpts.Argv0; Options.MCOptions.CommandLineArgs = CodeGenOpts.CommandLineArgs; + + return true; } static Optional<GCOVOptions> getGCOVOptions(const CodeGenOptions &CodeGenOpts, @@ -858,7 +861,9 @@ CodeGenOpt::Level OptLevel = getCGOptLevel(CodeGenOpts); llvm::TargetOptions Options; - initTargetOptions(Diags, Options, CodeGenOpts, TargetOpts, LangOpts, HSOpts); + if (!initTargetOptions(Diags, Options, CodeGenOpts, TargetOpts, LangOpts, + HSOpts)) + return; TM.reset(TheTarget->createTargetMachine(Triple, TargetOpts.CPU, FeaturesStr, Options, RM, CM, OptLevel)); }
Index: clang/test/CodeGen/basic-block-sections.c =================================================================== --- clang/test/CodeGen/basic-block-sections.c +++ clang/test/CodeGen/basic-block-sections.c @@ -6,7 +6,9 @@ // RUN: %clang_cc1 -triple x86_64 -S -fbasic-block-sections=all -o - < %s | FileCheck %s --check-prefix=BB_WORLD --check-prefix=BB_ALL // RUN: %clang_cc1 -triple x86_64 -S -fbasic-block-sections=list=%S/Inputs/basic-block-sections.funcnames -o - < %s | FileCheck %s --check-prefix=BB_WORLD --check-prefix=BB_LIST // RUN: %clang_cc1 -triple x86_64 -S -fbasic-block-sections=all -funique-basic-block-section-names -o - < %s | FileCheck %s --check-prefix=UNIQUE -// RUN: not %clang_cc1 -fbasic-block-sections=list= -emit-llvm -o - %s 2>&1 | FileCheck %s --check-prefix=ERROR +// RUN: rm -f %t +// RUN: not %clang_cc1 -fbasic-block-sections=list= -emit-obj -o %t %s 2>&1 | FileCheck %s --check-prefix=ERROR +// RUN: not ls %t int world(int a) { if (a > 10) Index: clang/lib/CodeGen/BackendUtil.cpp =================================================================== --- clang/lib/CodeGen/BackendUtil.cpp +++ clang/lib/CodeGen/BackendUtil.cpp @@ -446,7 +446,7 @@ } } -static void initTargetOptions(DiagnosticsEngine &Diags, +static bool initTargetOptions(DiagnosticsEngine &Diags, llvm::TargetOptions &Options, const CodeGenOptions &CodeGenOpts, const clang::TargetOptions &TargetOpts, @@ -517,11 +517,12 @@ if (Options.BBSections == llvm::BasicBlockSection::List) { ErrorOr<std::unique_ptr<MemoryBuffer>> MBOrErr = MemoryBuffer::getFile(CodeGenOpts.BBSections.substr(5)); - if (!MBOrErr) + if (!MBOrErr) { Diags.Report(diag::err_fe_unable_to_load_basic_block_sections_file) << MBOrErr.getError().message(); - else - Options.BBSectionsFuncListBuf = std::move(*MBOrErr); + return false; + } + Options.BBSectionsFuncListBuf = std::move(*MBOrErr); } Options.EnableMachineFunctionSplitter = CodeGenOpts.SplitMachineFunctions; @@ -572,6 +573,8 @@ Entry.IgnoreSysRoot ? Entry.Path : HSOpts.Sysroot + Entry.Path); Options.MCOptions.Argv0 = CodeGenOpts.Argv0; Options.MCOptions.CommandLineArgs = CodeGenOpts.CommandLineArgs; + + return true; } static Optional<GCOVOptions> getGCOVOptions(const CodeGenOptions &CodeGenOpts, @@ -858,7 +861,9 @@ CodeGenOpt::Level OptLevel = getCGOptLevel(CodeGenOpts); llvm::TargetOptions Options; - initTargetOptions(Diags, Options, CodeGenOpts, TargetOpts, LangOpts, HSOpts); + if (!initTargetOptions(Diags, Options, CodeGenOpts, TargetOpts, LangOpts, + HSOpts)) + return; TM.reset(TheTarget->createTargetMachine(Triple, TargetOpts.CPU, FeaturesStr, Options, RM, CM, OptLevel)); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits