Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"no-builtins" should work on __multi3? #65031

Open
DianQK opened this issue Aug 28, 2023 · 1 comment
Open

"no-builtins" should work on __multi3? #65031

DianQK opened this issue Aug 28, 2023 · 1 comment
Labels
compiler-rt:builtins question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

Comments

@DianQK
Copy link
Member

DianQK commented Aug 28, 2023

https://llvm.godbolt.org/z/9vcj8dqaY

I tried this IR:

define noundef i128 @multer(i128 noundef %0, i128 noundef %1) unnamed_addr #1 {
  %3 = mul i128 %1, %0
  ret i128 %3
}

define noundef i128 @multer2(i128 noundef %0, i128 noundef %1) {
  %3 = mul i128 %1, %0
  ret i128 %3
}

define noundef i128 @__multi3(i128 noundef %0, i128 noundef %1) unnamed_addr #1 {
  ret i128 999
}

attributes #1 = { "no-builtins" }

I expect multer to use the __multi3 function I defined.
But I got:

multer:                                 # @multer
        mov     rax, rdx
        imul    rsi, rdx
        mul     rdi
        add     rdx, rsi
        imul    rcx, rdi
        add     rdx, rcx
        ret
multer2:                                # @multer2
        mov     rax, rdx
        imul    rsi, rdx
        mul     rdi
        add     rdx, rsi
        imul    rcx, rdi
        add     rdx, rcx
        ret
__multi3:                               # @__multi3
        mov     eax, 999
        xor     edx, edx
        ret
@DianQK DianQK added question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead! compiler-rt:builtins labels Aug 28, 2023
@arsenm
Copy link
Contributor

arsenm commented Aug 29, 2023

It's unclear. "no-builtins" isn't even documented in the LangRef. It's only used by TargetLibraryInfo, but the backend has a separate, parallel RuntimeLibcalls. There probably needs to be a distinction between which calls are recognized and which calls can be emitted, but it seems that was never fully considered or implemented. cc @jhuber6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler-rt:builtins question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!
Projects
None yet
Development

No branches or pull requests

2 participants