Skip to content

Commit a8379c4

Browse files
[BOLT] create an LLVM OpenMP maintenance script
LLVM OpenMP is managed with other LLVM packages altogether in the official repository while BOLT depends on only LLVM OpenMP. The newly created utility script cherry-picks commits that change LLVM OpenMP files from the official LLVM repository.
1 parent cff5132 commit a8379c4

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

maint/update-llvmomp.sh

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/bash
2+
3+
boltpath="$(pwd)"
4+
5+
# Switch to the llvmomp branch
6+
git checkout llvmomp
7+
8+
# Get the latest llvm-project
9+
if [ -d "${boltpath}/llvm-project" ]; then
10+
cd "${boltpath}/llvm-project"
11+
git pull
12+
git checkout master
13+
else
14+
git clone https://github.com/llvm/llvm-project.git "${boltpath}/llvm-project"
15+
fi
16+
17+
# Find the corresponding latest commit of the llvmomp branch
18+
cd "$boltpath"
19+
if [ x"$(git log HEAD~..HEAD | grep cherry-pick:)" = x ]; then
20+
# The last commit in llvm-mirror: d69d1aa131b4cf339bfac116e50da33a5f94b861
21+
commit_id_begin="d69d1aa131b4cf339bfac116e50da33a5f94b861"
22+
else
23+
# Extract the first "cherry-pick:" comment from the latest log.
24+
commit_id_begin=$(git log HEAD~..HEAD | grep -Po "cherry-pick: \K[\w]+" | head -n 1)
25+
fi
26+
echo "last commit: $commit_id_begin"
27+
28+
rm -rf "${boltpath}/llvm-project/patch_diff.tmp"
29+
rm -rf "${boltpath}/llvm-project/patch_log.tmp"
30+
rm -rf "${boltpath}/llvm-project/patch_changed_list.tmp"
31+
32+
cd "${boltpath}/llvm-project/openmp"
33+
34+
for commit_id in $(git rev-list --reverse ${commit_id_begin}..HEAD); do
35+
echo "checking $commit_id"
36+
# Check if OpenMP part is changed.
37+
if [ x"$(git diff --name-only --relative ${commit_id}~..${commit_id})" != x ]; then
38+
echo "\n#########################\n"
39+
# Create a diff file
40+
git diff --relative ${commit_id}~..${commit_id} > "${boltpath}/llvm-project/patch_diff.tmp"
41+
# Create a list of changed files
42+
git diff --name-only --relative ${commit_id}~..${commit_id} > "${boltpath}/llvm-project/patch_changed_list.tmp"
43+
# Create a log file for this
44+
git log ${commit_id}~..${commit_id} --pretty=format:"%B" > "${boltpath}/llvm-project/patch_log.tmp"
45+
echo "" >> "${boltpath}/llvm-project/patch_log.tmp"
46+
echo "cherry-pick: $commit_id" >> "${boltpath}/llvm-project/patch_log.tmp"
47+
echo "https://github.com/llvm/llvm-project/commit/${commit_id}" >> "${boltpath}/llvm-project/patch_log.tmp"
48+
author_info="$(git show --pretty="%aN <%aE>" $commit_id | head -n 1)"
49+
timestamp_info="$(git show --pretty="%cd" $commit_id | head -n 1)"
50+
51+
# Go to the BOLT repository
52+
cd "${boltpath}"
53+
54+
# Apply the diff to the llvmomp branch
55+
git apply "${boltpath}/llvm-project/patch_diff.tmp"
56+
for changed_file in $(cat "${boltpath}/llvm-project/patch_changed_list.tmp"); do
57+
git add $changed_file
58+
done
59+
60+
# Commit it.
61+
cat "${boltpath}/llvm-project/patch_log.tmp"
62+
git commit -F "${boltpath}/llvm-project/patch_log.tmp" --author="$author_info" --date="$timestamp_info"
63+
64+
# Go to the llvm-project repository.
65+
cd "${boltpath}/llvm-project/openmp"
66+
fi
67+
done
68+
69+
echo "complete"

0 commit comments

Comments
 (0)