From: Chandler Carruth Date: Tue, 25 Jul 2017 10:46:07 +0000 (+0000) Subject: [PM] Setup TargetLibraryInfo correctly for the new pass manager. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ac84e19437d75e0875bd5d1b9d13d24690796c37;p=clang [PM] Setup TargetLibraryInfo correctly for the new pass manager. Without this, -fno-builtin and friends doesn't work. Added the obvious RUN lines to the test for -fno-builtin and they pass now. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@308967 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/BackendUtil.cpp b/lib/CodeGen/BackendUtil.cpp index 513896d986..b56d399d7e 100644 --- a/lib/CodeGen/BackendUtil.cpp +++ b/lib/CodeGen/BackendUtil.cpp @@ -871,6 +871,14 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager( // Register the AA manager first so that our version is the one used. FAM.registerPass([&] { return PB.buildDefaultAAPipeline(); }); + // Register the target library analysis directly and give it a customized + // preset TLI. + Triple TargetTriple(TheModule->getTargetTriple()); + std::unique_ptr TLII( + createTLII(TargetTriple, CodeGenOpts)); + FAM.registerPass([&] { return TargetLibraryAnalysis(*TLII); }); + MAM.registerPass([&] { return TargetLibraryAnalysis(*TLII); }); + // Register all the basic analyses with the managers. PB.registerModuleAnalyses(MAM); PB.registerCGSCCAnalyses(CGAM); diff --git a/test/CodeGen/nobuiltin.c b/test/CodeGen/nobuiltin.c index f80c3c332a..543918f674 100644 --- a/test/CodeGen/nobuiltin.c +++ b/test/CodeGen/nobuiltin.c @@ -4,6 +4,10 @@ // RUN: %clang_cc1 -triple x86_64-linux-gnu -fno-builtin -O1 -S -o - %s | FileCheck -check-prefix=NOSTRCPY -check-prefix=NOMEMSET %s // RUN: %clang_cc1 -triple x86_64-linux-gnu -fno-builtin-memset -O1 -S -o - %s | FileCheck -check-prefix=STRCPY -check-prefix=NOMEMSET %s +// RUN: %clang_cc1 -triple x86_64-linux-gnu -O1 -fexperimental-new-pass-manager -S -o - %s | FileCheck -check-prefix=STRCPY -check-prefix=MEMSET %s +// RUN: %clang_cc1 -triple x86_64-linux-gnu -fno-builtin -O1 -fexperimental-new-pass-manager -S -o - %s | FileCheck -check-prefix=NOSTRCPY -check-prefix=NOMEMSET %s +// RUN: %clang_cc1 -triple x86_64-linux-gnu -fno-builtin-memset -O1 -fexperimental-new-pass-manager -S -o - %s | FileCheck -check-prefix=STRCPY -check-prefix=NOMEMSET %s + void PR13497() { char content[2]; // make sure we don't optimize this call to strcpy()