Repository navigation
fix: user-defined math-named functions no longer bypassed by intrinsics (#874) - #879
Merged
Merged
Conversation
…cs (#874) A function named like a math builtin (exp, sin, log, ...) was silently replaced by the intrinsic/libm path in both backends, so a user's own definition was never called. MLIR: only lower to the math dialect when the name is not a user-defined function (checks the symbol table). C: the backend dropped any primitive-typed function with a libm name and kept its call unmangled so it linked against libm. Gate both on a new @libm attribute that only the stdlib math shims carry; a user function without it is emitted and called normally. Co-Authored-By: Claude <[email protected]>
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.
Closes #874. A function named like a math builtin (exp, sin, log, ...) was silently replaced by the intrinsic/libm path in both backends. MLIR now lowers to the math dialect only when the name is not a user-defined function. C gates the libm substitution on a new
@libmattribute that only the stdlib math shims carry, so a user's own definition is emitted and called. Verified on both backends and against stdlib math.