diff options
| author | Aiden Grossman <aidengrossman@google.com> | 2025-09-12 01:05:48 +0000 |
|---|---|---|
| committer | Aiden Grossman <aidengrossman@google.com> | 2025-09-12 01:05:48 +0000 |
| commit | 88a52e1fc6d3e153132f0e0a86431762adf8c0c4 (patch) | |
| tree | bae8c1b720736edc54705c325c5bfb95b459eda2 /mlir/lib/Bytecode/Reader/BytecodeReader.cpp | |
| parent | 1873dd7e8bb03319500a9f4b51e9e498a8fb70de (diff) | |
| parent | 2740e4b73682eb7a6869c333991a608304938952 (diff) | |
[𝘀𝗽𝗿] changes introduced through rebaseusers/boomanaiden154/main.clang-invoke-shell-script-with-bash
Created using spr 1.3.6
[skip ci]
Diffstat (limited to 'mlir/lib/Bytecode/Reader/BytecodeReader.cpp')
| -rw-r--r-- | mlir/lib/Bytecode/Reader/BytecodeReader.cpp | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/mlir/lib/Bytecode/Reader/BytecodeReader.cpp b/mlir/lib/Bytecode/Reader/BytecodeReader.cpp index d29053a2b6e6..1659437e1eb2 100644 --- a/mlir/lib/Bytecode/Reader/BytecodeReader.cpp +++ b/mlir/lib/Bytecode/Reader/BytecodeReader.cpp @@ -22,8 +22,6 @@ #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Endian.h" -#include "llvm/Support/Format.h" -#include "llvm/Support/LogicalResult.h" #include "llvm/Support/MemoryBufferRef.h" #include "llvm/Support/SourceMgr.h" @@ -296,12 +294,38 @@ public: if (failed(parseVarInt(alignment))) return failure(); - // Check that the requested alignment is less than or equal to the - // alignment of the root buffer. If it is not, we cannot safely guarantee - // that the specified alignment is globally correct. + // Check that the requested alignment must not exceed the alignment of + // the root buffer itself. Otherwise we cannot guarantee that pointers + // derived from this buffer will actually satisfy the requested alignment + // globally. // - // E.g. if the buffer is 8k aligned and the section is 16k aligned, - // we could end up at an offset of 24k, which is not globally 16k aligned. + // Consider a bytecode buffer that is guaranteed to be 8k aligned, but not + // 16k aligned (e.g. absolute address 40960. If a section inside this + // buffer declares a 16k alignment requirement, two problems can arise: + // + // (a) If we "align forward" the current pointer to the next + // 16k boundary, the amount of padding we skip depends on the + // buffer's starting address. For example: + // + // buffer_start = 40960 + // next 16k boundary = 49152 + // bytes skipped = 49152 - 40960 = 8192 + // + // This leaves behind variable padding that could be misinterpreted + // as part of the next section. + // + // (b) If we align relative to the buffer start, we may + // obtain addresses that are multiples of "buffer_start + + // section_alignment" rather than truly globally aligned + // addresses. For example: + // + // buffer_start = 40960 (5×8k, 8k aligned but not 16k) + // offset = 16384 (first multiple of 16k) + // section_ptr = 40960 + 16384 = 57344 + // + // 57344 is 8k aligned but not 16k aligned. + // Any consumer expecting true 16k alignment would see this as a + // violation. if (failed(alignmentValidator(alignment))) return emitError("failed to align section ID: ", unsigned(sectionID)); |
