================
@@ -1476,6 +1476,127 @@ static bool shouldExtendLifetime(const ASTContext
&Context,
return true;
}
+/// Adds metadata for restrict-qualified pointers at any nesting level.
+///
+/// This function processes pointer types recursively to generate metadata
+/// for restrict-qualified pointers. The metadata encodes which pointer levels
+/// are restrict qualified and assigns unique identifiers to each restrict
+/// qualification level.
+///
+/// For example, consider the type `int * restrict * restrict` in foo():
+/// - First level: pointer to restrict pointer (gets unique code 1)
+/// - Second level: restrict pointer to int (gets another unique code 1)
+///
+/// The metadata structure is attached to the alloca instruction and consists
+/// of:
+/// 1. Full variable name (function name + scope encoding)
+/// 2. List of restrict codes for each pointer level:
+/// - Non-zero: unique identifier for restrict-qualified pointer
+/// - Zero: non-restrict qualified pointer at that level
+///
+/// For example, consider function `foo` with variable declarations:
+/// void foo() {
+/// int * restrict p1; // Single-level restrict pointer
+/// int * restrict *p2; // restrict at first level, non-restrict at
+/// second int * restrict * restrict p3; // restrict at both levels
+/// }
+///
+/// Generated metadata would be:
+/// p1: !{!"foo_1", !{1}} // One restrict level, code 1
----------------
erichkeane wrote:
This encoding seems pretty awkward. I'm not sure I get it quite yet.
I DO find myself wondering if instead we should have each individual layer have
its 'own' metadata line, then just associate the alloca with the top level.
THEN when you get it dereferenced a level, its as easy as just pointing to the
next level.
https://github.com/llvm/llvm-project/pull/173394
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits