Add flag to llvm-profdata to allow symbols in profile data to be remapped, and
add a tool to generate symbol remapping files.

Summary:
The new tool llvm-cxxmap builds a symbol mapping table from a file containing
a description of partial equivalences to apply to mangled names and files
containing old and new symbol tables.

Reviewers: davidxl

Subscribers: mgorny, llvm-commits

Differential Revision: https://reviews.llvm.org/D51470

llvm-svn: 342168
diff --git a/llvm/test/tools/llvm-profdata/Inputs/instr-remap.expected b/llvm/test/tools/llvm-profdata/Inputs/instr-remap.expected
new file mode 100644
index 0000000..f5ff527
--- /dev/null
+++ b/llvm/test/tools/llvm-profdata/Inputs/instr-remap.expected
@@ -0,0 +1,29 @@
+# IR level Instrumentation Flag
+:ir
+bar
+# Func Hash:
+1234
+# Num Counters:
+2
+# Counter Values:
+31
+42
+
+bar
+# Func Hash:
+5678
+# Num Counters:
+2
+# Counter Values:
+500
+600
+
+baz
+# Func Hash:
+5678
+# Num Counters:
+2
+# Counter Values:
+7
+8
+
diff --git a/llvm/test/tools/llvm-profdata/Inputs/instr-remap.proftext b/llvm/test/tools/llvm-profdata/Inputs/instr-remap.proftext
new file mode 100644
index 0000000..ddd6671
--- /dev/null
+++ b/llvm/test/tools/llvm-profdata/Inputs/instr-remap.proftext
@@ -0,0 +1,25 @@
+# :ir is the flag to indicate this is IR level profile.
+:ir
+foo
+1234
+2
+1
+2
+
+bar
+1234
+2
+30
+40
+
+foo
+5678
+2
+500
+600
+
+baz
+5678
+2
+7
+8
diff --git a/llvm/test/tools/llvm-profdata/Inputs/instr-remap.remap b/llvm/test/tools/llvm-profdata/Inputs/instr-remap.remap
new file mode 100644
index 0000000..d675fa4
--- /dev/null
+++ b/llvm/test/tools/llvm-profdata/Inputs/instr-remap.remap
@@ -0,0 +1 @@
+foo bar
diff --git a/llvm/test/tools/llvm-profdata/Inputs/sample-remap.expected b/llvm/test/tools/llvm-profdata/Inputs/sample-remap.expected
new file mode 100644
index 0000000..863ea1e
--- /dev/null
+++ b/llvm/test/tools/llvm-profdata/Inputs/sample-remap.expected
@@ -0,0 +1,16 @@
+main:184019:0
+ 4: 534
+ 4.2: 534
+ 5: 1075
+ 5.1: 1075
+ 6: 2080
+ 7: 534
+ 9: 2064 _Z3bazi:1471 _Z3fooi:631
+ 10: inline2:2000
+  1: 2000
+ 10: inline42:1000
+  1: 1000
+_Z3bazi:40602:2437
+ 1: 2437
+_Z3fooi:7711:610
+ 1: 610
diff --git a/llvm/test/tools/llvm-profdata/Inputs/sample-remap.proftext b/llvm/test/tools/llvm-profdata/Inputs/sample-remap.proftext
new file mode 100644
index 0000000..33fce64
--- /dev/null
+++ b/llvm/test/tools/llvm-profdata/Inputs/sample-remap.proftext
@@ -0,0 +1,18 @@
+_Z3bari:20301:1437
+ 1: 1437
+_Z3fooi:7711:610
+ 1: 610
+main:184019:0
+ 4: 534
+ 4.2: 534
+ 5: 1075
+ 5.1: 1075
+ 6: 2080
+ 7: 534
+ 9: 2064 _Z3bari:1471 _Z3fooi:631
+ 10: inline1:1000
+  1: 1000
+ 10: inline2:2000
+  1: 2000
+_Z3bazi:20301:1000
+ 1: 1000
diff --git a/llvm/test/tools/llvm-profdata/Inputs/sample-remap.remap b/llvm/test/tools/llvm-profdata/Inputs/sample-remap.remap
new file mode 100644
index 0000000..465c45c
--- /dev/null
+++ b/llvm/test/tools/llvm-profdata/Inputs/sample-remap.remap
@@ -0,0 +1,2 @@
+_Z3bari _Z3bazi
+inline1 inline42