-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Code that uses a libcall marks internal symbol as exported when making object file #132055
Comments
bisected to 3d0846b with the help of manyclangs |
@llvm/issue-subscribers-backend-x86 Author: Gabriel Baraldi (gbaraldi)
This is showing up as https://github.com/JuliaLang/julia/pull/57658#issuecomment-2727385403 which is holding up julia being able to compile with LLVM20.
The issue is that a defining a libcall in a module and then having it be used is making the libcall symbol become external source_filename = "text"
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.14.0-macho"
declare i16 @<!-- -->julia_float_to_half(float)
define internal i16 @<!-- -->__truncsfhf2(float %0) {
%2 = call i16 @<!-- -->julia_float_to_half(float %0)
ret i16 %2
}
define hidden swiftcc half @<!-- -->julia_fp(float %0) {
%2 = fptrunc float %0 to half
ret half %2
}
@<!-- -->llvm.compiler.used = appending global [1 x ptr] [ptr @<!-- -->__truncsfhf2], section "llvm.metadata"
Not sure if this is an intentional change or not but it's between LLVM 19 and 20 |
Based on #3045, it seems at least in 2008 it was intentional that calls to libcalls have symbols of type |
Not sure I have the context here (or why am I tagged??) |
Sorry, so if you look at the ir in the first comment, it's no longer producing an internal symbol as you can see in the I was trying to understand what the point of that pr was and if it was intentional that it had caused the symbol to no longer be internal. Thanks. |
Shouldn’t MO_ExternalSymbol be external (as the name says)? Why would it be internal? |
The Julia Language currently will define As far as I can tell, a libcall is always represented with a source_filename = "text"
target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.14.0-macho"
declare i16 @julia_float_to_half(float)
define internal i16 @__truncsfhf2(float %0) {
%2 = call i16 @julia_float_to_half(float %0)
ret i16 %2
}
define hidden swiftcc half @julia_fp(float %0) {
%2 = fptrunc float %0 to half
ret half %2
}
@llvm.compiler.used = appending global [1 x ptr] [ptr @__truncsfhf2], section "llvm.metadata"
The Julia language typically only upgrades llvm when a new version comes out which is why it has gone unnoticed so far. |
Thank you for the details on the failure symptoms! This describes why Julia is currently failing, though it doesn't seem to explain why a (From another train of thought, perhaps less technical)I understand that Julia only pulls upstream every 6months hence the issue just popped, but llvm backend has many downstream users other than Julia, and there hasn't been much issue with this change for them. Could this be a more Julia specific thing that needs to be adjusted on Julia side instead of x86 backend? (CC @npanchen @dgurchenkov) |
@topperc does |
I don't have much knowledge about RISC-V, could you provide more context (since I know you are the RISC-V expert 😛 ) |
I mainly referred to RISC-V as it was the last target I know that was added, so @topperc implemented that functionality too. As soon as @topperc also maintained x86 for a long period of time, pretty sure he is the right person to answer that question. Overall, there're several targets that do seem to have copy-pasted same code to handle
|
The assumption, in the backend, is that all the RuntimeLibcalls symbols are, in fact defined in a different module. If you somehow manage to hack things together to make things work anyway, you're going outside the LLVM compilation model; it's not something we intentionally support. There's been a lot of discussion of changing the model in the context of LTO/offloading/etc., but nothing has really happened yet. That said, #108880 is clearly wrong: the AsmPrinter should not be modifying the visibility of a symbol that way. If some property of a symbol needs to be modified, it should be done using appropriate directives, not by directly messing with MC-internal datastructures. |
Opened #133291 |
Could you please point out what directives to use for "it should be done using appropriate directives"? Why is it wrong to mark 'MO_ExternalSymbol' as |
…3291) Reverts llvm#108880 . The patch has no regression test, no description of why the fix is necessary, and the code is modifying MC datastructures in a way that's forbidden in the AsmPrinter. Fixes llvm#132055. (cherry picked from commit cd6e959)
This is showing up as JuliaLang/julia#57658 (comment) which is holding up julia being able to compile with LLVM20.
The issue is that a defining a libcall in a module and then having it be used is making the libcall symbol become external
Not sure if this is an intentional change or not but it's between LLVM 19 and 20
The text was updated successfully, but these errors were encountered: