[PATCH] D15829: [PGO] Clang Option that enables IR level PGO instrumentation

Sean Silva via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 26 17:01:51 PST 2016

silvas added inline comments.

Comment at: lib/Driver/Tools.cpp:5520
@@ +5519,3 @@
+    A->claim();
+    if ((StringRef(A->getValue(0)) == "-fprofile-ir-instr") &&
+        (Args.hasArg(options::OPT_fprofile_instr_generate) ||
This is definitely not the right thing to do. Don't hijack -Xclang (which is a completely generic thing).

Comment at: lib/Frontend/CompilerInvocation.cpp:483
@@ +482,3 @@
+    Opts.ProfileIRInstr = true;
+  else
+    // Opts.ClangProfInstrGen will be used for Clang instrumentation only.
This still isn't factored right. I think at this point the meaning of the driver-level options is not really useful at CC1 level (too convoluted) for it to be useful to pass them through.

The right thing to do here is probably more like:
- refactor so that we have 4 individual CC1 options for InstrProfileOutput, InstrProfileInput, ProfileIRInstr, ClangProfInstrGen (although probably rename ClangProfInstrGen and ProfileIRInstr to be consistent with each other, e.g. "ProfileIRInstr" and "ProfileClangInstr").
- add logic in Driver to convert from the driver-level options to the CC1 options.

Comment at: test/CodeGen/pgo-instrumentation.c:5
@@ +4,3 @@
+// RUN: %clang -O2 -c -Xclang -fprofile-ir-instr -fprofile-instr-generate %s -mllvm -debug-pass=Structure 2>&1 | FileCheck %s -check-prefix=CHECK-PGOGENPASS-INVOKED-V1
+// CHECK-PGOGENPASS-INVOKED-V1: PGOInstrumentationGenPass
It isn't clear what V1/V2 mean.


More information about the cfe-commits mailing list