[PATCH] D63155: [clang][NewPM] Fix broken profile test

Leonard Chan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 11 11:55:24 PDT 2019


leonardchan created this revision.
leonardchan added reviewers: chandlerc, echristo, phosek, serge-sans-paille.
leonardchan added a project: clang.
leonardchan added a parent revision: D62225: [clang][NewPM] Fixing -O0 tests that are broken under new PM.

This contains the part of D62225 <https://reviews.llvm.org/D62225> which fixes `Profile/gcc-flag-compatibility.c` by adding the pass that allows default profile generation to work under the new PM. It seems that `./default.profraw` was not being generated with new PM enabled.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D63155

Files:
  clang/lib/CodeGen/BackendUtil.cpp


Index: clang/lib/CodeGen/BackendUtil.cpp
===================================================================
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -60,6 +60,7 @@
 #include "llvm/Transforms/Instrumentation/HWAddressSanitizer.h"
 #include "llvm/Transforms/Instrumentation/InstrProfiling.h"
 #include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
+#include "llvm/Transforms/Instrumentation/PGOInstrumentation.h"
 #include "llvm/Transforms/Instrumentation/ThreadSanitizer.h"
 #include "llvm/Transforms/ObjCARC.h"
 #include "llvm/Transforms/Scalar.h"
@@ -1216,6 +1217,11 @@
 
     if (CodeGenOpts.OptimizationLevel == 0)
       addSanitizersAtO0(MPM, TargetTriple, LangOpts, CodeGenOpts);
+
+    if (CodeGenOpts.hasProfileIRInstr()) {
+      // This file is stored as the ProfileFile.
+      MPM.addPass(PGOInstrumentationGenCreateVar(PGOOpt->ProfileFile));
+    }
   }
 
   // FIXME: We still use the legacy pass manager to do code generation. We


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63155.204124.patch
Type: text/x-patch
Size: 990 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190611/a751c4a7/attachment.bin>


More information about the cfe-commits mailing list