← Back to Pull requests

[Clang] Add memtag attribute for globals #241400

Open
ptosi opened this pull request with 271 lines diff across 8 files
View on GitHub
ptosi ptosi commented on Nov 11, 2026 17:22 UTC
Author

Add __attribute__((memtag)) ([[clang::memtag]]) to selectively enable hardware memory tagging (currently, aarch64 MTE) on individual global variables. It is implemented as a per-variable switch to leverage the infrastructure introduced for -fsanitize=memtag-globals (including at load time) in a more granular way. As a result, compiled code can use memory tagging only on those globals that require it, while leaving less security-sensitive ones unaffected.

Reject the attribute on variables which memtag-globals would have skipped such as non-global, non-mutable, or TLS-stored ones. Similarly, diagnose conflicting no_sanitize("memtag").

Gate the attribute such that __has_attribute(memtag) is false when the target does not support memory tagging. This enables saving the non-MTE overhead (granule alignment & GOT indirection) on targets that would never make use of the feature.

_Disclaimer: This PR contains a substantial amount of tool-generated content_

Diff: 271 lines (+267 / -4) across 8 files Reviewer: daniel-petrovic Review duration: 31648m
All Vouch review confidence checks passed
Residual risk 0.04 = Change Risk (0.47) × (1 − Review Confidence (0.91)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.47 · 271 lines diff across 8 files
0.47
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.89 · 5 substantive comment(s)
0.89
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
90%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.335
Real PR Conversation Timeline
11 items
github-actions[bot] github-actions[bot] commented on Nov 11, 2026 17:23 UTC
Bot

<!--LLVM NEW CONTRIBUTOR COMMENT-->

Hello @ptosi :wave:

Thank you for submitting a Pull Request (PR) to the LLVM Project. Since this is your first PR, here are a few useful links covering our main contribution policies and review practices.

All contributions to LLVM must follow our LLVM AI Tool Use Policy. In particular, if you used AI while working on this PR, remember to add a note to the PR description.
The LLVM Code-Review Policy and Practices document contains practical information about the PR process, including how patches are reviewed and accepted, and who can review a PR.

  • Our LLVM Developer Policy describes our expectations for code quality, commit summaries and contains notes on our CI system.
  • Please reply to this message to confirm that you have read these policies, especially the LLVM AI Tool Use Policy, and that any AI tool usage has been noted in the PR description.

    ---

    Frequently asked questions

    How do I add reviewers?

    This PR will be automatically labeled, and the relevant teams will be notified. For some parts of the project, reviewers may also be added automatically.

    You can also add reviewers manually using the Reviewers section on this page. If you cannot use that section, it is probably because you do not have write permissions for the repository. In that case, you can request a review by tagging reviewers in a comment using @ followed by their GitHub username.

    What if there are no comments?

    If you have not received any comments on your PR after a week, you can request a review by pinging the PR with a comment such as “Ping”. The common courtesy ping rate is once a week. Please remember that you are asking for volunteer time from other developers.

    Are any special GitHub settings required to contribute to LLVM?

    We only require contributors to have a public email address associated with their GitHub commits, see this section of LLVM Developer Policy for details.

    ---

    If you have questions, feel free to leave a comment on this PR, or ask on LLVM Discord or LLVM Discourse.

    Thank you,
    The LLVM Community

    llvmorg-github-actions[bot] llvmorg-github-actions[bot] commented on Nov 11, 2026 17:23 UTC
    Bot

    <!--LLVM PR SUMMARY COMMENT-->
    @llvm/pr-subscribers-clang-codegen

    @llvm/pr-subscribers-clang

    Author: Pierre-Clément Tosi (ptosi)

    <details>
    <summary>Changes</summary>

    Add __attribute__((memtag)) ([[clang::memtag]]) to selectively enable hardware memory tagging (currently, aarch64 MTE) on individual global variables. It is implemented as a per-variable switch to leverage the infrastructure introduced for -fsanitize=memtag-globals (including at load time) in a more granular way. As a result, compiled code can use memory tagging only on those globals that require it, while leaving less security-sensitive ones unaffected.

    Reject the attribute on variables which memtag-globals would have skipped such as non-global, non-mutable, or TLS-stored ones. Similarly, diagnose conflicting no_sanitize("memtag").

    Gate the attribute such that __has_attribute(memtag) is false when the target does not support memory tagging. This enables saving the non-MTE overhead (granule alignment &amp; GOT indirection) on targets that would never make use of the feature.

    ---
    Full diff: https://github.com/llvm/llvm-project/pull/241400.diff

    8 Files Affected:

  • (modified) clang/include/clang/Basic/Attr.td (+12)

  • (modified) clang/include/clang/Basic/AttrDocs.td (+12)

  • (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+2)

  • (modified) clang/include/clang/Sema/Sema.h (+1)

  • (modified) clang/lib/CodeGen/SanitizerMetadata.cpp (+9)

  • (modified) clang/lib/Sema/SemaDeclAttr.cpp (+38-2)

  • (modified) clang/test/CodeGen/memtag-globals.cpp (+47-2)

  • (added) clang/test/Sema/attr-memtag.c (+146)
  • ``````

    diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td
    index 24fd853a2384a..3dac924e9146d 100644
    --- a/clang/include/clang/Basic/Attr.td
    +++ b/clang/include/clang/Basic/Attr.td
    @@ -523,6 +523,10 @@ def TargetMustTailAvailable:  TargetSpec {
       let CustomCode = [{ Target.hasMustTail() }];
     }
     
    +def TargetHasMemTag : TargetSpec {
    +  let CustomCode = [{ Target.hasFeature("memtag") }];
    +}
    +
     def TargetELF : TargetSpec {
       let ObjectFormats = ["ELF"];
     }
    @@ -4153,6 +4157,14 @@ def DisableSanitizerInstrumentation : InheritableAttr {
       let SimpleHandler = 1;
     }
     
    +def MemTag : InheritableAttr, TargetSpecificAttr<TargetHasMemTag> {
    +  let Spellings = [Clang<"memtag">];
    +  let Subjects = SubjectList<[NonTLSGlobalVar], ErrorDiag>;
    +  let Documentation = [MemTagDocs];
    +  let IsTypeDependent = 1;
    +}
    +def : MutualExclusions<[MemTag, Section, DisableSanitizerInstrumentation]>;
    +
     def CFICanonicalJumpTable : InheritableAttr {
       let Spellings = [Clang<"cfi_canonical_jump_table">];
       let Subjects = SubjectList<[Function], ErrorDiag>;
    diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td
    index 2300c8456ef16..33c28c21378f0 100644
    --- a/clang/include/clang/Basic/AttrDocs.td
    +++ b/clang/include/clang/Basic/AttrDocs.td
    @@ -4071,6 +4071,18 @@ on the tool may still insert instrumentation to prevent false positive reports.
       }];
     }
     
    +def MemTagDocs : Documentation {
    +  let Category = DocCatVariable;
    +  let Content = [{
    +Use the `memtag` attribute on a non-TLS global variable declaration to
    +selectively enable hardware memory tagging protection for that variable (as if
    +`-fsanitize=memtag-globals` were applied to it). This attribute is only
    +available when targeting an architecture with hardware memory tagging enabled
    +(such as AArch64 with `+memtag`), and its availability can be tested with
    +`__has_attribute(memtag)`.
    +  }];
    +}
    +
     def NoSanitizeAddressDocs : Documentation {
       let Category = DocCatFunction;
       // This function has multiple distinct spellings, and so it requires a custom
    diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
    index 3e56980e22902..68ae59fb9078c 100644
    --- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
    +++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
    @@ -13510,6 +13510,8 @@ def err_memtag_any2arg_pointer : Error<
       "at least one argument of MTE builtin function must be a pointer (%0, %1 invalid)">;
     def err_memtag_arg_must_be_pointer : Error<
       "%0 argument of MTE builtin function must be a pointer (%1 invalid)">;
    +def err_memtag_attr_const_global : Error<
    +  "%0 attribute cannot be applied to a constant global variable">;
     
     def warn_dereference_of_noderef_type : Warning<
       "dereferencing %0; was declared with a 'noderef' type">, InGroup<NoDeref>;
    diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
    index 4341359b0e97c..7a480364c111c 100644
    --- a/clang/include/clang/Sema/Sema.h
    +++ b/clang/include/clang/Sema/Sema.h
    @@ -15915,6 +15915,7 @@ class Sema final : public SemaBase {
     
       void ActOnCleanupAttr(Decl *D, const Attr *A);
       void ActOnInitPriorityAttr(Decl *D, const Attr *A);
    +  void ActOnMemTagAttr(Decl *D, const Attr *A);
     
     private:
       /// The implementation of RequireCompleteType
    diff --git a/clang/lib/CodeGen/SanitizerMetadata.cpp b/clang/lib/CodeGen/SanitizerMetadata.cpp
    index 288f7f6415f44..a8260ce7b8f07 100644
    --- a/clang/lib/CodeGen/SanitizerMetadata.cpp
    +++ b/clang/lib/CodeGen/SanitizerMetadata.cpp
    @@ -96,8 +96,17 @@ void SanitizerMetadata::reportGlobal(llvm::GlobalVariable *GV,
     
     void SanitizerMetadata::reportGlobal(llvm::GlobalVariable *GV, const VarDecl &D,
                                          bool IsDynInit) {
    +  if (D.hasAttr<MemTagAttr>()) {
    +    llvm::GlobalVariable::SanitizerMetadata Meta;
    +    if (GV->hasSanitizerMetadata())
    +      Meta = GV->getSanitizerMetadata();
    +    Meta.Memtag = true;
    +    GV->setSanitizerMetadata(Meta);
    +  }
    +
       if (!isAsanHwasanMemTagOrTysan(CGM.getLangOpts().Sanitize))
         return;
    +
       std::string QualName;
       llvm::raw_string_ostream OS(QualName);
       D.printQualifiedName(OS);
    diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
    index e57f1de9c1100..3932bf751bd21 100644
    --- a/clang/lib/Sema/SemaDeclAttr.cpp
    +++ b/clang/lib/Sema/SemaDeclAttr.cpp
    @@ -7037,8 +7037,29 @@ static void handleNoSanitizeAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
         Sanitizers.push_back(SanitizerName);
       }
     
    -  D->addAttr(::new (S.Context) NoSanitizeAttr(S.Context, AL, Sanitizers.data(),
    -                                              Sanitizers.size()));
    +  auto *NewAttr = ::new (S.Context)
    +      NoSanitizeAttr(S.Context, AL, Sanitizers.data(), Sanitizers.size());
    +  if (NewAttr->getMask() & SanitizerKind::MemtagGlobals) {
    +    if (const auto *MTA = D->getAttr<MemTagAttr>()) {
    +      S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible)
    +          << NewAttr << MTA << false;
    +      S.Diag(MTA->getLocation(), diag::note_conflicting_attribute);
    +      return;
    +    }
    +  }
    +  D->addAttr(NewAttr);
    +}
    +
    +static void handleMemTagAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
    +  for (const auto *NSA : D->specific_attrs<NoSanitizeAttr>()) {
    +    if (NSA->getMask() & SanitizerKind::MemtagGlobals) {
    +      S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible)
    +          << AL << NSA << false;
    +      S.Diag(NSA->getLocation(), diag::note_conflicting_attribute);
    +      return;
    +    }
    +  }
    +  D->addAttr(::new (S.Context) MemTagAttr(S.Context, AL));
     }
     
     static AttributeCommonInfo
    @@ -8352,6 +8373,10 @@ ProcessDeclAttribute(Sema &S, Decl *D, const ParsedAttr &AL,
       case ParsedAttr::AT_NoSanitize:
         handleNoSanitizeAttr(S, D, AL);
         break;
    +  case ParsedAttr::AT_MemTag:
    +    handleMemTagAttr(S, D, AL);
    +    break;
    +
       case ParsedAttr::AT_NoSanitizeAddress:
         handleNoSanitizeAddressAttr(S, D, AL);
         break;
    @@ -9131,3 +9156,14 @@ void Sema::ActOnInitPriorityAttr(Decl *D, const Attr *A) {
         D->dropAttr<InitPriorityAttr>();
       }
     }
    +
    +void Sema::ActOnMemTagAttr(Decl *D, const Attr *A) {
    +  auto *VD = cast<VarDecl>(D);
    +  if (VD->isInvalidDecl() || VD->getType()->isDependentType())
    +    return;
    +  if (VD->getType().isConstantStorage(this->Context, /*ExcludeCtor=*/false,
    +                                      /*ExcludeDtor=*/false)) {
    +    this->Diag(A->getLocation(), diag::err_memtag_attr_const_global) << A;
    +    D->dropAttr<MemTagAttr>();
    +  }
    +}
    diff --git a/clang/test/CodeGen/memtag-globals.cpp b/clang/test/CodeGen/memtag-globals.cpp
    index 407eea1c37cfa..fcba6c4d37a25 100644
    --- a/clang/test/CodeGen/memtag-globals.cpp
    +++ b/clang/test/CodeGen/memtag-globals.cpp
    @@ -1,29 +1,42 @@
    -// RUN: %clang_cc1 -triple aarch64-linux-android34 \
    +// RUN: %clang_cc1 -triple aarch64-linux-android34 -target-feature +mte \
     // RUN:   -include %S/Inputs/sanitizer-extra-source.cpp \
     // RUN:   -fsanitize-ignorelist=%S/Inputs/sanitizer-ignorelist-global.txt \
     // RUN:   -fsanitize=memtag-globals -emit-llvm -o - %s | FileCheck %s
     
    -// RUN: %clang_cc1 -triple aarch64-linux-android34 \
    +// RUN: %clang_cc1 -triple aarch64-linux-android34 -target-feature +mte \
     // RUN:    -include %S/Inputs/sanitizer-extra-source.cpp \
     // RUN:   -fsanitize-ignorelist=%S/Inputs/sanitizer-ignorelist-src.txt \
     // RUN:   -fsanitize=memtag-globals -emit-llvm -o - %s | \
     // RUN:   FileCheck %s --check-prefix=IGNORELIST
     
    +// RUN: %clang_cc1 -triple aarch64-linux-android34 -target-feature +mte \
    +// RUN:   -include %S/Inputs/sanitizer-extra-source.cpp \
    +// RUN:   -emit-llvm -o - %s | FileCheck %s --check-prefix=ATTR
    +
    +// RUN: %clang_cc1 -triple aarch64-linux-android34 \
    +// RUN:   -include %S/Inputs/sanitizer-extra-source.cpp \
    +// RUN:   -emit-llvm -o - %s | FileCheck %s --check-prefix=NOMTE
    +
     int global;
    +int __attribute__((memtag)) explicitly_tagged_global;
     int __attribute__((__section__("my_section"))) section_global;
     int __attribute__((no_sanitize("memtag"))) attributed_global;
     int __attribute__((disable_sanitizer_instrumentation)) disable_instrumentation_global;
     int ignorelisted_global;
     extern int external_global;
    +extern __attribute__((memtag)) int explicitly_tagged_external_global;
     
     void func() {
       static int static_var = 0;
    +  __attribute__((memtag)) static int explicitly_tagged_static_var = 0;
       const char *literal = "Hello, world!";
       external_global = 1;
    +  explicitly_tagged_external_global = 1;
     }
     
     // CHECK: @{{.*}}extra_global{{.*}} ={{.*}} sanitize_memtag
     // CHECK: @{{.*}}global{{.*}} ={{.*}} sanitize_memtag
    +// CHECK: @{{.*}}explicitly_tagged_global{{.*}} ={{.*}} sanitize_memtag
     
     // This DOES NOT mean we are instrumenting the section global,
     // but we are ignoring it in AsmPrinter rather than in clang.
    @@ -36,13 +49,17 @@ void func() {
     // CHECK-NOT: sanitize_memtag
     
     // CHECK: @{{.*}}static_var{{.*}} ={{.*}} sanitize_memtag
    +// CHECK: @{{.*}}explicitly_tagged_static_var{{.*}} ={{.*}} sanitize_memtag
     // CHECK: @{{.*}} = {{.*}} c"Hello, world!\00"{{.*}} sanitize_memtag
     // CHECK: @{{.*}}external_global{{.*}} ={{.*}} sanitize_memtag
    +// CHECK: @{{.*}}explicitly_tagged_external_global{{.*}} ={{.*}} sanitize_memtag
     
     // IGNORELIST: @{{.*}}extra_global{{.*}} ={{.*}} sanitize_memtag
     
     // IGNORELIST:     @{{.*}}global{{.*}} =
     // IGNORELIST-NOT: sanitize_memtag
    +// IGNORELIST:     @{{.*}}explicitly_tagged_global{{.*}} =
    +// IGNORELIST-NOT: sanitize_memtag
     // IGNORELIST:     @{{.*}}attributed_global{{.*}} =
     // IGNORELIST-NOT: sanitize_memtag
     // IGNORELIST:     @{{.*}}disable_instrumentation_global{{.*}} =
    @@ -51,7 +68,35 @@ void func() {
     // IGNORELIST-NOT: sanitize_memtag
     // IGNORELIST:     @{{.*}}static_var{{.*}} =
     // IGNORELIST-NOT: sanitize_memtag
    +// IGNORELIST:     @{{.*}}explicitly_tagged_static_var{{.*}} =
    +// IGNORELIST-NOT: sanitize_memtag
     // IGNORELIST:     @{{.*}} = {{.*}} c"Hello, world!\00"{{.*}}
     // IGNORELIST-NOT: sanitize_memtag
     // IGNORELIST:     @{{.*}}external_global{{.*}} =
     // IGNORELIST-NOT: sanitize_memtag
    +// IGNORELIST:     @{{.*}}explicitly_tagged_external_global{{.*}} =
    +// IGNORELIST-NOT: sanitize_memtag
    +
    +// ATTR:     @{{.*}}extra_global{{.*}} =
    +// ATTR-NOT: sanitize_memtag
    +// ATTR:     @{{.*}}global{{.*}} =
    +// ATTR-NOT: sanitize_memtag
    +// ATTR:     @{{.*}}explicitly_tagged_global{{.*}} ={{.*}} sanitize_memtag
    +// ATTR:     @{{.*}}section_global{{.*}} =
    +// ATTR-NOT: sanitize_memtag
    +// ATTR:     @{{.*}}attributed_global{{.*}} =
    +// ATTR-NOT: sanitize_memtag
    +// ATTR:     @{{.*}}disable_instrumentation_global{{.*}} =
    +// ATTR-NOT: sanitize_memtag
    +// ATTR:     @{{.*}}ignorelisted_global{{.*}} =
    +// ATTR-NOT: sanitize_memtag
    +// ATTR:     @{{.*}}static_var{{.*}} =
    +// ATTR-NOT: sanitize_memtag
    +// ATTR:     @{{.*}}explicitly_tagged_static_var{{.*}} ={{.*}} sanitize_memtag
    +// ATTR:     @{{.*}} = {{.*}} c"Hello, world!\00"{{.*}}
    +// ATTR-NOT: sanitize_memtag
    +// ATTR:     @{{.*}}external_global{{.*}} =
    +// ATTR-NOT: sanitize_memtag
    +// ATTR:     @{{.*}}explicitly_tagged_external_global{{.*}} ={{.*}} sanitize_memtag
    +
    +// NOMTE-NOT: sanitize_memtag
    diff --git a/clang/test/Sema/attr-memtag.c b/clang/test/Sema/attr-memtag.c
    new file mode 100644
    index 0000000000000..3ea92e1afa183
    --- /dev/null
    +++ b/clang/test/Sema/attr-memtag.c
    @@ -0,0 +1,146 @@
    +// RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +mte -fsyntax-only -verify %s
    +// RUN: %clang_cc1 -triple aarch64-linux-gnu -fsyntax-only -verify=expected-nomte %s
    +// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify=expected-nomte %s
    +// RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +mte -x c++ -std=c++17 -fsyntax-only -verify %s
    +// RUN: %clang_cc1 -triple aarch64-linux-gnu -x c++ -std=c++17 -fsyntax-only -verify=expected-nomte %s
    +
    +#if defined(__aarch64__) && defined(__ARM_FEATURE_MEMORY_TAGGING)
    +#if !__has_attribute(memtag)
    +#error "__has_attribute(memtag) should be 1 when MTE is enabled"
    +#endif
    +#else
    +#if __has_attribute(memtag)
    +#error "__has_attribute(memtag) should be 0 when MTE is disabled"
    +#endif
    +#endif
    +
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag)) int valid_global;
    +
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag)) static int valid_static_global = 1;
    +
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +extern __attribute__((memtag)) int valid_extern_global;
    +
    +// Redeclarations inherit the attribute
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +extern __attribute__((memtag)) int redecl_global;
    +int redecl_global;
    +
    +
    +// Argument count check
    +// expected-error@+2 {{'memtag' attribute takes no arguments}}
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag(1))) int bad_args_global;
    +
    +// Non-global / TLS subjects
    +// expected-error@+2 {{'memtag' attribute only applies to non-TLS global variables}}
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__thread __attribute__((memtag)) int tls_global;
    +
    +// expected-error@+2 {{'memtag' attribute only applies to non-TLS global variables}}
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag)) void func_with_memtag(void) {}
    +
    +struct S {
    +  // expected-error@+2 {{'memtag' attribute only applies to non-TLS global variables}}
    +  // expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +  __attribute__((memtag)) int field;
    +};
    +
    +void local_vars(__attribute__((memtag)) int param) { // expected-error {{'memtag' attribute only applies to non-TLS global variables}} \
    +                                                     // expected-nomte-warning {{unknown attribute 'memtag' ignored}}
    +  // expected-error@+2 {{'memtag' attribute only applies to non-TLS global variables}}
    +  // expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +  __attribute__((memtag)) int local_var = 0;
    +
    +  // Function-local static has global storage, so it is allowed.
    +  // expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +  __attribute__((memtag)) static int static_local_var = 0;
    +}
    +
    +// Constant globals cannot be MTE-tagged
    +// expected-error@+2 {{'memtag' attribute cannot be applied to a constant global variable}}
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag)) const int const_global = 42;
    +
    +// expected-error@+2 {{'memtag' attribute cannot be applied to a constant global variable}}
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag)) const int const_array[4] = {1, 2, 3, 4};
    +
    +// Pointer to const is fine (the pointer itself is mutable)
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag)) const char *mutable_ptr_to_const = "hello";
    +
    +// Const pointer is not fine (the pointer variable itself is const)
    +// expected-error@+2 {{'memtag' attribute cannot be applied to a constant global variable}}
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag)) char *const const_ptr = 0;
    +
    +// Mutual exclusions with section, disable_sanitizer_instrumentation, and no_sanitize("memtag")
    +// expected-error@+3 {{'section' and 'memtag' attributes are not compatible}}
    +// expected-note@+2 {{conflicting attribute is here}}
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag, section("my_sec"))) int sec_global1;
    +
    +// expected-error@+3 {{'memtag' and 'section' attributes are not compatible}}
    +// expected-note@+2 {{conflicting attribute is here}}
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((section("my_sec"), memtag)) int sec_global2;
    +
    +// expected-error@+3 {{'disable_sanitizer_instrumentation' and 'memtag' attributes are not compatible}}
    +// expected-note@+2 {{conflicting attribute is here}}
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag, disable_sanitizer_instrumentation)) int dsi_global1;
    +
    +
    +// expected-error@+3 {{'no_sanitize' and 'memtag' attributes are not compatible}}
    +// expected-note@+2 {{conflicting attribute is here}}
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag, no_sanitize("memtag"))) int nosan_global1;
    +
    +// expected-error@+3 {{'memtag' and 'no_sanitize' attributes are not compatible}}
    +// expected-note@+2 {{conflicting attribute is here}}
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((no_sanitize("memtag"), memtag)) int nosan_global2;
    +
    +// no_sanitize for other sanitizers is allowed alongside memtag
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag, no_sanitize("address"))) int nosan_asan_global;
    +
    +#ifdef __cplusplus
    +#if defined(__aarch64__) && defined(__ARM_FEATURE_MEMORY_TAGGING)
    +#if !__has_cpp_attribute(clang::memtag)
    +#error "__has_cpp_attribute(clang::memtag) should be non-zero when MTE is enabled"
    +#endif
    +#else
    +#if __has_cpp_attribute(clang::memtag)
    +#error "__has_cpp_attribute(clang::memtag) should be 0 when MTE is disabled"
    +#endif
    +#endif
    +
    +// C++11 [[clang::memtag]] spelling and dependent type check
    +// expected-nomte-warning@+1 {{unknown attribute 'clang::memtag' ignored}}
    +[[clang::memtag]] int cxx11_tagged_global;
    +
    +// Deduced auto const global
    +// expected-error@+2 {{'clang::memtag' attribute cannot be applied to a constant global variable}}
    +// expected-nomte-warning@+1 {{unknown attribute 'clang::memtag' ignored}}
    +[[clang::memtag]] const auto deduced_const_global = 10;
    +
    +template <typename T>
    +struct Holder {
    +  // expected-error@+2 {{'clang::memtag' attribute cannot be applied to a constant global variable}}
    +  // expected-nomte-warning@+1 {{unknown attribute 'clang::memtag' ignored}}
    +  [[clang::memtag]] static T value;
    +};
    +
    +template <typename T>
    +T Holder<T>::value = 0;
    +
    +int use_templates() {
    +  return Holder<int>::value +
    +         Holder<const int>::value; // expected-note {{in instantiation of static data member 'Holder<const int>::value' requested here}}
    +}
    +#endif
    
    
    ``````

    </details>

    ptosi ptosi commented on Nov 11, 2026 17:25 UTC
    Author

    In that case, you can request a review by tagging reviewers

    @pcc and @fmayer, would you mind taking a look? Thanks!

    daniel-petrovic daniel-petrovic commented on code on Nov 11, 2026 20:09 UTC
    Code Review
    clang/lib/Sema/SemaDeclAttr.cpp:1
    @@ -9131,3 +9156,14 @@ void Sema::ActOnInitPriorityAttr(Decl *D, const Attr *A) {
         D->dropAttr<InitPriorityAttr>();
       }
     }
    +
    +void Sema::ActOnMemTagAttr(Decl *D, const Attr *A) {

    Is this guaranteed to run again on template instantiation or is the attribute simply forwarded from original template declaration ?

    daniel-petrovic daniel-petrovic commented on code on Nov 11, 2026 20:19 UTC
    Code Review
    clang/test/Sema/attr-memtag.c:1
    @@ -0,0 +1,146 @@
    +// RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +mte -fsyntax-only -verify %s
    +// RUN: %clang_cc1 -triple aarch64-linux-gnu -fsyntax-only -verify=expected-nomte %s
    +// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify=expected-nomte %s
    +// RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +mte -x c++ -std=c++17 -fsyntax-only -verify %s
    +// RUN: %clang_cc1 -triple aarch64-linux-gnu -x c++ -std=c++17 -fsyntax-only -verify=expected-nomte %s
    +
    +#if defined(__aarch64__) && defined(__ARM_FEATURE_MEMORY_TAGGING)
    +#if !__has_attribute(memtag)
    +#error "__has_attribute(memtag) should be 1 when MTE is enabled"
    +#endif
    +#else
    +#if __has_attribute(memtag)
    +#error "__has_attribute(memtag) should be 0 when MTE is disabled"
    +#endif
    +#endif
    +
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag)) int valid_global;
    +
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag)) static int valid_static_global = 1;
    +
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +extern __attribute__((memtag)) int valid_extern_global;
    +
    +// Redeclarations inherit the attribute
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +extern __attribute__((memtag)) int redecl_global;
    +int redecl_global;
    +
    +
    +// Argument count check
    +// expected-error@+2 {{'memtag' attribute takes no arguments}}
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag(1))) int bad_args_global;
    +
    +// Non-global / TLS subjects
    +// expected-error@+2 {{'memtag' attribute only applies to non-TLS global variables}}
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__thread __attribute__((memtag)) int tls_global;
    +
    +// expected-error@+2 {{'memtag' attribute only applies to non-TLS global variables}}
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag)) void func_with_memtag(void) {}
    +
    +struct S {
    +  // expected-error@+2 {{'memtag' attribute only applies to non-TLS global variables}}
    +  // expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +  __attribute__((memtag)) int field;
    +};
    +
    +void local_vars(__attribute__((memtag)) int param) { // expected-error {{'memtag' attribute only applies to non-TLS global variables}} \
    +                                                     // expected-nomte-warning {{unknown attribute 'memtag' ignored}}
    +  // expected-error@+2 {{'memtag' attribute only applies to non-TLS global variables}}
    +  // expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +  __attribute__((memtag)) int local_var = 0;
    +
    +  // Function-local static has global storage, so it is allowed.
    +  // expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +  __attribute__((memtag)) static int static_local_var = 0;
    +}
    +
    +// Constant globals cannot be MTE-tagged
    +// expected-error@+2 {{'memtag' attribute cannot be applied to a constant global variable}}
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag)) const int const_global = 42;
    +
    +// expected-error@+2 {{'memtag' attribute cannot be applied to a constant global variable}}
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag)) const int const_array[4] = {1, 2, 3, 4};
    +
    +// Pointer to const is fine (the pointer itself is mutable)
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag)) const char *mutable_ptr_to_const = "hello";
    +
    +// Const pointer is not fine (the pointer variable itself is const)
    +// expected-error@+2 {{'memtag' attribute cannot be applied to a constant global variable}}
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag)) char *const const_ptr = 0;
    +
    +// Mutual exclusions with section, disable_sanitizer_instrumentation, and no_sanitize("memtag")
    +// expected-error@+3 {{'section' and 'memtag' attributes are not compatible}}
    +// expected-note@+2 {{conflicting attribute is here}}
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag, section("my_sec"))) int sec_global1;
    +
    +// expected-error@+3 {{'memtag' and 'section' attributes are not compatible}}
    +// expected-note@+2 {{conflicting attribute is here}}
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((section("my_sec"), memtag)) int sec_global2;
    +
    +// expected-error@+3 {{'disable_sanitizer_instrumentation' and 'memtag' attributes are not compatible}}
    +// expected-note@+2 {{conflicting attribute is here}}
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag, disable_sanitizer_instrumentation)) int dsi_global1;
    +
    +
    +// expected-error@+3 {{'no_sanitize' and 'memtag' attributes are not compatible}}
    +// expected-note@+2 {{conflicting attribute is here}}
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag, no_sanitize("memtag"))) int nosan_global1;
    +
    +// expected-error@+3 {{'memtag' and 'no_sanitize' attributes are not compatible}}
    +// expected-note@+2 {{conflicting attribute is here}}
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((no_sanitize("memtag"), memtag)) int nosan_global2;
    +
    +// no_sanitize for other sanitizers is allowed alongside memtag
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag, no_sanitize("address"))) int nosan_asan_global;
    +
    +#ifdef __cplusplus
    +#if defined(__aarch64__) && defined(__ARM_FEATURE_MEMORY_TAGGING)
    +#if !__has_cpp_attribute(clang::memtag)
    +#error "__has_cpp_attribute(clang::memtag) should be non-zero when MTE is enabled"
    +#endif
    +#else
    +#if __has_cpp_attribute(clang::memtag)
    +#error "__has_cpp_attribute(clang::memtag) should be 0 when MTE is disabled"
    +#endif
    +#endif
    +
    +// C++11 [[clang::memtag]] spelling and dependent type check
    +// expected-nomte-warning@+1 {{unknown attribute 'clang::memtag' ignored}}
    +[[clang::memtag]] int cxx11_tagged_global;
    +
    +// Deduced auto const global
    +// expected-error@+2 {{'clang::memtag' attribute cannot be applied to a constant global variable}}
    +// expected-nomte-warning@+1 {{unknown attribute 'clang::memtag' ignored}}
    +[[clang::memtag]] const auto deduced_const_global = 10;
    +
    +template <typename T>
    +struct Holder {
    +  // expected-error@+2 {{'clang::memtag' attribute cannot be applied to a constant global variable}}
    +  // expected-nomte-warning@+1 {{unknown attribute 'clang::memtag' ignored}}
    +  [[clang::memtag]] static T value;
    +};
    +
    +template <typename T>
    +T Holder<T>::value = 0;
    +
    +int use_templates() {
    +  return Holder<int>::value +

    Maybe adding multiple instantiations (e.g., Holder<double>, ... etc.) and dependent redeclarations (e.g., template members with out-of-line definitions carrying the attribute, an explicit specialization, variable template) would be meaningful.

    daniel-petrovic daniel-petrovic commented on code on Nov 11, 2026 20:31 UTC
    Code Review
    clang/test/Sema/attr-memtag.c:1
    @@ -0,0 +1,146 @@
    +// RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +mte -fsyntax-only -verify %s
    +// RUN: %clang_cc1 -triple aarch64-linux-gnu -fsyntax-only -verify=expected-nomte %s
    +// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify=expected-nomte %s
    +// RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +mte -x c++ -std=c++17 -fsyntax-only -verify %s
    +// RUN: %clang_cc1 -triple aarch64-linux-gnu -x c++ -std=c++17 -fsyntax-only -verify=expected-nomte %s
    +
    +#if defined(__aarch64__) && defined(__ARM_FEATURE_MEMORY_TAGGING)
    +#if !__has_attribute(memtag)
    +#error "__has_attribute(memtag) should be 1 when MTE is enabled"
    +#endif
    +#else
    +#if __has_attribute(memtag)
    +#error "__has_attribute(memtag) should be 0 when MTE is disabled"
    +#endif
    +#endif
    +
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag)) int valid_global;
    +
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag)) static int valid_static_global = 1;
    +
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +extern __attribute__((memtag)) int valid_extern_global;
    +
    +// Redeclarations inherit the attribute
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +extern __attribute__((memtag)) int redecl_global;
    +int redecl_global;
    +
    +
    +// Argument count check
    +// expected-error@+2 {{'memtag' attribute takes no arguments}}
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag(1))) int bad_args_global;
    +
    +// Non-global / TLS subjects
    +// expected-error@+2 {{'memtag' attribute only applies to non-TLS global variables}}
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__thread __attribute__((memtag)) int tls_global;
    +
    +// expected-error@+2 {{'memtag' attribute only applies to non-TLS global variables}}
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag)) void func_with_memtag(void) {}
    +
    +struct S {
    +  // expected-error@+2 {{'memtag' attribute only applies to non-TLS global variables}}
    +  // expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +  __attribute__((memtag)) int field;
    +};
    +
    +void local_vars(__attribute__((memtag)) int param) { // expected-error {{'memtag' attribute only applies to non-TLS global variables}} \
    +                                                     // expected-nomte-warning {{unknown attribute 'memtag' ignored}}
    +  // expected-error@+2 {{'memtag' attribute only applies to non-TLS global variables}}
    +  // expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +  __attribute__((memtag)) int local_var = 0;
    +
    +  // Function-local static has global storage, so it is allowed.
    +  // expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +  __attribute__((memtag)) static int static_local_var = 0;
    +}
    +
    +// Constant globals cannot be MTE-tagged
    +// expected-error@+2 {{'memtag' attribute cannot be applied to a constant global variable}}
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag)) const int const_global = 42;
    +
    +// expected-error@+2 {{'memtag' attribute cannot be applied to a constant global variable}}
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag)) const int const_array[4] = {1, 2, 3, 4};
    +
    +// Pointer to const is fine (the pointer itself is mutable)
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag)) const char *mutable_ptr_to_const = "hello";
    +
    +// Const pointer is not fine (the pointer variable itself is const)
    +// expected-error@+2 {{'memtag' attribute cannot be applied to a constant global variable}}
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag)) char *const const_ptr = 0;
    +
    +// Mutual exclusions with section, disable_sanitizer_instrumentation, and no_sanitize("memtag")
    +// expected-error@+3 {{'section' and 'memtag' attributes are not compatible}}
    +// expected-note@+2 {{conflicting attribute is here}}
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag, section("my_sec"))) int sec_global1;
    +
    +// expected-error@+3 {{'memtag' and 'section' attributes are not compatible}}
    +// expected-note@+2 {{conflicting attribute is here}}
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((section("my_sec"), memtag)) int sec_global2;
    +
    +// expected-error@+3 {{'disable_sanitizer_instrumentation' and 'memtag' attributes are not compatible}}
    +// expected-note@+2 {{conflicting attribute is here}}
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag, disable_sanitizer_instrumentation)) int dsi_global1;
    +
    +
    +// expected-error@+3 {{'no_sanitize' and 'memtag' attributes are not compatible}}
    +// expected-note@+2 {{conflicting attribute is here}}
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag, no_sanitize("memtag"))) int nosan_global1;
    +
    +// expected-error@+3 {{'memtag' and 'no_sanitize' attributes are not compatible}}
    +// expected-note@+2 {{conflicting attribute is here}}
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((no_sanitize("memtag"), memtag)) int nosan_global2;
    +
    +// no_sanitize for other sanitizers is allowed alongside memtag
    +// expected-nomte-warning@+1 {{unknown attribute 'memtag' ignored}}
    +__attribute__((memtag, no_sanitize("address"))) int nosan_asan_global;
    +
    +#ifdef __cplusplus
    +#if defined(__aarch64__) && defined(__ARM_FEATURE_MEMORY_TAGGING)
    +#if !__has_cpp_attribute(clang::memtag)
    +#error "__has_cpp_attribute(clang::memtag) should be non-zero when MTE is enabled"
    +#endif
    +#else
    +#if __has_cpp_attribute(clang::memtag)
    +#error "__has_cpp_attribute(clang::memtag) should be 0 when MTE is disabled"
    +#endif
    +#endif
    +
    +// C++11 [[clang::memtag]] spelling and dependent type check
    +// expected-nomte-warning@+1 {{unknown attribute 'clang::memtag' ignored}}
    +[[clang::memtag]] int cxx11_tagged_global;
    +
    +// Deduced auto const global
    +// expected-error@+2 {{'clang::memtag' attribute cannot be applied to a constant global variable}}
    +// expected-nomte-warning@+1 {{unknown attribute 'clang::memtag' ignored}}
    +[[clang::memtag]] const auto deduced_const_global = 10;
    +
    +template <typename T>
    +struct Holder {
    +  // expected-error@+2 {{'clang::memtag' attribute cannot be applied to a constant global variable}}

    Wondering if hard error for const in templates is maybe too strict .. this makes generic code unusable for const T and constexpr-ish cases. Alternative would be warning + ignoring the attribute. Maybe it's worth considering...

    daniel-petrovic daniel-petrovic commented on Nov 11, 2026 20:34 UTC
    Contributor

    IMO entry in the clang/docs/ReleaseNotes is missing. Maybe a link to RFC if existing would also be helpful.

    daniel-petrovic daniel-petrovic commented on code on Nov 11, 2026 20:39 UTC
    Code Review
    clang/include/clang/Basic/AttrDocs.td:1
    @@ -4071,6 +4071,18 @@ on the tool may still insert instrumentation to prevent false positive reports.
       }];
     }
     
    +def MemTagDocs : Documentation {
    +  let Category = DocCatVariable;
    +  let Content = [{
    +Use the `memtag` attribute on a non-TLS global variable declaration to

    IMO the incompatibilities should be mentioned here also, e.g. (section, disable_sanitizer_instrumentation, no_sanitize("memtag")), the const restriction, or the ignorelist interaction. These are the things users will hit.

    daniel-petrovic daniel-petrovic commented on code on Nov 11, 2026 20:44 UTC
    Code Review
    clang/lib/CodeGen/SanitizerMetadata.cpp:1
    @@ -96,8 +96,17 @@ void SanitizerMetadata::reportGlobal(llvm::GlobalVariable *GV,
     
     void SanitizerMetadata::reportGlobal(llvm::GlobalVariable *GV, const VarDecl &D,
                                          bool IsDynInit) {
    +  if (D.hasAttr<MemTagAttr>()) {

    Maybe a comment saying that attribute check is done intentionally before the sanitizer-enabled-check would be helpful for future readers. Maybe it should also be verified that this path is reached by every caller even without sanitizer enabled.

    fmayer fmayer commented on code on Nov 11, 2026 21:31 UTC
    Code Review
    clang/lib/CodeGen/SanitizerMetadata.cpp:1
    @@ -96,8 +96,17 @@ void SanitizerMetadata::reportGlobal(llvm::GlobalVariable *GV,
     
     void SanitizerMetadata::reportGlobal(llvm::GlobalVariable *GV, const VarDecl &D,
                                          bool IsDynInit) {
    +  if (D.hasAttr<MemTagAttr>()) {
    +    llvm::GlobalVariable::SanitizerMetadata Meta;
    +    if (GV->hasSanitizerMetadata())
    +      Meta = GV->getSanitizerMetadata();
    +    Meta.Memtag = true;
    +    GV->setSanitizerMetadata(Meta);
    +  }
    +
       if (!isAsanHwasanMemTagOrTysan(CGM.getLangOpts().Sanitize))
         return;
    +

    nit: stray change

    Assignees
    ptosi ptosi
    Labels
    risk: low confidence: 90.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 46.8% (MEDIUM) · Higher = larger blast radius
    46.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 90.7% · Lower = rushed or shallow review
    90.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 4.4% · Safe to merge
    4.4%