diff --git a/CHANGELOG.md b/CHANGELOG.md index 7538269..046157a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.13.1] +### Fixed +- Incorrect offset used when parsing 32 bit profraw generated by LLVM 23. + ## [0.13.0] ### Added - Support for LLVM 23 diff --git a/Cargo.toml b/Cargo.toml index 4432445..f8498d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "llvm_profparser" -version = "0.13.0" +version = "0.13.1" authors = ["xd009642 "] description = "Parsing and interpretation of llvm coverage profiles and generated data" repository = "https://github.com/xd009642/llvm-profparser" diff --git a/src/instrumentation_profile/raw_profile.rs b/src/instrumentation_profile/raw_profile.rs index 004c6e5..a9d5d57 100644 --- a/src/instrumentation_profile/raw_profile.rs +++ b/src/instrumentation_profile/raw_profile.rs @@ -351,12 +351,11 @@ where let (bytes, data) = ProfileData::::parse(input, &header)?; debug!("Parsed data section {:?}", data); data_section.push(data); - // Struct tail padding. In v9/v10 ProfileData ends on a 4-byte field at offset 60, - // so the compiler pads to 64. In v11 (LLVM 23) OffloadDeviceWaveSize shifts - // NumBitmapBytes to offset 68, the struct ends at 72 which is already 8-aligned, - // and the padding moves INSIDE the struct (2 bytes, handled in ProfileData::parse). - // Taking 4 here as well would over-consume and desynchronise every later record. - if version_num > 8 && version_num < 11 { + // ProfileData contains uint64 fields, so its alignment is 8 bytes even when its + // pointer fields are 32-bit. V11's 64-bit layout ends at 72 bytes, but its 32-bit + // layout ends at 52 bytes and therefore retains 4 bytes of tail padding. Missing + // that padding desynchronises every record after the first in wasm profiles. + if version_num > 8 && (version_num < 11 || size_of::() == size_of::()) { let (bytes, v) = take(4usize)(bytes)?; debug!("Got those padding? bytes {:?}", v); input = bytes; diff --git a/tests/data/profdata/llvm-23/wasm-multi-record.profraw b/tests/data/profdata/llvm-23/wasm-multi-record.profraw new file mode 100644 index 0000000..63d9f73 Binary files /dev/null and b/tests/data/profdata/llvm-23/wasm-multi-record.profraw differ