This is an archive of the discontinued LLVM Phabricator instance.

[llvm] Support forward-referenced globals with dso_local_equivalent
ClosedPublic

Authored by leonardchan on Sep 19 2022, 4:08 PM.

Details

Summary

See https://github.com/llvm/llvm-project/issues/57815.

dso_local_equivalent would fail with an assertion on forward-referenced globals. This is an issue that only comes up in textual IR, which is why we've never seen this assertion with clang.

Diff Detail

Event Timeline

leonardchan created this revision.Sep 19 2022, 4:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 19 2022, 4:08 PM
leonardchan requested review of this revision.Sep 19 2022, 4:08 PM
MaskRay added inline comments.Sep 20 2022, 2:32 PM
llvm/lib/AsmParser/LLParser.cpp
220

Use a range-based for loop and clear ForwardRefDSOLocalEquivalents?

227

This line has no test coverage.

230

The error is not tested.

234

The error is not tested.

leonardchan marked 4 inline comments as done.
leonardchan added inline comments.
llvm/lib/AsmParser/LLParser.cpp
220

Right. Had this but forgot to update the diff.

MaskRay accepted this revision.Sep 20 2022, 10:29 PM
MaskRay added inline comments.
llvm/lib/AsmParser/LLParser.cpp
3459

This may use try_emplace with structured bindings since we can use C++17.

llvm/test/CodeGen/X86/dso_local_equivalent_undefined_func.ll
1 ↗(On Diff #461732)

Instead of having 3 test files, if merging improves readability, check out split-file. I think at the least the two invalid tests should be combined.

This revision is now accepted and ready to land.Sep 20 2022, 10:29 PM
leonardchan marked 2 inline comments as done.Sep 21 2022, 12:31 PM
leonardchan added inline comments.
llvm/test/CodeGen/X86/dso_local_equivalent_undefined_func.ll
1 ↗(On Diff #461732)

First time learning about this. Very useful!

This revision was landed with ongoing or failed builds.Sep 21 2022, 12:32 PM
This revision was automatically updated to reflect the committed changes.
leonardchan marked an inline comment as done.
nikic added a subscriber: nikic.Sep 21 2022, 1:27 PM

These tests should be in llvm/test/Assembler and preferably test round-trip of llvm-as and llvm-dis, as well as verify-uselistorder.

These tests should be in llvm/test/Assembler and preferably test round-trip of llvm-as and llvm-dis, as well as verify-uselistorder.

Added llvm-as/dis tests and verify-uselistorder. I still think the codegen tests are necessary though since we still want to test the lowered calls are properly calling the right thing with/without plts.