This is an archive of the discontinued LLVM Phabricator instance.

Pass code-model through Module IR to [llc]
ClosedPublic

Authored by Esme on Jun 26 2022, 9:51 PM.

Details

Reviewers
shchenz
rzurob
MaskRay
Group Reviewers
Restricted Project
Commits
rGff855f5ec0c3: Pass code-model through Module IR to [llc].
Summary

Currently, the code-model specified in IR can't be captured by LLC.
This patch fixes that.

Diff Detail

Event Timeline

Esme created this revision.Jun 26 2022, 9:51 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 26 2022, 9:51 PM
Esme requested review of this revision.Jun 26 2022, 9:51 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 26 2022, 9:51 PM

Thanks. This makes sense to me.

llvm/test/tools/llc/codemodel.ll
1 ↗(On Diff #440108)

Add ; REQUIRES: x86-registered-target

llvm/tools/llc/llc.cpp
579

drop braces

For Optional, the convention is to use its operator bool() instead of hasValue.

Esme updated this revision to Diff 440115.Jun 27 2022, 12:33 AM

Addressed comments.
Thanks! @MaskRay

Esme updated this revision to Diff 440116.Jun 27 2022, 12:35 AM
shchenz added inline comments.Jun 27 2022, 7:41 PM
llvm/include/llvm/Target/TargetMachine.h
226

We may can implement this simple function in the header.

llvm/test/tools/llc/codemodel.ll
2 ↗(On Diff #440116)

Can we add more cases? For example, changing the code model by using command option to verify:
1: the command option will override the IR input
2: different code models generate different instructions. (Not sure X86 will have different final assembly for below case for different code models, if no difference on X86, we can use some PPC target codes). With this we can verify that the code model in the IR is taken into account by the llc.

MaskRay accepted this revision.Jun 27 2022, 9:33 PM

LGTM when @shchenz is happy

FWIW, I'd use [llc] instead of ... to LLC for the subject.

This revision is now accepted and ready to land.Jun 27 2022, 9:33 PM
Esme updated this revision to Diff 440503.Jun 28 2022, 12:13 AM
Esme retitled this revision from Pass code-model through Module IR to LLC to Pass code-model through Module IR to [llc].
shchenz accepted this revision as: shchenz.Jun 28 2022, 12:37 AM

Looks great! Thanks for adding this support.

This revision was landed with ongoing or failed builds.Jun 28 2022, 11:31 PM
This revision was automatically updated to reflect the committed changes.