This is an archive of the discontinued LLVM Phabricator instance.

[SelectionDAG] Make fast and linearize visible by clang -pre-RA-sched
ClosedPublic

Authored by TaoPan on Apr 30 2021, 1:10 AM.

Details

Summary

ScheduleDAGFast.cpp is compiled to object file, but the ScheduleDAGFast
object file isn't linked into clang executable file as no symbol is
referred by outside. Add calling to createXxx of ScheduleDAGFast.cpp,
then the ScheduleDAGFast object file will be linked into clang
executable file. The static RegisterScheduler will register scheduler
fast and linearize at clang boot time.

Diff Detail

Event Timeline

TaoPan created this revision.Apr 30 2021, 1:10 AM
TaoPan requested review of this revision.Apr 30 2021, 1:10 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptApr 30 2021, 1:10 AM

Could you please have a review?

TaoPan added subscribers: YolandaCY, penzn.
pengfei added inline comments.May 6 2021, 9:26 PM
clang/test/CodeGen/pre-ra-sched.c
2

Should we add test under llvm/test? A bit strange that changing LLVM code while adding test in clang/test.

llvm/include/llvm/CodeGen/TargetLowering.h
105

This comma should be removed.

llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
273–276

I saw they are always registered in ScheduleDAGFast.cpp:
https://github.com/llvm/llvm-project/blob/main/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGFast.cpp#L36
Why do we register them again here?

TaoPan updated this revision to Diff 343589.May 6 2021, 11:29 PM

Move test from clang/test to llvm/test, remove comma of the last enum item.

TaoPan marked an inline comment as done.May 6 2021, 11:49 PM

Thanks Pengfei for your review comments!

llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
273–276

Please also help to have a review of the Summary. It's a little bit of a trick. ScheduleDAGFast.cpp is compiled to object file, but the object file isn't linked into clang executable file as no symbol is referred by outside without this patch.

TaoPan updated this revision to Diff 343598.May 7 2021, 12:48 AM

git rebase

craig.topper added inline comments.May 7 2021, 3:26 PM
llvm/test/CodeGen/Generic/pre-ra-sched.c
1 ↗(On Diff #343598)

You can't run clang from an llvm test directory. There's no guarantee clang will have been compiled.

craig.topper added inline comments.May 7 2021, 4:04 PM
llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
273–276

That wasn't very clear from your summary. The "the object file isn't linked into clang executable file as no symbol is referred by outside without this patch" in this comment was much more help. Can you put something like that in summary?

Why are they being stripped from clang but not llc?

craig.topper added inline comments.May 7 2021, 4:06 PM
llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
273–276

Oh I see, llc uses include/llvm/CodeGen/LinkAllCodegenComponents.h to force these to link in.

TaoPan edited the summary of this revision. (Show Details)May 7 2021, 6:44 PM
TaoPan updated this revision to Diff 343800.May 7 2021, 7:05 PM

Move test back to clang/test/CodeGen/

TaoPan added inline comments.May 7 2021, 7:09 PM
llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
273–276

Thanks! I modified summary. could you please have a review?
Yes, you are right, llc include LinkAllCodegenComponents.h which refers function createFastDAGScheduler of ScheduleDAGFast.cpp.

llvm/test/CodeGen/Generic/pre-ra-sched.c
1 ↗(On Diff #343598)

Thanks for notifying no guarantee clang in llvm test directory! I moved the test back to clang/test/CodeGen/.

pengfei accepted this revision.May 7 2021, 7:24 PM

I see. LGTM, but let's wait one or more days to see if others object it.

llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
275–276

Can this be omitted given createFastDAGScheduler should make it linked.

This revision is now accepted and ready to land.May 7 2021, 7:24 PM
TaoPan added inline comments.May 7 2021, 7:57 PM
llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
275–276

For making scheduler fast and linearize visible by clang -pre-RA-sched, yes, createDAGLinearizer can be omitted.
Adding both is also for keeping the ability that all schedulers can be selected by TargetLowering object in the case of clang -pre-RA-sched=default.

hubert.reinterpretcast added inline comments.
clang/test/CodeGen/pre-ra-sched.c
1–2

The test as was committed is bogus. It checks the output binary(!) stream for an error message when stderr was not even redirected. Please fix.

TaoPan added inline comments.May 20 2021, 7:11 PM
clang/test/CodeGen/pre-ra-sched.c
1–2

Thanks for your review comment and fixing!
I tried to check stderr as you guided and meet empty stdin problem, thanks for your quick fixing and I got FileCheck option --allow-empty can resolve this kind of problem.

clang/test/CodeGen/pre-ra-sched.c
1–2

No problem. Thanks for looking into it.