Repository navigation
--di with --opt keeps its locations, and inlined ones are made safe for the DI scope pass - #415
Merged
Merged
Conversation
…or the DI scope pass `--di --opt` failed before any code was generated, for most programs and every -mm=rc one: "inlinable function call in a function with a DISubprogram location must have a debug location". --opt ran StripDebugInfo ahead of the inliner, so every location was gone, while --di still ran DIScopeForLLVMFuncOpPass, which gives every function a subprogram. A call left standing then had no location in a function that needed one, which the LLVM dialect verifier rejects for a call it could inline. Under rc that is every program: the tsrel_/tsret_ helpers are made by the lowering, after the inliner ran. It also stripped the very debug information --di asked for. The strip now runs only without --di. Keeping the locations exposed two shapes the inliner leaves that DIScopeForLLVMFuncOpPass dereferences without checking, crashing tslang: - `callsite(unknown at <call>)`, from an op made without a location of its own: the pass reads a file name out of every call site's callee; - a call-site location on an op outside any function - the lowering makes a string literal's global with the location of the op that used it: the pass reads the enclosing function's location. A new InlinedLocationPass runs ahead of it under --di --opt: an inlined op with no location of its own takes its call's, and an op outside a function takes the location it was written at. Test test-compile-debug-info-opt (debug-info-opt.cmake): five programs to LLVM IR with --di --opt under gc, rc and none. Without the fix it fails for four of the five in every model. Every file in test/tester/tests compiles with --di --opt under gc, rc and none, and runs under JIT (gc and rc), wherever it does with --opt alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
Building with debug info and optimisation together,
--di --opt, failed before any code was generated. It failed for most programs, and for every-mm=rcprogram:Cause
--optranStripDebugInfobefore the inliner, which removed every location.--distill ranDIScopeForLLVMFuncOpPass, which gives every function a subprogram. Any call still standing afterwards had no location inside a function that needed one, and the LLVM dialect verifier rejects that when the callee could be inlined.Under rc that is every program, because the lowering makes the
tsrel_/tsret_helpers after the inliner has run. Stripping also threw away the very debug information--diasked for.Fix
--di.InlinedLocationPassruns beforeDIScopeForLLVMFuncOpPassunder--di --opt. Keeping the locations exposed two shapes the inliner leaves behind, both of which the upstream pass dereferences without checking, crashing tslang:callsite(unknown at <call>), from an op that was made without a location and then inlined. The pass reads a file name from every call site's callee. The inlined op now takes the location of its call.Tests
test-compile-debug-info-opt(debug-info-opt.cmake) emits LLVM IR with--di --optfor five programs under gc, rc and none. It is a cmake script, likedebug-info-rc.cmake, becausetest-runnernever combines the two flags. Without the fix, four of the five fail in every model.Every file in
test/tester/testswas also swept with--di --optand compared against--optalone:--di;--di.Release ctest: 3293/3293 (one test already disabled).
🤖 Generated with Claude Code