Repository navigation
Update LLVM - #1740
Merged
Merged
Update LLVM#1740
Conversation
rjodinchr
enabled auto-merge (squash)
November 12, 2026 09:47
LLVM's `IRBuilder::CreateGEP` now canonicalizes `getelementptr` instructions into `i8` or `[N x i8]` `ptradd` form and elides all-zero indices. - Extend `SimplifyPointerBitcastPass` (`runOnUpgradeableConstantCasts`) to recognize single-index `[N x i8]` GEPs alongside `i8` GEPs so canonicalized byte-array GEPs created by upstream LLVM passes can be upgraded to the target element type. - Add `clspv::CreateGEP` and `clspv::CreateInBoundsGEP` helpers in `Types.h` that preserve explicit GEP source element types via `GetElementPtrInst::Create` (after running the builder's `FoldGEP`), and use them across clspv passes that rely on typed GEPs.
rjodinchr
force-pushed
the
update-llvm
branch
from
November 12, 2026 10:15
d65565c to
8f246e0
Compare
alan-baker
approved these changes
Nov 12, 2026
rjodinchr
added a commit
to rjodinchr/clspv
that referenced
this pull request
Nov 12, 2026
Follow-up to google#1740: - Do not upgrade `[N x i8]` GEPs to struct types or upgrade GEPs to packed struct types in `runOnUpgradeableConstantCasts`. `RewritePackedStructs` lowers packed struct GEPs into `[N x i8]` GEPs and relies on `runOnImplicitCasts` and `ReplacePointerBitcastPass` to lower downstream struct users; upgrading `[N x i8]` back to the struct type undoes `RewritePackedStructs` and leaves unaligned packed structs in SPIR-V. - Reject empty `[0 x i8]` arrays in `IsByteArrayTy` to avoid division by zero when computing GEP stride ratios. - Require `smallerBitWidths` and `coef_target` to evenly divide each other (`smallerBitWidths % coef_target == 0` when `coef_target <= smallerBitWidths`, or `coef_target % smallerBitWidths == 0` otherwise) before upgrading dynamic `[N x i8]` GEPs, including in the `knownMultiple` fallback, so `GetIdxsForTyFromOffset` never hits an assertion or truncates non-integer stride ratios. - Remove unused variables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LLVM's
IRBuilder::CreateGEPnow canonicalizesgetelementptrinstructions intoi8or[N x i8]ptraddform and elides all-zero indices.SimplifyPointerBitcastPass(runOnUpgradeableConstantCasts) to recognize single-index[N x i8]GEPs alongsidei8GEPs so canonicalized byte-array GEPs created by upstream LLVM passes can be upgraded to the target element type.clspv::CreateGEPandclspv::CreateInBoundsGEPhelpers inTypes.hthat preserve explicit GEP source element types viaGetElementPtrInst::Create(after running the builder'sFoldGEP), and use them across clspv passes that rely on typed GEPs.