forked from google/autofdo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
create_gcov.cc
51 lines (46 loc) · 1.96 KB
/
create_gcov.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright 2011 Google Inc. All Rights Reserved.
// Author: [email protected] (Dehao Chen)
// Main function to create AutoFDO Profile.
//
// To test if this tool is working properly with perflab:
// 1. build create_gcov: blaze build devtools/crosstoo/autofdo:create_gcov
// 2. perflab checkout k8
// 3. perflab -k --fdo=gen-afdo build k8
// 4. perflab qfetch `perflab -k --arch=ikaria_westmere \
// --fdo=gen-afdo qsub k8 | awk '{print $3}'`
// 5. perflab -k --arch=ikaria_westmere --create_gcov=your_create_gcov_path \
// --fdo_profile_root=. --fdo_profile_name=name create-autoprof k8
// 6. perflab -k --fdo_profile_root=. --fdo_profile_name=name --fdo=use-afdo \
// build k8
// 7. perflab qfetch `perflab -k --label=opt --arch=ikaria_westmere qsub k8 \
// | awk '{print $3}'`
// 8. perflab --arch=ikaria_westmere --label=opt table k8
#include "base/commandlineflags.h"
#include "gcov.h"
#include "profile_creator.h"
#include "third_party/abseil/absl/flags/flag.h"
#include "third_party/abseil/absl/flags/parse.h"
#include "third_party/abseil/absl/flags/usage.h"
ABSL_FLAG(std::string, profile, "perf.data",
"Profile file name");
ABSL_FLAG(std::string, profiler, "perf",
"Profile type");
ABSL_FLAG(std::string, gcov, "fbdata.afdo",
"Output file name");
ABSL_FLAG(std::string, binary, "data.binary",
"Binary file name");
int main(int argc, char **argv) {
absl::SetProgramUsageMessage(argv[0]);
absl::ParseCommandLine(argc, argv);
devtools_crosstool_autofdo::AutoFDOProfileWriter writer(
absl::GetFlag(FLAGS_gcov_version));
devtools_crosstool_autofdo::ProfileCreator creator(
absl::GetFlag(FLAGS_binary));
if (creator.CreateProfile(absl::GetFlag(FLAGS_profile),
absl::GetFlag(FLAGS_profiler), &writer,
absl::GetFlag(FLAGS_gcov))) {
return 0;
} else {
return -1;
}
}