File size: 4,417 Bytes
2406a1f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# LLVM IR Analysis Dataset: llvm-sys.rs

This dataset contains comprehensive LLVM IR analysis data extracted from Rust source `/home/mdupont/2024/08/24/llvm-sys.rs` using the LLVM IR extractor.

## Dataset Overview

- **Source**: /home/mdupont/2024/08/24/llvm-sys.rs
- **Optimization Levels**: ["O0", "O1", "O2", "O3"]
- **Extraction Tool**: LLVM IR extractor (part of hf-dataset-validator-rust)
- **Format**: Apache Parquet files optimized for machine learning
- **Compression**: Snappy compression for fast loading

## Dataset Structure

### Phase-Based Organization

The dataset captures the complete Rust β†’ LLVM IR compilation pipeline:

#### 1. IR Generation (`ir_generation-*-phase/`)
- Initial LLVM IR generation from Rust source
- Type system mappings (Rust types β†’ LLVM types)
- Function signature transformations
- Basic block and instruction analysis

#### 2. Optimization Passes (`optimization_passes-*-phase/`)
- LLVM optimization pass applications and effects
- Before/after IR comparisons for each optimization
- Performance impact measurements
- Optimization decision analysis

#### 3. Code Generation (`code_generation-*-phase/`)
- Final IR β†’ machine code generation patterns
- Target-specific optimizations and transformations
- Register allocation and instruction selection
- Assembly code generation analysis

#### 4. Performance Analysis (`performance_analysis-*-phase/`)
- Execution cycle estimates and performance metrics
- Code size and complexity analysis
- Optimization impact correlation
- Performance regression detection

#### 5. Type System Mapping (`type_system_mapping-*-phase/`)
- Detailed Rust type β†’ LLVM type conversions
- Generic parameter handling and monomorphization
- Trait object representation analysis
- Lifetime analysis impact on IR generation

#### 6. Memory Analysis (`memory_analysis-*-phase/`)
- Stack and heap allocation pattern analysis
- Memory safety guarantee preservation
- Reference counting and ownership in IR
- Memory layout optimization analysis

## Optimization Levels

Each phase is analyzed across multiple optimization levels:
- **O0**: No optimization (debug builds)
- **O1**: Basic optimizations
- **O2**: Standard optimizations (release builds)
- **O3**: Aggressive optimizations

## Schema

Each record contains:
- **Source Context**: Original Rust code, line/column, construct type
- **LLVM IR**: Generated IR code, instruction counts, basic blocks
- **Optimization Data**: Passes applied, before/after comparisons, impact scores
- **Code Generation**: Target architecture, assembly code, register usage
- **Performance Metrics**: Cycle estimates, code size, complexity scores
- **Type Mappings**: Rust β†’ LLVM type conversions and analysis
- **Memory Patterns**: Allocation analysis and safety preservation
- **Processing Metadata**: Timestamps, tool versions, processing times

## Applications

This dataset enables research in:
- **Compiler Optimization**: Understanding LLVM optimization effectiveness
- **Performance Prediction**: Predicting performance from source patterns
- **Code Generation**: Learning optimal IR generation strategies
- **Type System Research**: Understanding type system compilation
- **Memory Safety**: Analyzing memory safety preservation in compilation

## Usage

### Loading with Python

```python
import pandas as pd

# Load IR generation data for O2 optimization
ir_gen_df = pd.read_parquet('ir_generation-O2-phase/data.parquet')
print(f"Loaded {len(ir_gen_df)} IR generation records")

# Load optimization pass data
opt_df = pd.read_parquet('optimization_passes-O2-phase/data.parquet')
print(f"Loaded {len(opt_df)} optimization records")
```

### Loading with Rust

```rust
use arrow::record_batch::RecordBatch;
use parquet::arrow::arrow_reader::ParquetRecordBatchReaderBuilder;

// Load LLVM IR data
let file = std::fs::File::open("ir_generation-O2-phase/data.parquet")?;
let builder = ParquetRecordBatchReaderBuilder::try_new(file)?;
let reader = builder.build()?;

for batch_result in reader {
    let batch = batch_result?;
    println!("Loaded batch with {} LLVM IR records", batch.num_rows());
}
```

## Generation Details

- **Generated**: 2025-08-08 00:39:57 UTC
- **Tool Version**: LLVM IR extractor (hf-dataset-validator-rust)
- **Source**: /home/mdupont/2024/08/24/llvm-sys.rs
- **Optimization Levels**: ["O0", "O1", "O2", "O3"]
- **Total Phases**: 6 analysis phases Γ— 4 optimization levels