]> granicus.if.org Git - clang/commitdiff
[PM] Setup TargetLibraryInfo correctly for the new pass manager.
authorChandler Carruth <chandlerc@gmail.com>
Tue, 25 Jul 2017 10:46:07 +0000 (10:46 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Tue, 25 Jul 2017 10:46:07 +0000 (10:46 +0000)
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

lib/CodeGen/BackendUtil.cpp
test/CodeGen/nobuiltin.c

index 513896d98634501ffcb6acc9123b81ab39b5897d..b56d399d7e1be7224784e656976f867a82d93295 100644 (file)
@@ -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<TargetLibraryInfoImpl> 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);
index f80c3c332ab4bd0b8b3b12911b56e6a01e2c0fa6..543918f67491b31a97f8cd1dc7a600620e1af242 100644 (file)
@@ -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()