OLD | NEW |
1 #!/usr/bin/env bash | 1 #!/usr/bin/env bash |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 # This script will check out llvm and clang into third_party/llvm and build it. | 6 # This script will check out llvm and clang into third_party/llvm and build it. |
7 | 7 |
8 # Do NOT CHANGE this if you don't know what you're doing -- see | 8 # Do NOT CHANGE this if you don't know what you're doing -- see |
9 # https://code.google.com/p/chromium/wiki/UpdatingClang | 9 # https://code.google.com/p/chromium/wiki/UpdatingClang |
10 # Reverting problematic clang rolls is safe, though. | 10 # Reverting problematic clang rolls is safe, though. |
11 CLANG_REVISION=217949 | 11 CLANG_REVISION=218707 |
12 | 12 |
13 THIS_DIR="$(dirname "${0}")" | 13 THIS_DIR="$(dirname "${0}")" |
14 LLVM_DIR="${THIS_DIR}/../../../third_party/llvm" | 14 LLVM_DIR="${THIS_DIR}/../../../third_party/llvm" |
15 LLVM_BUILD_DIR="${LLVM_DIR}/../llvm-build/Release+Asserts" | 15 LLVM_BUILD_DIR="${LLVM_DIR}/../llvm-build/Release+Asserts" |
16 COMPILER_RT_BUILD_DIR="${LLVM_DIR}/../llvm-build/compiler-rt" | 16 COMPILER_RT_BUILD_DIR="${LLVM_DIR}/../llvm-build/compiler-rt" |
17 LLVM_BOOTSTRAP_DIR="${LLVM_DIR}/../llvm-bootstrap" | 17 LLVM_BOOTSTRAP_DIR="${LLVM_DIR}/../llvm-bootstrap" |
18 LLVM_BOOTSTRAP_INSTALL_DIR="${LLVM_DIR}/../llvm-bootstrap-install" | 18 LLVM_BOOTSTRAP_INSTALL_DIR="${LLVM_DIR}/../llvm-bootstrap-install" |
19 CLANG_DIR="${LLVM_DIR}/tools/clang" | 19 CLANG_DIR="${LLVM_DIR}/tools/clang" |
20 COMPILER_RT_DIR="${LLVM_DIR}/compiler-rt" | 20 COMPILER_RT_DIR="${LLVM_DIR}/compiler-rt" |
21 LIBCXX_DIR="${LLVM_DIR}/projects/libcxx" | 21 LIBCXX_DIR="${LLVM_DIR}/projects/libcxx" |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 echo "ninja needed to build clang, please install" | 228 echo "ninja needed to build clang, please install" |
229 exit 1 | 229 exit 1 |
230 fi | 230 fi |
231 | 231 |
232 echo Reverting previously patched files | 232 echo Reverting previously patched files |
233 for i in \ | 233 for i in \ |
234 "${CLANG_DIR}/test/Index/crash-recovery-modules.m" \ | 234 "${CLANG_DIR}/test/Index/crash-recovery-modules.m" \ |
235 "${CLANG_DIR}/unittests/libclang/LibclangTest.cpp" \ | 235 "${CLANG_DIR}/unittests/libclang/LibclangTest.cpp" \ |
236 "${COMPILER_RT_DIR}/lib/asan/asan_rtl.cc" \ | 236 "${COMPILER_RT_DIR}/lib/asan/asan_rtl.cc" \ |
237 "${COMPILER_RT_DIR}/test/asan/TestCases/Linux/new_array_cookie_test.cc" \ | 237 "${COMPILER_RT_DIR}/test/asan/TestCases/Linux/new_array_cookie_test.cc" \ |
| 238 "${LLVM_DIR}/test/DebugInfo/gmlt.ll" \ |
| 239 "${LLVM_DIR}/lib/CodeGen/SpillPlacement.cpp" \ |
| 240 "${LLVM_DIR}/lib/CodeGen/SpillPlacement.h" \ |
238 ; do | 241 ; do |
239 if [[ -e "${i}" ]]; then | 242 if [[ -e "${i}" ]]; then |
240 svn revert "${i}" | 243 svn revert "${i}" |
241 fi; | 244 fi; |
242 done | 245 done |
243 | 246 |
| 247 echo Remove the Clang tools shim dir |
| 248 CHROME_TOOLS_SHIM_DIR=${ABS_LLVM_DIR}/tools/chrometools |
| 249 rm -rfv ${CHROME_TOOLS_SHIM_DIR} |
| 250 |
244 echo Getting LLVM r"${CLANG_REVISION}" in "${LLVM_DIR}" | 251 echo Getting LLVM r"${CLANG_REVISION}" in "${LLVM_DIR}" |
245 if ! svn co --force "${LLVM_REPO_URL}/llvm/trunk@${CLANG_REVISION}" \ | 252 if ! svn co --force "${LLVM_REPO_URL}/llvm/trunk@${CLANG_REVISION}" \ |
246 "${LLVM_DIR}"; then | 253 "${LLVM_DIR}"; then |
247 echo Checkout failed, retrying | 254 echo Checkout failed, retrying |
248 rm -rf "${LLVM_DIR}" | 255 rm -rf "${LLVM_DIR}" |
249 svn co --force "${LLVM_REPO_URL}/llvm/trunk@${CLANG_REVISION}" "${LLVM_DIR}" | 256 svn co --force "${LLVM_REPO_URL}/llvm/trunk@${CLANG_REVISION}" "${LLVM_DIR}" |
250 fi | 257 fi |
251 | 258 |
252 echo Getting clang r"${CLANG_REVISION}" in "${CLANG_DIR}" | 259 echo Getting clang r"${CLANG_REVISION}" in "${CLANG_DIR}" |
253 svn co --force "${LLVM_REPO_URL}/cfe/trunk@${CLANG_REVISION}" "${CLANG_DIR}" | 260 svn co --force "${LLVM_REPO_URL}/cfe/trunk@${CLANG_REVISION}" "${CLANG_DIR}" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 | 310 |
304 -TEST_F(LibclangReparseTest, ReparseWithModule) { | 311 -TEST_F(LibclangReparseTest, ReparseWithModule) { |
305 +TEST_F(LibclangReparseTest, DISABLED_ReparseWithModule) { | 312 +TEST_F(LibclangReparseTest, DISABLED_ReparseWithModule) { |
306 const char *HeaderTop = "#ifndef H\n#define H\nstruct Foo { int bar;"; | 313 const char *HeaderTop = "#ifndef H\n#define H\nstruct Foo { int bar;"; |
307 const char *HeaderBottom = "\n};\n#endif\n"; | 314 const char *HeaderBottom = "\n};\n#endif\n"; |
308 const char *MFile = "#include \"HeaderFile.h\"\nint main() {" | 315 const char *MFile = "#include \"HeaderFile.h\"\nint main() {" |
309 EOF | 316 EOF |
310 patch -p0 | 317 patch -p0 |
311 popd | 318 popd |
312 | 319 |
| 320 # Apply r218742: test: XFAIL the non-darwin gmlt test on darwin |
| 321 # Back-ported becase the test was renamed. |
| 322 pushd "${LLVM_DIR}" |
| 323 cat << 'EOF' | |
| 324 --- a/test/DebugInfo/gmlt.ll |
| 325 +++ b/test/DebugInfo/gmlt.ll |
| 326 @@ -1,2 +1,5 @@ |
| 327 ; REQUIRES: object-emission |
| 328 ; RUN: %llc_dwarf -O0 -filetype=obj < %S/Inputs/gmlt.ll | llvm-dwarfdump - | Fi
leCheck %S/Inputs/gmlt.ll |
| 329 + |
| 330 +; There's a darwin specific test in X86/gmlt, so it's okay to XFAIL this here. |
| 331 +; XFAIL: darwin |
| 332 EOF |
| 333 patch -p1 |
| 334 popd |
| 335 |
| 336 # Apply r218921; fixes spill placement compile-time regression. |
| 337 pushd "${LLVM_DIR}" |
| 338 cat << 'EOF' | |
| 339 --- a/lib/CodeGen/SpillPlacement.cpp |
| 340 +++ b/lib/CodeGen/SpillPlacement.cpp |
| 341 @@ -61,27 +61,6 @@ void SpillPlacement::getAnalysisUsage(AnalysisUsage &AU) cons
t { |
| 342 MachineFunctionPass::getAnalysisUsage(AU); |
| 343 } |
| 344 |
| 345 -namespace { |
| 346 -static ManagedStatic<BlockFrequency> Threshold; |
| 347 -} |
| 348 - |
| 349 -/// Decision threshold. A node gets the output value 0 if the weighted sum of |
| 350 -/// its inputs falls in the open interval (-Threshold;Threshold). |
| 351 -static BlockFrequency getThreshold() { return *Threshold; } |
| 352 - |
| 353 -/// \brief Set the threshold for a given entry frequency. |
| 354 -/// |
| 355 -/// Set the threshold relative to \c Entry. Since the threshold is used as a |
| 356 -/// bound on the open interval (-Threshold;Threshold), 1 is the minimum |
| 357 -/// threshold. |
| 358 -static void setThreshold(const BlockFrequency &Entry) { |
| 359 - // Apparently 2 is a good threshold when Entry==2^14, but we need to scale |
| 360 - // it. Divide by 2^13, rounding as appropriate. |
| 361 - uint64_t Freq = Entry.getFrequency(); |
| 362 - uint64_t Scaled = (Freq >> 13) + bool(Freq & (1 << 12)); |
| 363 - *Threshold = std::max(UINT64_C(1), Scaled); |
| 364 -} |
| 365 - |
| 366 /// Node - Each edge bundle corresponds to a Hopfield node. |
| 367 /// |
| 368 /// The node contains precomputed frequency data that only depends on the CFG, |
| 369 @@ -127,9 +106,9 @@ struct SpillPlacement::Node { |
| 370 |
| 371 /// clear - Reset per-query data, but preserve frequencies that only depend o
n |
| 372 // the CFG. |
| 373 - void clear() { |
| 374 + void clear(const BlockFrequency &Threshold) { |
| 375 BiasN = BiasP = Value = 0; |
| 376 - SumLinkWeights = getThreshold(); |
| 377 + SumLinkWeights = Threshold; |
| 378 Links.clear(); |
| 379 } |
| 380 |
| 381 @@ -167,7 +146,7 @@ struct SpillPlacement::Node { |
| 382 |
| 383 /// update - Recompute Value from Bias and Links. Return true when node |
| 384 /// preference changes. |
| 385 - bool update(const Node nodes[]) { |
| 386 + bool update(const Node nodes[], const BlockFrequency &Threshold) { |
| 387 // Compute the weighted sum of inputs. |
| 388 BlockFrequency SumN = BiasN; |
| 389 BlockFrequency SumP = BiasP; |
| 390 @@ -187,9 +166,9 @@ struct SpillPlacement::Node { |
| 391 // 2. It helps tame rounding errors when the links nominally sum to 0. |
| 392 // |
| 393 bool Before = preferReg(); |
| 394 - if (SumN >= SumP + getThreshold()) |
| 395 + if (SumN >= SumP + Threshold) |
| 396 Value = -1; |
| 397 - else if (SumP >= SumN + getThreshold()) |
| 398 + else if (SumP >= SumN + Threshold) |
| 399 Value = 1; |
| 400 else |
| 401 Value = 0; |
| 402 @@ -228,7 +207,7 @@ void SpillPlacement::activate(unsigned n) { |
| 403 if (ActiveNodes->test(n)) |
| 404 return; |
| 405 ActiveNodes->set(n); |
| 406 - nodes[n].clear(); |
| 407 + nodes[n].clear(Threshold); |
| 408 |
| 409 // Very large bundles usually come from big switches, indirect branches, |
| 410 // landing pads, or loops with many 'continue' statements. It is difficult to |
| 411 @@ -245,6 +224,18 @@ void SpillPlacement::activate(unsigned n) { |
| 412 } |
| 413 } |
| 414 |
| 415 +/// \brief Set the threshold for a given entry frequency. |
| 416 +/// |
| 417 +/// Set the threshold relative to \c Entry. Since the threshold is used as a |
| 418 +/// bound on the open interval (-Threshold;Threshold), 1 is the minimum |
| 419 +/// threshold. |
| 420 +void SpillPlacement::setThreshold(const BlockFrequency &Entry) { |
| 421 + // Apparently 2 is a good threshold when Entry==2^14, but we need to scale |
| 422 + // it. Divide by 2^13, rounding as appropriate. |
| 423 + uint64_t Freq = Entry.getFrequency(); |
| 424 + uint64_t Scaled = (Freq >> 13) + bool(Freq & (1 << 12)); |
| 425 + Threshold = std::max(UINT64_C(1), Scaled); |
| 426 +} |
| 427 |
| 428 /// addConstraints - Compute node biases and weights from a set of constraints. |
| 429 /// Set a bit in NodeMask for each active node. |
| 430 @@ -311,7 +302,7 @@ bool SpillPlacement::scanActiveBundles() { |
| 431 Linked.clear(); |
| 432 RecentPositive.clear(); |
| 433 for (int n = ActiveNodes->find_first(); n>=0; n = ActiveNodes->find_next(n))
{ |
| 434 - nodes[n].update(nodes); |
| 435 + nodes[n].update(nodes, Threshold); |
| 436 // A node that must spill, or a node without any links is not going to |
| 437 // change its value ever again, so exclude it from iterations. |
| 438 if (nodes[n].mustSpill()) |
| 439 @@ -331,7 +322,7 @@ void SpillPlacement::iterate() { |
| 440 // First update the recently positive nodes. They have likely received new |
| 441 // negative bias that will turn them off. |
| 442 while (!RecentPositive.empty()) |
| 443 - nodes[RecentPositive.pop_back_val()].update(nodes); |
| 444 + nodes[RecentPositive.pop_back_val()].update(nodes, Threshold); |
| 445 |
| 446 if (Linked.empty()) |
| 447 return; |
| 448 @@ -350,7 +341,7 @@ void SpillPlacement::iterate() { |
| 449 iteration == 0 ? Linked.rbegin() : std::next(Linked.rbegin()), |
| 450 E = Linked.rend(); I != E; ++I) { |
| 451 unsigned n = *I; |
| 452 - if (nodes[n].update(nodes)) { |
| 453 + if (nodes[n].update(nodes, Threshold)) { |
| 454 Changed = true; |
| 455 if (nodes[n].preferReg()) |
| 456 RecentPositive.push_back(n); |
| 457 @@ -364,7 +355,7 @@ void SpillPlacement::iterate() { |
| 458 for (SmallVectorImpl<unsigned>::const_iterator I = |
| 459 std::next(Linked.begin()), E = Linked.end(); I != E; ++I) { |
| 460 unsigned n = *I; |
| 461 - if (nodes[n].update(nodes)) { |
| 462 + if (nodes[n].update(nodes, Threshold)) { |
| 463 Changed = true; |
| 464 if (nodes[n].preferReg()) |
| 465 RecentPositive.push_back(n); |
| 466 diff --git a/lib/CodeGen/SpillPlacement.h b/lib/CodeGen/SpillPlacement.h |
| 467 index 03cf5cd..622361e 100644 |
| 468 --- a/lib/CodeGen/SpillPlacement.h |
| 469 +++ b/lib/CodeGen/SpillPlacement.h |
| 470 @@ -62,6 +62,10 @@ class SpillPlacement : public MachineFunctionPass { |
| 471 // Block frequencies are computed once. Indexed by block number. |
| 472 SmallVector<BlockFrequency, 8> BlockFrequencies; |
| 473 |
| 474 + /// Decision threshold. A node gets the output value 0 if the weighted sum of |
| 475 + /// its inputs falls in the open interval (-Threshold;Threshold). |
| 476 + BlockFrequency Threshold; |
| 477 + |
| 478 public: |
| 479 static char ID; // Pass identification, replacement for typeid. |
| 480 |
| 481 @@ -152,6 +156,7 @@ private: |
| 482 void releaseMemory() override; |
| 483 |
| 484 void activate(unsigned); |
| 485 + void setThreshold(const BlockFrequency &Entry); |
| 486 }; |
| 487 |
| 488 } // end namespace llvm |
| 489 EOF |
| 490 patch -p1 |
| 491 popd |
| 492 |
| 493 |
313 # Echo all commands. | 494 # Echo all commands. |
314 set -x | 495 set -x |
315 | 496 |
316 # Set default values for CC and CXX if they're not set in the environment. | 497 # Set default values for CC and CXX if they're not set in the environment. |
317 CC=${CC:-cc} | 498 CC=${CC:-cc} |
318 CXX=${CXX:-c++} | 499 CXX=${CXX:-c++} |
319 | 500 |
320 if [[ -n "${gcc_toolchain}" ]]; then | 501 if [[ -n "${gcc_toolchain}" ]]; then |
321 # Use the specified gcc installation for building. | 502 # Use the specified gcc installation for building. |
322 CC="$gcc_toolchain/bin/gcc" | 503 CC="$gcc_toolchain/bin/gcc" |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 popd | 612 popd |
432 LDFLAGS+="-stdlib=libc++ -L${PWD}/libcxxbuild" | 613 LDFLAGS+="-stdlib=libc++ -L${PWD}/libcxxbuild" |
433 fi | 614 fi |
434 | 615 |
435 # Hook the Chromium tools into the LLVM build. Several Chromium tools have | 616 # Hook the Chromium tools into the LLVM build. Several Chromium tools have |
436 # dependencies on LLVM/Clang libraries. The LLVM build detects implicit tools | 617 # dependencies on LLVM/Clang libraries. The LLVM build detects implicit tools |
437 # in the tools subdirectory, so install a shim CMakeLists.txt that forwards to | 618 # in the tools subdirectory, so install a shim CMakeLists.txt that forwards to |
438 # the real directory for the Chromium tools. | 619 # the real directory for the Chromium tools. |
439 # Note that the shim directory name intentionally has no _ or _. The implicit | 620 # Note that the shim directory name intentionally has no _ or _. The implicit |
440 # tool detection logic munges them in a weird way. | 621 # tool detection logic munges them in a weird way. |
441 CHROME_TOOLS_SHIM_DIR=${ABS_LLVM_DIR}/tools/chrometools | |
442 rm -rfv ${CHROME_TOOLS_SHIM_DIR} | |
443 mkdir -v ${CHROME_TOOLS_SHIM_DIR} | 622 mkdir -v ${CHROME_TOOLS_SHIM_DIR} |
444 cat > ${CHROME_TOOLS_SHIM_DIR}/CMakeLists.txt << EOF | 623 cat > ${CHROME_TOOLS_SHIM_DIR}/CMakeLists.txt << EOF |
445 # Since tools/clang isn't actually a subdirectory, use the two argument version | 624 # Since tools/clang isn't actually a subdirectory, use the two argument version |
446 # to specify where build artifacts go. CMake doesn't allow reusing the same | 625 # to specify where build artifacts go. CMake doesn't allow reusing the same |
447 # binary dir for multiple source dirs, so the build artifacts have to go into a | 626 # binary dir for multiple source dirs, so the build artifacts have to go into a |
448 # subdirectory... | 627 # subdirectory... |
449 add_subdirectory(\${CHROMIUM_TOOLS_SRC} \${CMAKE_CURRENT_BINARY_DIR}/a) | 628 add_subdirectory(\${CHROMIUM_TOOLS_SRC} \${CMAKE_CURRENT_BINARY_DIR}/a) |
450 EOF | 629 EOF |
451 rm -fv CMakeCache.txt | 630 rm -fv CMakeCache.txt |
452 MACOSX_DEPLOYMENT_TARGET=${deployment_target} cmake -GNinja \ | 631 MACOSX_DEPLOYMENT_TARGET=${deployment_target} cmake -GNinja \ |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 -DCMAKE_BUILD_TYPE=Release \ | 718 -DCMAKE_BUILD_TYPE=Release \ |
540 -DLLVM_ENABLE_ASSERTIONS=ON \ | 719 -DLLVM_ENABLE_ASSERTIONS=ON \ |
541 -DLLVM_ENABLE_THREADS=OFF \ | 720 -DLLVM_ENABLE_THREADS=OFF \ |
542 -DCMAKE_C_COMPILER=${PWD}/../bin/clang \ | 721 -DCMAKE_C_COMPILER=${PWD}/../bin/clang \ |
543 -DCMAKE_CXX_COMPILER=${PWD}/../bin/clang++ \ | 722 -DCMAKE_CXX_COMPILER=${PWD}/../bin/clang++ \ |
544 -DLLVM_CONFIG_PATH=${PWD}/../bin/llvm-config \ | 723 -DLLVM_CONFIG_PATH=${PWD}/../bin/llvm-config \ |
545 -DCMAKE_C_FLAGS="--target=arm-linux-androideabi --sysroot=${PWD}/../androi
d-toolchain/sysroot -B${PWD}/../android-toolchain" \ | 724 -DCMAKE_C_FLAGS="--target=arm-linux-androideabi --sysroot=${PWD}/../androi
d-toolchain/sysroot -B${PWD}/../android-toolchain" \ |
546 -DCMAKE_CXX_FLAGS="--target=arm-linux-androideabi --sysroot=${PWD}/../andr
oid-toolchain/sysroot -B${PWD}/../android-toolchain" \ | 725 -DCMAKE_CXX_FLAGS="--target=arm-linux-androideabi --sysroot=${PWD}/../andr
oid-toolchain/sysroot -B${PWD}/../android-toolchain" \ |
547 -DANDROID=1 \ | 726 -DANDROID=1 \ |
548 "${ABS_COMPILER_RT_DIR}" | 727 "${ABS_COMPILER_RT_DIR}" |
549 ninja clang_rt.asan-arm-android | 728 ninja libclang_rt.asan-arm-android.so |
550 | 729 |
551 # And copy it into the main build tree. | 730 # And copy it into the main build tree. |
552 cp "$(find -name libclang_rt.asan-arm-android.so)" "${ABS_LLVM_CLANG_LIB_DIR}/
lib/linux/" | 731 cp "$(find -name libclang_rt.asan-arm-android.so)" "${ABS_LLVM_CLANG_LIB_DIR}/
lib/linux/" |
553 popd | 732 popd |
554 fi | 733 fi |
555 | 734 |
556 if [[ -n "$run_tests" ]]; then | 735 if [[ -n "$run_tests" ]]; then |
557 # Run Chrome tool tests. | 736 # Run Chrome tool tests. |
558 ninja -C "${LLVM_BUILD_DIR}" cr-check-all | 737 ninja -C "${LLVM_BUILD_DIR}" cr-check-all |
559 # Run the LLVM and Clang tests. | 738 # Run the LLVM and Clang tests. |
560 ninja -C "${LLVM_BUILD_DIR}" check-all | 739 ninja -C "${LLVM_BUILD_DIR}" check-all |
561 fi | 740 fi |
562 | 741 |
563 # After everything is done, log success for this revision. | 742 # After everything is done, log success for this revision. |
564 echo "${CLANG_AND_PLUGINS_REVISION}" > "${STAMP_FILE}" | 743 echo "${CLANG_AND_PLUGINS_REVISION}" > "${STAMP_FILE}" |
OLD | NEW |