[llvm] r352246 - [llvm] Opt-in flag for X86DiscriminateMemOps

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 1 04:44:14 PST 2019


Merged to 8.0 in r352867.

On Fri, Jan 25, 2019 at 10:49 PM Mircea Trofin via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
>
> Author: mtrofin
> Date: Fri Jan 25 13:49:54 2019
> New Revision: 352246
>
> URL: http://llvm.org/viewvc/llvm-project?rev=352246&view=rev
> Log:
> [llvm] Opt-in flag for X86DiscriminateMemOps
>
> Summary:
> Currently, if an instruction with a memory operand has no debug information,
> X86DiscriminateMemOps will generate one based on the first line of the
> enclosing function, or the last seen debug info.
>
> This may cause confusion in certain debugging scenarios. The long term
> approach would be to use the line number '0' in such cases, however, that
> brings in challenges: the base discriminator value range is limited
> (4096 values).
>
> For the short term, adding an opt-in flag for this feature.
>
> See bug 40319 (https://bugs.llvm.org/show_bug.cgi?id=40319)
>
> Reviewers: dblaikie, jmorse, gbedwell
>
> Reviewed By: dblaikie
>
> Subscribers: aprantl, eraman, hiraditya
>
> Differential Revision: https://reviews.llvm.org/D57257
>
> Modified:
>     llvm/trunk/lib/Target/X86/X86DiscriminateMemOps.cpp
>     llvm/trunk/lib/Target/X86/X86InsertPrefetch.cpp
>     llvm/trunk/test/CodeGen/X86/discriminate-mem-ops.ll
>     llvm/trunk/test/CodeGen/X86/insert-prefetch-inline.ll
>     llvm/trunk/test/CodeGen/X86/insert-prefetch-invalid-instr.ll
>     llvm/trunk/test/CodeGen/X86/insert-prefetch.ll
>
> Modified: llvm/trunk/lib/Target/X86/X86DiscriminateMemOps.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86DiscriminateMemOps.cpp?rev=352246&r1=352245&r2=352246&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/X86/X86DiscriminateMemOps.cpp (original)
> +++ llvm/trunk/lib/Target/X86/X86DiscriminateMemOps.cpp Fri Jan 25 13:49:54 2019
> @@ -26,6 +26,14 @@ using namespace llvm;
>
>  #define DEBUG_TYPE "x86-discriminate-memops"
>
> +static cl::opt<bool> EnableDiscriminateMemops(
> +    DEBUG_TYPE, cl::init(false),
> +    cl::desc("Generate unique debug info for each instruction with a memory "
> +             "operand. Should be enabled for profile-drived cache prefetching, "
> +             "both in the build of the binary being profiled, as well as in "
> +             "the build of the binary consuming the profile."),
> +    cl::Hidden);
> +
>  namespace {
>
>  using Location = std::pair<StringRef, unsigned>;
> @@ -66,6 +74,9 @@ char X86DiscriminateMemOps::ID = 0;
>  X86DiscriminateMemOps::X86DiscriminateMemOps() : MachineFunctionPass(ID) {}
>
>  bool X86DiscriminateMemOps::runOnMachineFunction(MachineFunction &MF) {
> +  if (!EnableDiscriminateMemops)
> +    return false;
> +
>    DISubprogram *FDI = MF.getFunction().getSubprogram();
>    if (!FDI || !FDI->getUnit()->getDebugInfoForProfiling())
>      return false;
>
> Modified: llvm/trunk/lib/Target/X86/X86InsertPrefetch.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InsertPrefetch.cpp?rev=352246&r1=352245&r2=352246&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/X86/X86InsertPrefetch.cpp (original)
> +++ llvm/trunk/lib/Target/X86/X86InsertPrefetch.cpp Fri Jan 25 13:49:54 2019
> @@ -33,7 +33,8 @@ using namespace sampleprof;
>
>  static cl::opt<std::string>
>      PrefetchHintsFile("prefetch-hints-file",
> -                      cl::desc("Path to the prefetch hints profile."),
> +                      cl::desc("Path to the prefetch hints profile. See also "
> +                               "-x86-discriminate-memops"),
>                        cl::Hidden);
>  namespace {
>
>
> Modified: llvm/trunk/test/CodeGen/X86/discriminate-mem-ops.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/discriminate-mem-ops.ll?rev=352246&r1=352245&r2=352246&view=diff
> ==============================================================================
> --- llvm/trunk/test/CodeGen/X86/discriminate-mem-ops.ll (original)
> +++ llvm/trunk/test/CodeGen/X86/discriminate-mem-ops.ll Fri Jan 25 13:49:54 2019
> @@ -1,4 +1,4 @@
> -; RUN: llc < %s | FileCheck %s
> +; RUN: llc -x86-discriminate-memops  < %s | FileCheck %s
>  ;
>  ; original source, compiled with -O3 -gmlt -fdebug-info-for-profiling:
>  ; int sum(int* arr, int pos1, int pos2) {
>
> Modified: llvm/trunk/test/CodeGen/X86/insert-prefetch-inline.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/insert-prefetch-inline.ll?rev=352246&r1=352245&r2=352246&view=diff
> ==============================================================================
> --- llvm/trunk/test/CodeGen/X86/insert-prefetch-inline.ll (original)
> +++ llvm/trunk/test/CodeGen/X86/insert-prefetch-inline.ll Fri Jan 25 13:49:54 2019
> @@ -1,4 +1,4 @@
> -; RUN: llc < %s -prefetch-hints-file=%S/insert-prefetch-inline.afdo | FileCheck %s
> +; RUN: llc < %s -x86-discriminate-memops -prefetch-hints-file=%S/insert-prefetch-inline.afdo | FileCheck %s
>  ;
>  ; Verify we can insert prefetch instructions in code belonging to inlined
>  ; functions.
>
> Modified: llvm/trunk/test/CodeGen/X86/insert-prefetch-invalid-instr.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/insert-prefetch-invalid-instr.ll?rev=352246&r1=352245&r2=352246&view=diff
> ==============================================================================
> --- llvm/trunk/test/CodeGen/X86/insert-prefetch-invalid-instr.ll (original)
> +++ llvm/trunk/test/CodeGen/X86/insert-prefetch-invalid-instr.ll Fri Jan 25 13:49:54 2019
> @@ -1,4 +1,4 @@
> -; RUN: llc < %s -prefetch-hints-file=%S/insert-prefetch-invalid-instr.afdo | FileCheck %s
> +; RUN: llc < %s -x86-discriminate-memops -prefetch-hints-file=%S/insert-prefetch-invalid-instr.afdo | FileCheck %s
>  ; ModuleID = 'prefetch.cc'
>  source_filename = "prefetch.cc"
>  target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
>
> Modified: llvm/trunk/test/CodeGen/X86/insert-prefetch.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/insert-prefetch.ll?rev=352246&r1=352245&r2=352246&view=diff
> ==============================================================================
> --- llvm/trunk/test/CodeGen/X86/insert-prefetch.ll (original)
> +++ llvm/trunk/test/CodeGen/X86/insert-prefetch.ll Fri Jan 25 13:49:54 2019
> @@ -1,5 +1,5 @@
> -; RUN: llc < %s -prefetch-hints-file=%S/insert-prefetch.afdo | FileCheck %s
> -; RUN: llc < %s -prefetch-hints-file=%S/insert-prefetch-other.afdo | FileCheck %s -check-prefix=OTHERS
> +; RUN: llc < %s -x86-discriminate-memops -prefetch-hints-file=%S/insert-prefetch.afdo | FileCheck %s
> +; RUN: llc < %s -x86-discriminate-memops -prefetch-hints-file=%S/insert-prefetch-other.afdo | FileCheck %s -check-prefix=OTHERS
>  ;
>  ; original source, compiled with -O3 -gmlt -fdebug-info-for-profiling:
>  ; int sum(int* arr, int pos1, int pos2) {
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list