llvm.org GIT mirror llvm / 68fd69b
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352246 91177308-0d34-0410-b5e6-96231b3b80d8 Mircea Trofin 1 year, 4 months ago
6 changed file(s) with 18 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
2424 using namespace llvm;
2525
2626 #define DEBUG_TYPE "x86-discriminate-memops"
27
28 static cl::opt EnableDiscriminateMemops(
29 DEBUG_TYPE, cl::init(false),
30 cl::desc("Generate unique debug info for each instruction with a memory "
31 "operand. Should be enabled for profile-drived cache prefetching, "
32 "both in the build of the binary being profiled, as well as in "
33 "the build of the binary consuming the profile."),
34 cl::Hidden);
2735
2836 namespace {
2937
6573 X86DiscriminateMemOps::X86DiscriminateMemOps() : MachineFunctionPass(ID) {}
6674
6775 bool X86DiscriminateMemOps::runOnMachineFunction(MachineFunction &MF) {
76 if (!EnableDiscriminateMemops)
77 return false;
78
6879 DISubprogram *FDI = MF.getFunction().getSubprogram();
6980 if (!FDI || !FDI->getUnit()->getDebugInfoForProfiling())
7081 return false;
3232
3333 static cl::opt
3434 PrefetchHintsFile("prefetch-hints-file",
35 cl::desc("Path to the prefetch hints profile."),
35 cl::desc("Path to the prefetch hints profile. See also "
36 "-x86-discriminate-memops"),
3637 cl::Hidden);
3738 namespace {
3839
None ; RUN: llc < %s | FileCheck %s
0 ; RUN: llc -x86-discriminate-memops < %s | FileCheck %s
11 ;
22 ; original source, compiled with -O3 -gmlt -fdebug-info-for-profiling:
33 ; int sum(int* arr, int pos1, int pos2) {
None ; RUN: llc < %s -prefetch-hints-file=%S/insert-prefetch-inline.afdo | FileCheck %s
0 ; RUN: llc < %s -x86-discriminate-memops -prefetch-hints-file=%S/insert-prefetch-inline.afdo | FileCheck %s
11 ;
22 ; Verify we can insert prefetch instructions in code belonging to inlined
33 ; functions.
None ; RUN: llc < %s -prefetch-hints-file=%S/insert-prefetch-invalid-instr.afdo | FileCheck %s
0 ; RUN: llc < %s -x86-discriminate-memops -prefetch-hints-file=%S/insert-prefetch-invalid-instr.afdo | FileCheck %s
11 ; ModuleID = 'prefetch.cc'
22 source_filename = "prefetch.cc"
33 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
None ; RUN: llc < %s -prefetch-hints-file=%S/insert-prefetch.afdo | FileCheck %s
1 ; RUN: llc < %s -prefetch-hints-file=%S/insert-prefetch-other.afdo | FileCheck %s -check-prefix=OTHERS
0 ; RUN: llc < %s -x86-discriminate-memops -prefetch-hints-file=%S/insert-prefetch.afdo | FileCheck %s
1 ; RUN: llc < %s -x86-discriminate-memops -prefetch-hints-file=%S/insert-prefetch-other.afdo | FileCheck %s -check-prefix=OTHERS
22 ;
33 ; original source, compiled with -O3 -gmlt -fdebug-info-for-profiling:
44 ; int sum(int* arr, int pos1, int pos2) {