As discussed on the list (incidentally I already had a patch for that).
Details
Diff Detail
Event Timeline
Also it is not clear to me why we track this globally instead of per-file? What is an ASM reference a local symbol for instance?
lib/LTO/LTOBackend.cpp | ||
---|---|---|
291 | thinBackend() is also used by clang and it's not entirely clear to me what should I pass to it as AsmUndefinedReferences. If you know that off of your mind, I can change it. Otherwise I can commit the patch as is for full LTO and you can modify for thin accordingly (sorry, my knowledge of ThinLTO is still rather limited, and I don't want to delay this further). |
Yeah at least for ThinLTO perhaps we should call IRObjectFile::CollectAsmUndefinedRefs in the thinBackend to collect this for each module? That would address the issue Davide mentioned about that being called from clang (distributed backends case). For regular LTO it is essentially global since we merge the module.
lib/LTO/LTO.cpp | ||
---|---|---|
310 | Shouldn't this be: an undefined reference "of" a symbol "used" in asm? |
The problem is that after merge, if two local symbols have a name conflict in LTO, one of them will be renamed.
I'd like to see a test with such cases.
Hmm, so how would we catch/handle this? The uses from module level assembly won't be renamed, right? (I know that is an issue for inline assembly). That seems orthogonal to the issue of making sure their defs are not dropped by updating llvm.compiler.used appropriately (which could be fixed by doing what I suggested for ThinLTO - call CollectAsmUndefinedRefs from the backend).
That seems orthogonal to the issue of making sure their defs are not dropped by updating llvm.compiler.used appropriately which could be fixed by doing what I suggested for ThinLTO - call CollectAsmUndefinedRefs from the backend).
Right, this would solves it (but for the lack of renaming).
Another way is to do it on the individual modules when they're loaded, pre-merge.
Teresa, is this what you had in mind? Also added a ThinLTO test, hopefully it's correct.
lib/LTO/LTO.cpp | ||
---|---|---|
368 | Why don't you update compiler.used here before merging? This way the StringSet could be local to this function and not global to the LTO class/lifetime I believe. |
Yes, thanks. One suggestion to merge the new tests below.
test/tools/gold/X86/asm_undefined2_thin.ll | ||
---|---|---|
6 ↗ | (On Diff #71552) | I suppose since the test is basically the same you could copy these RUN lines into asm_undefined2.ll so it would test both regular and thin LTO. |
I tried to write that but there are issues providing the resolution because IRObjectFile will report the same symbol twice. I added a comment to https://llvm.org/bugs/show_bug.cgi?id=30396 so that we can add a test for this once we fix IRObjectFile =)
Shouldn't this be: an undefined reference "of" a symbol "used" in asm?