This is an archive of the discontinued LLVM Phabricator instance.

[llc] Use CPUStr instead of calling codegen::getMCPU(). NFC
ClosedPublic

Authored by SixWeining on Aug 29 2022, 5:34 AM.

Details

Summary

getCPUStr() fallsback to getMCPU().

The only difference between getCPUStr() and getMCPU() is that
getCPUStr() handles -mcpu=native. That doesn't matter for this case.

This is just a simplification of the original code and it does not
change the functionality. So no new tests added.

Diff Detail

Event Timeline

SixWeining created this revision.Aug 29 2022, 5:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 29 2022, 5:34 AM
Herald added a subscriber: StephenFan. · View Herald Transcript
SixWeining requested review of this revision.Aug 29 2022, 5:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 29 2022, 5:34 AM

getCPUStr() fallsback to getMCPU so this looks good to me.

This revision is now accepted and ready to land.Aug 29 2022, 6:16 AM
MaskRay requested changes to this revision.Aug 29 2022, 2:23 PM

Test?

This revision now requires changes to proceed.Aug 29 2022, 2:23 PM

Test?

The only difference between getCPUStr() and getMCPU() is that getCPUStr() handles -mcpu=native. That doesn't matter for this case. I believe this is NFC as the title says.

Test?

The only difference between getCPUStr() and getMCPU() is that getCPUStr() handles -mcpu=native. That doesn't matter for this case. I believe this is NFC as the title says.

Yes. This is just a simplification of the original code and it does not change the functionality.

Maybe there is only one difference that if sys::getHostCPUName() returns help. But I believe no targets will do like this.

573 std::string codegen::getCPUStr() {
574   // If user asked for the 'native' CPU, autodetect here. If autodection fails,
575   // this will set the CPU to an empty string which tells the target to
576   // pick a basic default.
577   if (getMCPU() == "native")
578     return std::string(sys::getHostCPUName());
579 
580   return getMCPU();
581 }

Test?

The only difference between getCPUStr() and getMCPU() is that getCPUStr() handles -mcpu=native. That doesn't matter for this case. I believe this is NFC as the title says.

This is fine. The motivation should be mentioned in the summary.

SixWeining edited the summary of this revision. (Show Details)Aug 29 2022, 6:16 PM
MaskRay accepted this revision.Aug 29 2022, 6:44 PM

LGTM.

This revision is now accepted and ready to land.Aug 29 2022, 6:44 PM