File tree Expand file tree Collapse file tree 3 files changed +45
-3
lines changed Expand file tree Collapse file tree 3 files changed +45
-3
lines changed Original file line number Diff line number Diff line change 1+ ; RUN: rm -rf %t
2+ ; RUN: mkdir -p %t
3+ ; RUN: cd %t
4+
5+ ; RUN: echo -e "1\n401120-40113b:1\n1\n40112f->401110:1" > %t.prof
6+ ; RUN: cp %S/Inputs/missing-dwarf.exe %t/missing-dwarf.exe
7+
8+ ; Test --load-function-from-symbol=0
9+ ; RUN: llvm-profgen --format=text --unsymbolized-profile=%t.prof --binary=%t/missing-dwarf.exe --output=%t1 --fill-zero-for-all-funcs --show-detailed-warning --use-offset=0 --load-function-from-symbol=0 2>&1 | FileCheck %s --check-prefix=CHECK-NO-LOAD-SYMTAB
10+
11+ ; CHECK-NO-LOAD-SYMTAB: warning: 100.00%(1/1) of function range samples do not belong to any function
12+ ; CHECK-NO-LOAD-SYMTAB-NEXT: warning: 100.00%(1/1) of LBR source samples do not belong to any function
13+ ; CHECK-NO-LOAD-SYMTAB-NEXT: warning: 100.00%(1/1) of LBR target samples do not belong to any function
14+
15+ ; Test --load-function-from-symbol=1
16+ ; RUN: llvm-profgen --format=text --unsymbolized-profile=%t.prof --binary=%t/missing-dwarf.exe --output=%t2 --fill-zero-for-all-funcs --show-detailed-warning --use-offset=0 --load-function-from-symbol=1
17+ ; RUN: FileCheck %s --input-file %t2 --check-prefix=CHECK-LOAD-SYMTAB
18+
19+ ; CHECK-LOAD-SYMTAB: main:2:1
20+ ; CHECK-LOAD-SYMTAB-NEXT: 1: 1
21+ ; CHECK-LOAD-SYMTAB-NEXT: 2: 1 foo:1
22+ ; CHECK-LOAD-SYMTAB-NEXT: !CFGChecksum: 281479271677951
23+ ; CHECK-LOAD-SYMTAB-NEXT: foo:0:0
24+ ; CHECK-LOAD-SYMTAB-NEXT: 1: 0
25+ ; CHECK-LOAD-SYMTAB-NEXT: !CFGChecksum: 4294967295
26+
27+ ; Build instructions:
28+ ; missing-dwarf.o: clang -gsplit-dwarf=split -fdebug-compilation-dir=. test.c -fdebug-info-for-profiling -fpseudo-probe-for-profiling -O0 -g -o missing-dwarf.o -c
29+ ; missing-dwarf.exe: clang -fdebug-compilation-dir=. missing-dwarf.o -o missing-dwarf.exe -fdebug-info-for-profiling -fpseudo-probe-for-profiling -O0 -g
30+
31+ ; Source code:
32+
33+ int foo() {
34+ return 1;
35+ }
36+
37+ int main() {
38+ foo();
39+ return 0;
40+ }
Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ static cl::list<std::string> DisassembleFunctions(
6666 cl::cat(ProfGenCategory));
6767
6868static cl::opt<bool >
69- LoadFunctionFromSymbol (" load-function-from-symbol" ,
69+ LoadFunctionFromSymbol (" load-function-from-symbol" , cl::init( true ),
7070 cl::desc(" Gather additional binary function info "
7171 " from symbols (e.g. .symtab) in case "
7272 " dwarf info is incomplete." ),
@@ -264,7 +264,7 @@ void ProfiledBinary::load() {
264264 if (ShowDisassemblyOnly)
265265 decodePseudoProbe (Obj);
266266
267- if (LoadFunctionFromSymbol || UsePseudoProbes)
267+ if (LoadFunctionFromSymbol && UsePseudoProbes)
268268 populateSymbolsFromBinary (Obj);
269269
270270 // Disassemble the text sections.
@@ -853,8 +853,10 @@ void ProfiledBinary::populateSymbolsFromBinary(const ObjectFile *Obj) {
853853
854854 auto Ret = BinaryFunctions.emplace (SymName, BinaryFunction ());
855855 auto &Func = Ret.first ->second ;
856- if (Ret.second )
856+ if (Ret.second ) {
857857 Func.FuncName = Ret.first ->first ;
858+ HashBinaryFunctions[MD5Hash (StringRef (SymName))] = &Func;
859+ }
858860
859861 if (auto Range = findFuncRange (Addr)) {
860862 if (Ret.second && ShowDetailedWarning)
You can’t perform that action at this time.
0 commit comments