<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rust/compiler/rustc_codegen_llvm/src/builder.rs, branch try-perf</title>
<subtitle>https://github.com/rust-lang/rust
</subtitle>
<id>http://git.dreamy.place/mirrors/rust/atom?h=try-perf</id>
<link rel='self' href='http://git.dreamy.place/mirrors/rust/atom?h=try-perf'/>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/'/>
<updated>2025-10-02T08:04:23+00:00</updated>
<entry>
<title>Extract helper method `set_metadata_node`</title>
<updated>2025-10-02T08:04:23+00:00</updated>
<author>
<name>Zalathar</name>
<email>Zalathar@users.noreply.github.com</email>
</author>
<published>2025-10-02T06:29:18+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=ecb831dcf4c28d3b66c9bce7aa4c3a8eb221fa5e'/>
<id>urn:sha1:ecb831dcf4c28d3b66c9bce7aa4c3a8eb221fa5e</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Rollup merge of #144197 - KMJ-007:type-tree, r=ZuseZ4</title>
<updated>2025-09-28T16:13:11+00:00</updated>
<author>
<name>Matthias Krüger</name>
<email>476013+matthiaskrgr@users.noreply.github.com</email>
</author>
<published>2025-09-28T16:13:11+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=c29fb2e57ed0578c9051cc9314b0225f847de710'/>
<id>urn:sha1:c29fb2e57ed0578c9051cc9314b0225f847de710</id>
<content type='text'>
TypeTree support in autodiff

# TypeTrees for Autodiff

## What are TypeTrees?
Memory layout descriptors for Enzyme. Tell Enzyme exactly how types are structured in memory so it can compute derivatives efficiently.

## Structure
```rust
TypeTree(Vec&lt;Type&gt;)

Type {
    offset: isize,  // byte offset (-1 = everywhere)
    size: usize,    // size in bytes
    kind: Kind,     // Float, Integer, Pointer, etc.
    child: TypeTree // nested structure
}
```

## Example: `fn compute(x: &amp;f32, data: &amp;[f32]) -&gt; f32`

**Input 0: `x: &amp;f32`**
```rust
TypeTree(vec![Type {
    offset: -1, size: 8, kind: Pointer,
    child: TypeTree(vec![Type {
        offset: -1, size: 4, kind: Float,
        child: TypeTree::new()
    }])
}])
```

**Input 1: `data: &amp;[f32]`**
```rust
TypeTree(vec![Type {
    offset: -1, size: 8, kind: Pointer,
    child: TypeTree(vec![Type {
        offset: -1, size: 4, kind: Float,  // -1 = all elements
        child: TypeTree::new()
    }])
}])
```

**Output: `f32`**
```rust
TypeTree(vec![Type {
    offset: -1, size: 4, kind: Float,
    child: TypeTree::new()
}])
```

## Why Needed?
- Enzyme can't deduce complex type layouts from LLVM IR
- Prevents slow memory pattern analysis
- Enables correct derivative computation for nested structures
- Tells Enzyme which bytes are differentiable vs metadata

## What Enzyme Does With This Information:

Without TypeTrees (current state):
```llvm
; Enzyme sees generic LLVM IR:
define float ``@distance(ptr*`` %p1, ptr* %p2) {
; Has to guess what these pointers point to
; Slow analysis of all memory operations
; May miss optimization opportunities
}
```

With TypeTrees (our implementation):
```llvm
define "enzyme_type"="{[]:Float@float}" float ``@distance(``
    ptr "enzyme_type"="{[]:Pointer}" %p1,
    ptr "enzyme_type"="{[]:Pointer}" %p2
) {
; Enzyme knows exact type layout
; Can generate efficient derivative code directly
}
```

# TypeTrees - Offset and -1 Explained

## Type Structure

```rust
Type {
    offset: isize, // WHERE this type starts
    size: usize,   // HOW BIG this type is
    kind: Kind,    // WHAT KIND of data (Float, Int, Pointer)
    child: TypeTree // WHAT'S INSIDE (for pointers/containers)
}
```

## Offset Values

### Regular Offset (0, 4, 8, etc.)
**Specific byte position within a structure**

```rust
struct Point {
    x: f32, // offset 0, size 4
    y: f32, // offset 4, size 4
    id: i32, // offset 8, size 4
}
```

TypeTree for `&amp;Point` (internal representation):
```rust
TypeTree(vec![
    Type { offset: 0, size: 4, kind: Float },   // x at byte 0
    Type { offset: 4, size: 4, kind: Float },   // y at byte 4
    Type { offset: 8, size: 4, kind: Integer }  // id at byte 8
])
```

Generates LLVM:
```llvm
"enzyme_type"="{[]:Float@float}"
```

### Offset -1 (Special: "Everywhere")
**Means "this pattern repeats for ALL elements"**

#### Example 1: Array `[f32; 100]`
```rust
TypeTree(vec![Type {
    offset: -1, // ALL positions
    size: 4,    // each f32 is 4 bytes
    kind: Float, // every element is float
}])
```

Instead of listing 100 separate Types with offsets `0,4,8,12...396`

#### Example 2: Slice `&amp;[i32]`
```rust
// Pointer to slice data
TypeTree(vec![Type {
    offset: -1, size: 8, kind: Pointer,
    child: TypeTree(vec![Type {
        offset: -1, // ALL slice elements
        size: 4,    // each i32 is 4 bytes
        kind: Integer
    }])
}])
```

#### Example 3: Mixed Structure
```rust
struct Container {
    header: i64,        // offset 0
    data: [f32; 1000],  // offset 8, but elements use -1
}
```

```rust
TypeTree(vec![
    Type { offset: 0, size: 8, kind: Integer }, // header
    Type { offset: 8, size: 4000, kind: Pointer,
        child: TypeTree(vec![Type {
            offset: -1, size: 4, kind: Float // ALL array elements
        }])
    }
])
```
</content>
</entry>
<entry>
<title>Use standard attribute logic for allocator shim</title>
<updated>2025-09-25T08:04:40+00:00</updated>
<author>
<name>Nikita Popov</name>
<email>npopov@redhat.com</email>
</author>
<published>2025-09-19T12:53:16+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=d226e7aa93425ba2090f423642341a99ab047838'/>
<id>urn:sha1:d226e7aa93425ba2090f423642341a99ab047838</id>
<content type='text'>
Use llfn_attrs_from_instance() to generate the attributes for the
allocator shim. This ensures that we generate all the usual
attributes (and don't get to find out one-by-one that a certain
attribute is important for a certain target). Additionally this
will enable emitting the allocator-specific attributes (not
included here).

This change is quite awkward because the allocator shim uses
SimpleCx, while llfn_attrs_from_instance uses CodegenCx. I've
switched it to use SimpleCx plus tcx/sess arguments where necessary.
If there's a simpler way to do this, I'd love to know about it...
</content>
</entry>
<entry>
<title>added typetree support for memcpy</title>
<updated>2025-09-19T04:02:20+00:00</updated>
<author>
<name>Karan Janthe</name>
<email>karanjanthe@gmail.com</email>
</author>
<published>2025-08-23T23:10:48+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=664e83b3e76b51fb5192e74a64eef3bc5bbd4e32'/>
<id>urn:sha1:664e83b3e76b51fb5192e74a64eef3bc5bbd4e32</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Update the minimum external LLVM to 20</title>
<updated>2025-09-16T18:49:20+00:00</updated>
<author>
<name>Josh Stone</name>
<email>jistone@redhat.com</email>
</author>
<published>2025-08-07T21:29:00+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=580b4891aa23c0625539bf5ee55270f27af09072'/>
<id>urn:sha1:580b4891aa23c0625539bf5ee55270f27af09072</id>
<content type='text'>
</content>
</entry>
<entry>
<title>inline at the callsite &amp; warn when target features mismatch</title>
<updated>2025-08-27T13:45:01+00:00</updated>
<author>
<name>James Barford-Evans</name>
<email>james.barford-evans@arm.com</email>
</author>
<published>2025-08-21T13:32:10+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=bcfc9b5073a92bbb4b1e4db2eab535357d8973ad'/>
<id>urn:sha1:bcfc9b5073a92bbb4b1e4db2eab535357d8973ad</id>
<content type='text'>
Co-authored-by: Jamie Cunliffe &lt;Jamie.Cunliffe@arm.com&gt;
</content>
</entry>
<entry>
<title>Rename `llvm::Bool` aliases to standard const case</title>
<updated>2025-08-24T13:09:54+00:00</updated>
<author>
<name>Zalathar</name>
<email>Zalathar@users.noreply.github.com</email>
</author>
<published>2025-08-24T10:49:32+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=b4e97e5d866dd43c110d337affc419d5ac482765'/>
<id>urn:sha1:b4e97e5d866dd43c110d337affc419d5ac482765</id>
<content type='text'>
This avoids the need for `#![allow(non_upper_case_globals)]`.
</content>
</entry>
<entry>
<title>Replace the `llvm::Bool` typedef with a proper newtype</title>
<updated>2025-08-24T13:09:54+00:00</updated>
<author>
<name>Zalathar</name>
<email>Zalathar@users.noreply.github.com</email>
</author>
<published>2025-08-24T05:05:26+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=455a67bd4f38b10e613fc6e2103598db10ad57fe'/>
<id>urn:sha1:455a67bd4f38b10e613fc6e2103598db10ad57fe</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Rollup merge of #145420 - Zalathar:llvm-c, r=WaffleLapkin</title>
<updated>2025-08-18T05:31:12+00:00</updated>
<author>
<name>Stuart Cook</name>
<email>Zalathar@users.noreply.github.com</email>
</author>
<published>2025-08-18T05:31:12+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=aa2dcbe583037bdd13e0f1f5bcf5933d589481a8'/>
<id>urn:sha1:aa2dcbe583037bdd13e0f1f5bcf5933d589481a8</id>
<content type='text'>
cg_llvm: Use LLVM-C bindings for `LLVMSetTailCallKind`, `LLVMGetTypeKind`

This PR replaces two existing `LLVMRust` bindings with equivalent calls to the LLVM-C API.

For `LLVMGetTypeKind`, we avoid the UB hazard by declaring the foreign function to return `RawEnum&lt;TypeKind&gt;` (which is a wrapper around `u32`), and then perform checked conversion from `u32` to `TypeKind`.
</content>
</entry>
<entry>
<title>Rollup merge of #145120 - maurer:llvm-time, r=nikic</title>
<updated>2025-08-15T06:16:37+00:00</updated>
<author>
<name>Stuart Cook</name>
<email>Zalathar@users.noreply.github.com</email>
</author>
<published>2025-08-15T06:16:37+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=0166de2f87485e77c6d233f414489139bdb94e0a'/>
<id>urn:sha1:0166de2f87485e77c6d233f414489139bdb94e0a</id>
<content type='text'>
llvm: Accept new LLVM lifetime format

In llvm/llvm-project#150248 LLVM removed the size parameter from the lifetime format. Tolerate not having that size parameter.
</content>
</entry>
</feed>
