diff --git a/clang-tools-extra/clangd/Protocol.h b/clang-tools-extra/clangd/Protocol.h
index 3a43a48367c053a74d412f8cb12ec14c74e3aa38..3a1eae58755485be71094fa2d64b06fe46656bed 100644
--- a/clang-tools-extra/clangd/Protocol.h
+++ b/clang-tools-extra/clangd/Protocol.h
@@ -7,7 +7,7 @@
 //===----------------------------------------------------------------------===//
 //
 // This file contains structs based on the LSP specification at
-// https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md
+// https://github.com/Microsoft/language-server-protocol/blob/main/protocol.md
 //
 // This is not meant to be a complete implementation, new interfaces are added
 // when they're needed.
@@ -1172,7 +1172,7 @@ enum class InsertTextFormat {
   /// typing in one will update others too.
   ///
   /// See also:
-  /// https//github.com/Microsoft/vscode/blob/master/src/vs/editor/contrib/snippet/common/snippet.md
+  /// https://github.com/Microsoft/vscode/blob/main/src/vs/editor/contrib/snippet/snippet.md
   Snippet = 2,
 };
 
diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst
index e9a381c93a46bd1ed6ebfbb4f330861e1f6f7ae0..2d4e1b56dcb59588caf10876f648ebc51a22fb98 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -149,7 +149,7 @@ the configuration (without a prefix: ``Auto``).
     <https://google.github.io/styleguide/cppguide.html>`_
   * ``Chromium``
     A style complying with `Chromium's style guide
-    <https://chromium.googlesource.com/chromium/src/+/master/styleguide/styleguide.md>`_
+    <https://chromium.googlesource.com/chromium/src/+/refs/heads/main/styleguide/styleguide.md>`_
   * ``Mozilla``
     A style complying with `Mozilla's style guide
     <https://developer.mozilla.org/en-US/docs/Developer_Guide/Coding_Style>`_
diff --git a/clang/docs/LibFormat.rst b/clang/docs/LibFormat.rst
index 4ea84e658d1b00c04b287134355a06a71f93ea51..833f768c54a64d77a930195ebac3e6c8b2477860 100644
--- a/clang/docs/LibFormat.rst
+++ b/clang/docs/LibFormat.rst
@@ -53,7 +53,7 @@ several style guides are hard-coded:
   FormatStyle getGoogleStyle();
 
   /// Returns a format style complying with Chromium's style guide:
-  /// https://chromium.googlesource.com/chromium/src/+/master/styleguide/styleguide.md
+  /// https://chromium.googlesource.com/chromium/src/+/refs/heads/main/styleguide/styleguide.md
   FormatStyle getChromiumStyle();
 
   /// Returns a format style complying with the GNU coding standards:
diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 68c112c964f28b3edecc0d1b1b6719f3f2c6eab7..8c6922db6b37dc005166a4588211599e8ca11c60 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -3139,7 +3139,7 @@ extension should use reserved identifier prefix e.g. amd, arm, intel.
 
 Clang also supports language extensions documented in `The OpenCL C Language
 Extensions Documentation
-<https://github.com/KhronosGroup/Khronosdotorg/blob/master/api/opencl/assets/OpenCL_LangExt.pdf>`_.
+<https://github.com/KhronosGroup/Khronosdotorg/blob/main/api/opencl/assets/OpenCL_LangExt.pdf>`_.
 
 OpenCL-Specific Attributes
 --------------------------
diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 799da1247cd347ed9f863c133dd1256b6451091b..07579d04e27546137e2c41b890b8a5e62d1dbfdd 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -3572,7 +3572,7 @@ void CXXNameMangler::mangleAArch64NeonVectorType(const DependentVectorType *T) {
 // mangling scheme, it will be specified in the next revision. The mangling
 // scheme is otherwise defined in the appendices to the Procedure Call Standard
 // for the Arm Architecture, see
-// https://github.com/ARM-software/abi-aa/blob/master/aapcs64/aapcs64.rst#appendix-c-mangling
+// https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#appendix-c-mangling
 void CXXNameMangler::mangleAArch64FixedSveVectorType(const VectorType *T) {
   assert((T->getVectorKind() == VectorType::SveFixedLengthDataVector ||
           T->getVectorKind() == VectorType::SveFixedLengthPredicateVector) &&
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 16f39062423e98b6ee7dd098ddd4387e159ce7e2..c499831241ab5357bab33c15e896e1c4da5a290b 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1386,7 +1386,7 @@ FormatStyle getChromiumStyle(FormatStyle::LanguageKind Language) {
     ChromiumStyle.ContinuationIndentWidth = 8;
     ChromiumStyle.IndentWidth = 4;
     // See styleguide for import groups:
-    // https://chromium.googlesource.com/chromium/src/+/master/styleguide/java/java.md#Import-Order
+    // https://chromium.googlesource.com/chromium/src/+/refs/heads/main/styleguide/java/java.md#Import-Order
     ChromiumStyle.JavaImportGroups = {
         "android",
         "androidx",
diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index bbce27f799bc7506227e93d9523ecc6968e670cf..06d51dd95f50f11dfd190138bdaf2d2512766014 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -1060,7 +1060,7 @@ struct AdditionalKeywords {
   bool IsJavaScriptIdentifier(const FormatToken &Tok,
                               bool AcceptIdentifierName = true) const {
     // Based on the list of JavaScript & TypeScript keywords here:
-    // https://github.com/microsoft/TypeScript/blob/master/src/compiler/scanner.ts#L74
+    // https://github.com/microsoft/TypeScript/blob/main/src/compiler/scanner.ts#L74
     switch (Tok.Tok.getKind()) {
     case tok::kw_break:
     case tok::kw_case:
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index e6be3a918034bafef85bad90f863a9a56bc8b976..5686a6e7587c9bb0fd8f60f5d95f2ca0637946d6 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -4061,7 +4061,7 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
                       Keywords.kw_interface, Keywords.kw_type, Keywords.kw_var,
                       Keywords.kw_let, tok::kw_const))
       // See grammar for 'declare' statements at:
-      // https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#A.10
+      // https://github.com/Microsoft/TypeScript/blob/main/doc/spec-ARCHIVED.md#A.10
       return false;
     if (Left.isOneOf(Keywords.kw_module, tok::kw_namespace) &&
         Right.isOneOf(tok::identifier, tok::string_literal))
diff --git a/clang/test/OpenMP/aarch64_vfabi_NarrowestDataSize.c b/clang/test/OpenMP/aarch64_vfabi_NarrowestDataSize.c
index d65c4edaeea7095eff499524a9ee22999b423b61..4186ec8e0730157b35512ae6a3e68a173283a2b0 100644
--- a/clang/test/OpenMP/aarch64_vfabi_NarrowestDataSize.c
+++ b/clang/test/OpenMP/aarch64_vfabi_NarrowestDataSize.c
@@ -5,7 +5,7 @@
 // Note: -fopemp and -fopenmp-simd behavior are expected to be the same.
 
 // This test checks the values of Narrowest Data Size (NDS), as defined in
-// https://github.com/ARM-software/abi-aa/tree/master/vfabia64
+// https://github.com/ARM-software/abi-aa/tree/main/vfabia64
 //
 // NDS is used to compute the <vlen> token in the name of AdvSIMD
 // vector functions when no `simdlen` is specified, with the rule:
diff --git a/clang/test/OpenMP/aarch64_vfabi_WidestDataSize.c b/clang/test/OpenMP/aarch64_vfabi_WidestDataSize.c
index 841a64053e5e3b65e3226ab25123ebeaff87ff0d..9d3689a57ce9474864c1586d4e4e1f72296a48f1 100644
--- a/clang/test/OpenMP/aarch64_vfabi_WidestDataSize.c
+++ b/clang/test/OpenMP/aarch64_vfabi_WidestDataSize.c
@@ -5,7 +5,7 @@
 // Note: -fopemp and -fopenmp-simd behavior are expected to be the same.
 
 // This test checks the values of Widest Data Size (WDS), as defined
-// in https://github.com/ARM-software/abi-aa/tree/master/vfabia64
+// in https://github.com/ARM-software/abi-aa/tree/main/vfabia64
 //
 // WDS is used to check the accepted values <N> of `simdlen(<N>)` when
 // targeting fixed-length SVE vector function names. The values of
diff --git a/clang/www/related.html b/clang/www/related.html
index 2c53c1a7f0d45c83fd82d7c6a41779e1c7c2ad09..d45f5336776541000908a40e85b92db3a71e7357 100755
--- a/clang/www/related.html
+++ b/clang/www/related.html
@@ -39,8 +39,8 @@
       <dd>
         <p>
           <b>Site:</b>
-          <a href="https://chromium.googlesource.com/chromium/src/+/master/docs/clang.md">
-            https://chromium.googlesource.com/chromium/src/+/master/docs/clang.md</a>
+          <a href="https://chromium.googlesource.com/chromium/src/+/refs/heads/main/docs/clang.md">
+            https://chromium.googlesource.com/chromium/src/+/refs/heads/main/docs/clang.md</a>
         </p>
         <p>
           Notes on using Clang to build the Chromium web browser.
diff --git a/libcxx/utils/ci/Dockerfile b/libcxx/utils/ci/Dockerfile
index 6e1d2bf4cd8d1a6c7279c5f55bac30115feba2a8..689d3f58775a47eb3cf5e2a4041eae691a97e803 100644
--- a/libcxx/utils/ci/Dockerfile
+++ b/libcxx/utils/ci/Dockerfile
@@ -91,7 +91,7 @@ WORKDIR /home/libcxx-builder
 
 # Install the Buildkite agent and dependencies. This must be done as non-root
 # for the Buildkite agent to be installed in a path where we can find it.
-RUN bash -c "$(curl -sL https://raw.githubusercontent.com/buildkite/agent/master/install.sh)"
+RUN bash -c "$(curl -sL https://raw.githubusercontent.com/buildkite/agent/main/install.sh)"
 ENV PATH="${PATH}:/home/libcxx-builder/.buildkite-agent/bin"
 RUN echo "tags=\"queue=libcxx-builders,arch=$(uname -m),os=linux\"" >> "/home/libcxx-builder/.buildkite-agent/buildkite-agent.cfg"
 
diff --git a/lld/docs/WebAssembly.rst b/lld/docs/WebAssembly.rst
index c01df99cddb96964b75b4485372f5cd464535263..89690d800588bc633a8af408d0d3a97294d08f12 100644
--- a/lld/docs/WebAssembly.rst
+++ b/lld/docs/WebAssembly.rst
@@ -205,6 +205,6 @@ Missing features
   supported.
 - No support for creating shared libraries.  The spec for shared libraries in
   WebAssembly is still in flux:
-  https://github.com/WebAssembly/tool-conventions/blob/master/DynamicLinking.md
+  https://github.com/WebAssembly/tool-conventions/blob/main/DynamicLinking.md
 
-.. _linking: https://github.com/WebAssembly/tool-conventions/blob/master/Linking.md
+.. _linking: https://github.com/WebAssembly/tool-conventions/blob/main/Linking.md
diff --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp
index 3a2d2fde34e25235cc2411f750593dfc960ca5ef..59abfaadf3989eb34c17765a6b2ddbae7717348b 100644
--- a/lld/wasm/Driver.cpp
+++ b/lld/wasm/Driver.cpp
@@ -632,7 +632,7 @@ static void createSyntheticSymbols() {
     // __table_base) from the environment and use these as the offset at
     // which to load our static data and function table.
     // See:
-    // https://github.com/WebAssembly/tool-conventions/blob/master/DynamicLinking.md
+    // https://github.com/WebAssembly/tool-conventions/blob/main/DynamicLinking.md
     auto *globalType = is64 ? &globalTypeI64 : &globalTypeI32;
     WasmSym::memoryBase = createUndefinedGlobal("__memory_base", globalType);
     WasmSym::tableBase = createUndefinedGlobal("__table_base", globalType);
diff --git a/lld/wasm/SyntheticSections.h b/lld/wasm/SyntheticSections.h
index 956c896148db06583d524036de9ec3d90d4973ba..9a425ea4f6ec3baa93b0248ab137025afba8db90 100644
--- a/lld/wasm/SyntheticSections.h
+++ b/lld/wasm/SyntheticSections.h
@@ -71,7 +71,7 @@ protected:
 // Create the custom "dylink" section containing information for the dynamic
 // linker.
 // See
-// https://github.com/WebAssembly/tool-conventions/blob/master/DynamicLinking.md
+// https://github.com/WebAssembly/tool-conventions/blob/main/DynamicLinking.md
 class DylinkSection : public SyntheticSection {
 public:
   DylinkSection() : SyntheticSection(llvm::wasm::WASM_SEC_CUSTOM, "dylink.0") {}
diff --git a/lldb/unittests/Process/minidump/Inputs/linux-x86_64.cpp b/lldb/unittests/Process/minidump/Inputs/linux-x86_64.cpp
index 827fe67b503b81d939bebb67e8652029c5d65a28..830b090ed808eb90a9b79e58dfcc2eafd6a33655 100644
--- a/lldb/unittests/Process/minidump/Inputs/linux-x86_64.cpp
+++ b/lldb/unittests/Process/minidump/Inputs/linux-x86_64.cpp
@@ -1,5 +1,5 @@
 // Example source from breakpad's linux tutorial
-// https://chromium.googlesource.com/breakpad/breakpad/+/master/docs/linux_starter_guide.md
+// https://chromium.googlesource.com/breakpad/breakpad/+/main/docs/linux_starter_guide.md
 
 #include <stdio.h>
 #include <sys/types.h>
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index d3fb7dc4126927e65cd45877d1600523311189b9..00fccac4ab170a738a84dd09225f0948a4e7bca6 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -812,7 +812,7 @@ if(LLVM_INCLUDE_TESTS)
 endif()
 
 # For up-to-date instructions for installing the Tensorflow dependency, refer to
-# the bot setup script: https://github.com/google/ml-compiler-opt/blob/master/buildbot/buildbot_init.sh
+# the bot setup script: https://github.com/google/ml-compiler-opt/blob/main/buildbot/buildbot_init.sh
 # In this case, the latest C API library is available for download from
 # https://www.tensorflow.org/install/lang_c.
 # We will expose the conditional compilation variable,
@@ -846,7 +846,7 @@ if (TENSORFLOW_C_LIB_PATH)
 endif()
 
 # For up-to-date instructions for installing the Tensorflow dependency, refer to
-# the bot setup script: https://github.com/google/ml-compiler-opt/blob/master/buildbot/buildbot_init.sh
+# the bot setup script: https://github.com/google/ml-compiler-opt/blob/main/buildbot/buildbot_init.sh
 # Specifically, assuming python3 is installed:
 # python3 -m pip install --upgrade pip && python3 -m pip install --user tf_nightly==2.3.0.dev20200528
 # Then set TENSORFLOW_AOT_PATH to the package install - usually it's ~/.local/lib/python3.7/site-packages/tensorflow
diff --git a/llvm/docs/CompileCudaWithLLVM.rst b/llvm/docs/CompileCudaWithLLVM.rst
index a2d7fd0b7453ac0d2633236e504a39b22437b776..a63f5a111413213d047dcdafb2bd23206ee31c57 100644
--- a/llvm/docs/CompileCudaWithLLVM.rst
+++ b/llvm/docs/CompileCudaWithLLVM.rst
@@ -144,9 +144,9 @@ device side.
 ----------------------------
 
 In clang, ``math.h`` and ``cmath`` are available and `pass
-<https://github.com/llvm/llvm-test-suite/blob/master/External/CUDA/math_h.cu>`_
+<https://github.com/llvm/llvm-test-suite/blob/main/External/CUDA/math_h.cu>`_
 `tests
-<https://github.com/llvm/llvm-test-suite/blob/master/External/CUDA/cmath.cu>`_
+<https://github.com/llvm/llvm-test-suite/blob/main/External/CUDA/cmath.cu>`_
 adapted from libc++'s test suite.
 
 In nvcc ``math.h`` and ``cmath`` are mostly available.  Versions of ``::foof``
diff --git a/llvm/docs/Proposals/TestSuite.rst b/llvm/docs/Proposals/TestSuite.rst
index 29507495c116858c38ee8f2e94753ea88e41d25d..33bb890244ffb8f729d6e86d6403e3a13ff61e1f 100644
--- a/llvm/docs/Proposals/TestSuite.rst
+++ b/llvm/docs/Proposals/TestSuite.rst
@@ -219,7 +219,7 @@ http://www.nwchem-sw.org/index.php/Benchmarks
 
 TVM
 ----
-https://github.com/dmlc/tvm/tree/master/apps/benchmark
+https://github.com/dmlc/tvm/tree/main/apps/benchmark
 
 HydroBench
 ----------
@@ -227,7 +227,7 @@ https://github.com/HydroBench/Hydro
 
 ParRes
 ------
-https://github.com/ParRes/Kernels/tree/master/Cxx11
+https://github.com/ParRes/Kernels/tree/default/Cxx11
 
 Applications/Libraries
 ======================
diff --git a/llvm/include/llvm/BinaryFormat/Wasm.h b/llvm/include/llvm/BinaryFormat/Wasm.h
index 0940d189136d3336c2d56dc6d593ad709e5fd914..0bc8c4e167d852f33f3d0ce6e75e7db591a2c07e 100644
--- a/llvm/include/llvm/BinaryFormat/Wasm.h
+++ b/llvm/include/llvm/BinaryFormat/Wasm.h
@@ -7,7 +7,7 @@
 //===----------------------------------------------------------------------===//
 //
 // This file defines manifest constants for the wasm object file format.
-// See: https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md
+// See: https://github.com/WebAssembly/design/blob/main/BinaryEncoding.md
 //
 //===----------------------------------------------------------------------===//
 
diff --git a/llvm/include/llvm/Object/Wasm.h b/llvm/include/llvm/Object/Wasm.h
index 69ae0dc126d1aad80ca02780e70d70edf91d0d66..e4802c087b8b4cbb68b9bd2799518b9745261b59 100644
--- a/llvm/include/llvm/Object/Wasm.h
+++ b/llvm/include/llvm/Object/Wasm.h
@@ -9,7 +9,7 @@
 // This file declares the WasmObjectFile class, which implements the ObjectFile
 // interface for Wasm files.
 //
-// See: https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md
+// See: https://github.com/WebAssembly/design/blob/main/BinaryEncoding.md
 //
 //===----------------------------------------------------------------------===//
 
diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp
index 015931ba4cac4898a0aa9da66a744dbbb2612e6b..636c1d238932f6fa125e01a32669dae70f068307 100644
--- a/llvm/lib/MC/WasmObjectWriter.cpp
+++ b/llvm/lib/MC/WasmObjectWriter.cpp
@@ -1087,7 +1087,7 @@ uint32_t WasmObjectWriter::writeDataSection(const MCAsmLayout &Layout) {
 void WasmObjectWriter::writeRelocSection(
     uint32_t SectionIndex, StringRef Name,
     std::vector<WasmRelocationEntry> &Relocs) {
-  // See: https://github.com/WebAssembly/tool-conventions/blob/master/Linking.md
+  // See: https://github.com/WebAssembly/tool-conventions/blob/main/Linking.md
   // for descriptions of the reloc sections.
 
   if (Relocs.empty())
diff --git a/llvm/lib/Object/WasmObjectFile.cpp b/llvm/lib/Object/WasmObjectFile.cpp
index fedfcae959122d54346a975eefa60a95bb84e680..6a19b159f3d5717de2bc46b9f45c913809c4eafa 100644
--- a/llvm/lib/Object/WasmObjectFile.cpp
+++ b/llvm/lib/Object/WasmObjectFile.cpp
@@ -359,7 +359,7 @@ Error WasmObjectFile::parseDylinkSection(ReadContext &Ctx) {
 
 Error WasmObjectFile::parseDylink0Section(ReadContext &Ctx) {
   // See
-  // https://github.com/WebAssembly/tool-conventions/blob/master/DynamicLinking.md
+  // https://github.com/WebAssembly/tool-conventions/blob/main/DynamicLinking.md
   HasDylinkSection = true;
 
   const uint8_t *OrigEnd = Ctx.End;
diff --git a/llvm/lib/Target/WebAssembly/README.txt b/llvm/lib/Target/WebAssembly/README.txt
index 934a3ba3bc4aab5518dab915f042d035ff42b39d..ab1cd8f0f84a26d3309c2da20a1ee3867f056f8b 100644
--- a/llvm/lib/Target/WebAssembly/README.txt
+++ b/llvm/lib/Target/WebAssembly/README.txt
@@ -2,11 +2,11 @@
 
 The object format emitted by the WebAssembly backed is documented in:
 
-  * https://github.com/WebAssembly/tool-conventions/blob/master/Linking.md
+  * https://github.com/WebAssembly/tool-conventions/blob/main/Linking.md
 
 The C ABI is described in:
 
-  * https://github.com/WebAssembly/tool-conventions/blob/master/BasicCABI.md
+  * https://github.com/WebAssembly/tool-conventions/blob/main/BasicCABI.md
 
 For more information on WebAssembly itself, see the home page:
 
@@ -31,8 +31,8 @@ For more information, see:
 
 The following documents contain some information on the semantics and binary
 encoding of WebAssembly itself:
-  * https://github.com/WebAssembly/design/blob/master/Semantics.md
-  * https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md
+  * https://github.com/WebAssembly/design/blob/main/Semantics.md
+  * https://github.com/WebAssembly/design/blob/main/BinaryEncoding.md
 
 Some notes on ways that the generated code could be improved follow:
 
diff --git a/llvm/tools/vfabi-demangle-fuzzer/vfabi-demangler-fuzzer.cpp b/llvm/tools/vfabi-demangle-fuzzer/vfabi-demangler-fuzzer.cpp
index d19629858a429100a2e11e95e95f82b7fba28ab6..b0b80131bf48f4864d4fbf4039d2faca3c90a27e 100644
--- a/llvm/tools/vfabi-demangle-fuzzer/vfabi-demangler-fuzzer.cpp
+++ b/llvm/tools/vfabi-demangle-fuzzer/vfabi-demangler-fuzzer.cpp
@@ -34,7 +34,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
   const auto Info = VFABI::tryDemangleForVFABI(MangledName, *M);
 
   // Do not optimize away the return value. Inspired by
-  // https://github.com/google/benchmark/blob/master/include/benchmark/benchmark.h#L307-L345
+  // https://github.com/google/benchmark/blob/main/include/benchmark/benchmark.h#L307-L345
   asm volatile("" : : "r,m"(Info) : "memory");
 
   return 0;
diff --git a/llvm/utils/gn/README.rst b/llvm/utils/gn/README.rst
index 74b4e88da4c7a30c4393420a2f5948bca0040412..9ca545061099d84fffa8694a546f2449a3c90624 100644
--- a/llvm/utils/gn/README.rst
+++ b/llvm/utils/gn/README.rst
@@ -63,7 +63,7 @@ before starting the build.
 
 GN has extensive built-in help; try e.g. ``llvm/utils/gn/gn.py help gen`` to see
 the help for the ``gen`` command. The full GN reference is also `available
-online <https://gn.googlesource.com/gn/+/master/docs/reference.md>`_.
+online <https://gn.googlesource.com/gn/+/refs/heads/main/docs/reference.md>`_.
 
 GN has an autoformatter:
 ``git ls-files '*.gn' '*.gni' | xargs llvm/utils/gn/gn.py format``
diff --git a/mlir/docs/Dialects/SPIR-V.md b/mlir/docs/Dialects/SPIR-V.md
index 9e9106b3f53827464c15604720e06501dd35502b..b79d9e8bdd31faa4651a0fb40164c9db914191b3 100644
--- a/mlir/docs/Dialects/SPIR-V.md
+++ b/mlir/docs/Dialects/SPIR-V.md
@@ -1422,8 +1422,8 @@ dialect.
 [GitHubLoweringTracking]: https://github.com/tensorflow/mlir/issues/303
 [GenSpirvUtilsPy]: https://github.com/llvm/llvm-project/blob/main/mlir/utils/spirv/gen_spirv_dialect.py
 [CustomTypeAttrTutorial]: ../Tutorials/DefiningAttributesAndTypes.md
-[VulkanExtensionPhysicalStorageBuffer]: https://github.com/KhronosGroup/SPIRV-Registry/blob/master/extensions/KHR/SPV_KHR_physical_storage_buffer.html
-[VulkanExtensionVariablePointers]: https://github.com/KhronosGroup/SPIRV-Registry/blob/master/extensions/KHR/SPV_KHR_variable_pointers.html
+[VulkanExtensionPhysicalStorageBuffer]: https://github.com/KhronosGroup/SPIRV-Registry/blob/main/extensions/KHR/SPV_KHR_physical_storage_buffer.html
+[VulkanExtensionVariablePointers]: https://github.com/KhronosGroup/SPIRV-Registry/blob/main/extensions/KHR/SPV_KHR_variable_pointers.html
 [VulkanSpirv]: https://renderdoc.org/vkspec_chunked/chap40.html#spirvenv
 [VulkanShaderInterface]: https://renderdoc.org/vkspec_chunked/chap14.html#interfaces-resources
 [VulkanShaderInterfaceStorageClass]: https://renderdoc.org/vkspec_chunked/chap15.html#interfaces
diff --git a/mlir/docs/LangRef.md b/mlir/docs/LangRef.md
index c3818d33fff24c96c6e76a471b702b12eb12ef8f..357778a54f08731904d5d0816d2d4ad1dc0e3474 100644
--- a/mlir/docs/LangRef.md
+++ b/mlir/docs/LangRef.md
@@ -3,7 +3,7 @@
 MLIR (Multi-Level IR) is a compiler intermediate representation with
 similarities to traditional three-address SSA representations (like
 [LLVM IR](http://llvm.org/docs/LangRef.html) or
-[SIL](https://github.com/apple/swift/blob/master/docs/SIL.rst)), but which
+[SIL](https://github.com/apple/swift/blob/main/docs/SIL.rst)), but which
 introduces notions from polyhedral loop optimization as first-class concepts.
 This hybrid design is optimized to represent, analyze, and transform high level
 dataflow graphs as well as target-specific code generated for high performance
diff --git a/mlir/docs/Rationale/Rationale.md b/mlir/docs/Rationale/Rationale.md
index c64e6f69f9130613e4b9545d3df05de87f4c7503..192ec7ef7e2e874c2d14bf565ab3f686ffd3029f 100644
--- a/mlir/docs/Rationale/Rationale.md
+++ b/mlir/docs/Rationale/Rationale.md
@@ -13,7 +13,7 @@ about their consistency or readability.
 MLIR is a compiler intermediate representation with similarities to traditional
 three-address SSA representations (like
 [LLVM IR](http://llvm.org/docs/LangRef.html) or
-[SIL](https://github.com/apple/swift/blob/master/docs/SIL.rst)), but which
+[SIL](https://github.com/apple/swift/blob/main/docs/SIL.rst)), but which
 introduces notions from the polyhedral loop optimization works as first class
 concepts. This hybrid design is optimized to represent, analyze, and transform
 high level dataflow graphs as well as target-specific code generated for high
@@ -195,10 +195,10 @@ represented in either form) but block arguments have several advantages:
     [landingpad instruction](http://llvm.org/docs/LangRef.html#landingpad-instruction)
     is a hack used to represent this. MLIR doesn't make use of this capability,
     but SIL uses it extensively, e.g. in the
-    [switch_enum instruction](https://github.com/apple/swift/blob/master/docs/SIL.rst#switch-enum).
+    [switch_enum instruction](https://github.com/apple/swift/blob/main/docs/SIL.rst#switch-enum).
 
 For more context, block arguments were previously used in the Swift
-[SIL Intermediate Representation](https://github.com/apple/swift/blob/master/docs/SIL.rst),
+[SIL Intermediate Representation](https://github.com/apple/swift/blob/main/docs/SIL.rst),
 and described in
 [a talk on YouTube](https://www.youtube.com/watch?v=Ntj8ab-5cvE). The section of
 interest
diff --git a/mlir/docs/Rationale/RationaleGenericDAGRewriter.md b/mlir/docs/Rationale/RationaleGenericDAGRewriter.md
index b0a1c163ee71c7bdc3986df994fddb4fe4b3a9e0..d586b1f7719c0c88a8276b24289b232e195b5bbb 100644
--- a/mlir/docs/Rationale/RationaleGenericDAGRewriter.md
+++ b/mlir/docs/Rationale/RationaleGenericDAGRewriter.md
@@ -102,7 +102,7 @@ GCC
 LLVM's
 [DAG Combiner](https://github.com/llvm-mirror/llvm/blob/master/lib/CodeGen/SelectionDAG/DAGCombiner.cpp),
 the Swift compiler's
-[SIL Combiner](https://github.com/apple/swift/tree/master/lib/SILOptimizer/SILCombiner),
+[SIL Combiner](https://github.com/apple/swift/tree/main/lib/SILOptimizer/SILCombiner),
 etc. These generally match one or more operations and produce zero or more
 operations as a result. The LLVM
 [Legalization](https://github.com/llvm/llvm-project/tree/main/llvm/lib/CodeGen/SelectionDAG)
diff --git a/mlir/include/mlir/Dialect/LLVMIR/ROCDLDialect.h b/mlir/include/mlir/Dialect/LLVMIR/ROCDLDialect.h
index b00b8ac0b125a355459081dc2308078fc4f3cebf..478b31f3a6d8a147254dd1e2910a48929a9d28f6 100644
--- a/mlir/include/mlir/Dialect/LLVMIR/ROCDLDialect.h
+++ b/mlir/include/mlir/Dialect/LLVMIR/ROCDLDialect.h
@@ -13,8 +13,8 @@
 // pointed to here. However the following links contain more information about
 // ROCDL (ROCm-Device-Library)
 //
-// https://github.com/RadeonOpenCompute/ROCm-Device-Libs/blob/master/doc/OCML.md
-// https://github.com/RadeonOpenCompute/ROCm-Device-Libs/blob/master/doc/OCKL.md
+// https://github.com/RadeonOpenCompute/ROCm-Device-Libs/blob/amd-stg-open/doc/OCML.md
+// https://github.com/RadeonOpenCompute/ROCm-Device-Libs/blob/amd-stg-open/doc/OCKL.md
 // https://llvm.org/docs/AMDGPUUsage.html
 //
 //===----------------------------------------------------------------------===//
diff --git a/mlir/lib/Tools/mlir-lsp-server/lsp/Protocol.h b/mlir/lib/Tools/mlir-lsp-server/lsp/Protocol.h
index d0f7b052620b69111e9acc7edc083f9b813c4526..8a3f47ed59891d1f2fe445e15cd2353b79b1ae4a 100644
--- a/mlir/lib/Tools/mlir-lsp-server/lsp/Protocol.h
+++ b/mlir/lib/Tools/mlir-lsp-server/lsp/Protocol.h
@@ -7,7 +7,7 @@
 //===----------------------------------------------------------------------===//
 //
 // This file contains structs based on the LSP specification at
-// https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md
+// https://github.com/Microsoft/language-server-protocol/blob/main/protocol.md
 //
 // This is not meant to be a complete implementation, new interfaces are added
 // when they're needed.
diff --git a/utils/bazel/.bazelrc b/utils/bazel/.bazelrc
index 92ff7d30b0a222179a54cb9eeff11b6d49bebc88..0ad68148b8b36e7fc6d4462705589180c058d4f5 100644
--- a/utils/bazel/.bazelrc
+++ b/utils/bazel/.bazelrc
@@ -158,7 +158,7 @@ build:rbe --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
 # Platform flags:
 # The toolchain container used for execution is defined in the target indicated
 # by "extra_execution_platforms", "host_platform" and "platforms".
-# More about platforms: https://docs.bazel.build/versions/master/platforms.html
+# More about platforms: https://docs.bazel.build/versions/main/platforms.html
 build:rbe --extra_toolchains=@rbe_default//config:cc-toolchain
 build:rbe --extra_execution_platforms=@rbe_default//config:platform
 build:rbe --host_platform=@rbe_default//config:platform
diff --git a/utils/bazel/README.md b/utils/bazel/README.md
index 3521f897ca88e1a76e7831282b6bc0b6a9e4b699..fe8ead32f7d90daaf8069911055b426ad0d0420a 100644
--- a/utils/bazel/README.md
+++ b/utils/bazel/README.md
@@ -28,7 +28,7 @@ for adding this configuration.
    you don't have a checkout yet.
 2. Install Bazel at the version indicated by [.bazelversion](./.bazelversion),
    following the official instructions, if you don't have it installed yet:
-   https://docs.bazel.build/versions/master/install.html.
+   https://docs.bazel.build/versions/main/install.html.
 3. `cd utils/bazel`
 4. `bazel build --config=generic_clang @llvm-project//...` (if building on Unix
    with Clang). `--config=generic_gcc` and `--config=msvc` are also available.
@@ -45,7 +45,7 @@ build --config=generic_clang
 ```
 
 You can enable
-[disk caching](https://docs.bazel.build/versions/master/remote-caching.html#disk-cache),
+[disk caching](https://docs.bazel.build/versions/main/remote-caching.html#disk-cache),
 which will cache build results
 
 ```.bazelrc
@@ -53,7 +53,7 @@ build --disk_cache=~/.cache/bazel-disk-cache
 ```
 
 You can instruct Bazel to use a ramdisk for its sandboxing operations via
-[--sandbox_base](https://docs.bazel.build/versions/master/command-line-reference.html#flag--sandbox_base),
+[--sandbox_base](https://docs.bazel.build/versions/main/command-line-reference.html#flag--sandbox_base),
 which can help avoid IO bottlenecks for the symlink stragegy used for
 sandboxing. This is especially important with many inputs and many cores (see
 https://github.com/bazelbuild/bazel/issues/11868):