Update LLVM 16 scripts

The CL is for the most part changing '10' to '16'.

Extra changes:
* Add `/cmake/` to `.git/info/sparce-checkout`.
  See https://github.com/llvm/llvm-project/issues/53281
* Turn OFF `LLVM_INCLUDE_BENCHMARKS` and
  `LLVM_INCLUDE_TESTS`.
* Copy generated files from additional directories:
  - include/llvm/TargetParser
  - include/llvm/Frontend
  - lib/ExecutionEngine

Bug: b/272710814

Change-Id: I5e18df6ba54ade60fd0e0c13069749342af99a0e
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/70950
Commit-Queue: Jean-François Geyelin <jif@google.com>
Reviewed-by: Geoff Lang <geofflang@google.com>
Tested-by: Jean-François Geyelin <jif@google.com>
diff --git a/third_party/llvm-16.0/scripts/update.py b/third_party/llvm-16.0/scripts/update.py
index f6cf4bf..c646ee8 100644
--- a/third_party/llvm-16.0/scripts/update.py
+++ b/third_party/llvm-16.0/scripts/update.py
@@ -26,15 +26,15 @@
 import tempfile
 from os import path
 
-# LLVM_BRANCH must match the value of the same variable in third_party/update-llvm-10.sh
-LLVM_BRANCH = "release/10.x"
+# LLVM_BRANCH must match the value of the same variable in third_party/update-llvm-16.sh
+LLVM_BRANCH = "release/16.x"
 
-# LLVM_COMMIT must be set to the commit hash that we last updated to when running third_party/update-llvm-10.sh.
-# Run 'git show -s origin/llvm10-clean' and look for 'llvm-10-update: <hash>' to retrieve it.
-LLVM_COMMIT = "d32170dbd5b0d54436537b6b75beaf44324e0c28"
+# LLVM_COMMIT must be set to the commit hash that we last updated to when running third_party/update-llvm-16.sh.
+# Run 'git show -s origin/llvm16-clean' and look for 'llvm-16-update: <hash>' to retrieve it.
+LLVM_COMMIT = "fce3e75e01babe38576b1519dab5f752955525f9"
 
 SCRIPT_DIR = path.dirname(path.realpath(sys.argv[0]))
-LLVM_STAGING_DIR = path.abspath(path.join(tempfile.gettempdir(), "llvm-10"))
+LLVM_STAGING_DIR = path.abspath(path.join(tempfile.gettempdir(), "llvm-16"))
 LLVM_DIR = path.abspath(path.join(LLVM_STAGING_DIR, "llvm"))
 LLVM_OBJS = path.join(LLVM_STAGING_DIR, "build")
 LLVM_CONFIGS = path.abspath(path.join(SCRIPT_DIR, '..', 'configs'))
@@ -117,6 +117,8 @@
     '-DLLVM_ENABLE_LIBEDIT=OFF',
     '-DLLVM_ENABLE_LIBPFM=OFF',
     '-DLLVM_ENABLE_ZLIB=OFF',
+    '-DLLVM_INCLUDE_BENCHMARKS=OFF',
+    '-DLLVM_INCLUDE_TESTS=OFF',
     '-DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON'
 ]
 
@@ -193,9 +195,11 @@
                 'git remote add origin https://github.com/llvm/llvm-project.git', 2)
             run_command('git config core.sparsecheckout true', 2)
             run_command('echo /llvm > .git/info/sparse-checkout', 2)
+            run_command('echo /cmake >> .git/info/sparse-checkout', 2)
 
     with pushd(LLVM_STAGING_DIR):
         run_command('echo /llvm > .git/info/sparse-checkout', 2)
+        run_command('echo /cmake >> .git/info/sparse-checkout', 2)
         run_command('git fetch origin {}'.format(LLVM_BRANCH), 2)
         run_command('git checkout {}'.format(LLVM_COMMIT), 2)
     return
@@ -244,7 +248,10 @@
     subdirs = [
         path.join('include', 'llvm', 'IR'),
         path.join('include', 'llvm', 'Support'),
+        path.join('include', 'llvm', 'TargetParser'),
+        path.join('include', 'llvm', 'Frontend'),
         path.join('lib', 'IR'),
+        path.join('lib', 'ExecutionEngine'),
         path.join('lib', 'Transforms', 'InstCombine'),
     ] + [path.join('lib', 'Target', arch) for arch, defs in LLVM_TARGETS]
     for subdir in subdirs:
diff --git a/third_party/update-llvm-16.sh b/third_party/update-llvm-16.sh
index 1823778..6f906c2 100755
--- a/third_party/update-llvm-16.sh
+++ b/third_party/update-llvm-16.sh
@@ -5,20 +5,20 @@
 # SwiftShader only requires the llvm project from this repo, and does not wish
 # to pull in everything else.
 # This script performs the following:
-# * The llvm10-clean branch is fetched and checked out.
+# * The llvm16-clean branch is fetched and checked out.
 # * A sparse checkout of the llvm project is made to a temporary directory.
-# * The third_party/llvm-10.0/llvm is replaced with the latest LLVM version.
+# * The third_party/llvm-16.0/llvm is replaced with the latest LLVM version.
 # * This is committed and pushed.
-# * The original branch is checked out again, and a merge from llvm10-clean to
+# * The original branch is checked out again, and a merge from llvm16-clean to
 #   the original branch is made.
 
 THIRD_PARTY_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd )"
-STAGING_DIR="/tmp/llvm-10-update"
-CLEAN_BRANCH="llvm10-clean"
+STAGING_DIR="/tmp/llvm-16-update"
+CLEAN_BRANCH="llvm16-clean"
 SOURCE_DIR="${STAGING_DIR}/llvm"
-TARGET_DIR="${THIRD_PARTY_DIR}/llvm-10.0/llvm"
-LLVM_REPO_BRANCH="release/10.x"
-BUG_NUMBER="b/152339534"
+TARGET_DIR="${THIRD_PARTY_DIR}/llvm-16.0/llvm"
+LLVM_REPO_BRANCH="release/16.x"
+BUG_NUMBER="b/272710814"
 
 SWIFTSHADER_HEAD=`git rev-parse HEAD`
 
@@ -46,10 +46,10 @@
 
 if [[ -d "$TARGET_DIR" ]]; then
   # Look for the last update change.
-  LAST_TARGET_UPDATE=`git log --grep="^llvm-10-update: [0-9a-f]\{9\}$" -n 1 --pretty=format:'%h' ${TARGET_DIR}`
+  LAST_TARGET_UPDATE=`git log --grep="^llvm-16-update: [0-9a-f]\{9\}$" -n 1 --pretty=format:'%h' ${TARGET_DIR}`
   if [[ ! -z "$LAST_TARGET_UPDATE" ]]; then
     # Get the LLVM commit hash from the update change.
-    LAST_SOURCE_UPDATE=`git log $LAST_TARGET_UPDATE -n 1 | grep -oP "llvm-10-update: \K([0-9a-f]{9})"`
+    LAST_SOURCE_UPDATE=`git log $LAST_TARGET_UPDATE -n 1 | grep -oP "llvm-16-update: \K([0-9a-f]{9})"`
     if [ $LLVM_HEAD == $LAST_SOURCE_UPDATE ]; then
       echo "No new LLVM changes to apply"
       exit 0
@@ -63,9 +63,9 @@
   fi
 fi
 
-COMMIT_MSG=`echo -e "Update LLVM 10 to ${LLVM_HEAD}\n\n${LLVM_CHANGE_LOG}Commands:\n  third_party/update-llvm-10.sh\n\nllvm-10-update: ${LLVM_HEAD}\nBug: ${BUG_NUMBER}"`
+COMMIT_MSG=`echo -e "Update LLVM 16 to ${LLVM_HEAD}\n\n${LLVM_CHANGE_LOG}Commands:\n  third_party/update-llvm-16.sh\n\nllvm-16-update: ${LLVM_HEAD}\nBug: ${BUG_NUMBER}"`
 
-# Switch to the llvm-10-clean branch.
+# Switch to the llvm-16-clean branch.
 git fetch "https://swiftshader.googlesource.com/SwiftShader" $CLEAN_BRANCH
 git checkout FETCH_HEAD
 
@@ -79,7 +79,7 @@
 git commit -m "$COMMIT_MSG"
 MERGE_SOURCE=`git log HEAD -n 1 --pretty=format:'%h'`
 
-# Push llvm-10-clean branch.
+# Push llvm-16-clean branch.
 git push "https://swiftshader.googlesource.com/SwiftShader" $CLEAN_BRANCH
 
 # Switch to the branch in use when calling the script.