This is an archive of the discontinued LLVM Phabricator instance.

[ORC][COFF] Properly set weak flag to COMDAT symbols.
ClosedPublic

Authored by sunho on Jul 14 2022, 5:28 AM.

Details

Summary

Properly set weak flag to COMDAT symbols so that no duplicate definition error will be generated. There is an inaccuracy in setting plain weak for largest selection type, which will be dealt with soon when largest type is properly implemented.

Diff Detail

Event Timeline

sunho created this revision.Jul 14 2022, 5:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 14 2022, 5:28 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
sunho requested review of this revision.Jul 14 2022, 5:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 14 2022, 5:28 AM

Thanks!

llvm/lib/ExecutionEngine/Orc/ObjectFileInterface.cpp
165

I guess this could indeed fail for malformed objects. The referred section might not exist, right?

llvm/test/ExecutionEngine/JITLink/X86/COFF_comdat_weak_plus_strong.s
12

I never double-checked this with the Mircosoft toolchain. Did you?

llvm/test/ExecutionEngine/JITLink/X86/COFF_strong_duplicate.s
10

Can we use # RUN: not llvm-jitlink ... to check that we get a non-zero exit code instead of XFAILing the test? My impression was that XFAIL should be used specifically to mark bugs and todos.

sunho added a comment.Jul 17 2022, 5:21 PM

Thanks for the review!

llvm/lib/ExecutionEngine/Orc/ObjectFileInterface.cpp
165

It shouldn't happen in valid object file, but yes it could happen in invalid ones, I'll change it to check error.

llvm/test/ExecutionEngine/JITLink/X86/COFF_comdat_weak_plus_strong.s
12

I just checked with msvc toolchain and it gets duplicate definition error. I guess we need to introduce new linkage type for this.

llvm/test/ExecutionEngine/JITLink/X86/COFF_strong_duplicate.s
10

I didn't know about not when I wrote this. Thanks for pointing out!

sunho updated this revision to Diff 445680.Jul 18 2022, 7:43 PM

Address comments, strong + weak test will be corrected in follow up patch.

sunho marked 3 inline comments as done.Jul 18 2022, 7:43 PM
lhames accepted this revision.Jul 19 2022, 6:28 PM

Otherwise LGTM. Thanks @sunho!

llvm/test/ExecutionEngine/JITLink/X86/COFF_strong_duplicate.s
10

Even better, can we check for the text of the error to verify that it failed for the expected reason? (And likewise in the other testcase, if possible)

This revision is now accepted and ready to land.Jul 19 2022, 6:28 PM
This revision was landed with ongoing or failed builds.Jul 25 2022, 7:25 AM
This revision was automatically updated to reflect the committed changes.