Skip to content

fix: user-defined math-named functions no longer bypassed by intrinsics (#874) - #879

Merged
godofecht merged 1 commit into
mainfrom
harvest/874-mlir-intrinsic-bypass
Sep 11, 2026
Merged

godofecht merged 1 commit into
mainfrom
harvest/874-mlir-intrinsic-bypass

Conversation

@godofecht

Copy link
Copy Markdown
Contributor

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 @libm attribute 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.

…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]>
@godofecht
godofecht merged commit e833595 into main Sep 11, 2026
20 of 26 checks passed
@godofecht
godofecht deleted the harvest/874-mlir-intrinsic-bypass branch September 11, 2026 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MLIR math intrinsic lowering can silently bypass user-defined functions with builtin names

1 participant