Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 9 pull requests #111297

Closed
wants to merge 19 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift click to select a range
71ab284
Fix the test directories suggested by `./x.py suggest`
Zalathar Apr 30, 2023
a4ef2f5
Make ConstProp tests unit.
cjgillot May 1, 2023
eea6202
check bootstrap scripts syntax
onur-ozkan May 3, 2023
1e4fd21
Diagnostic args are still args if they're documented
compiler-errors May 3, 2023
0aa6b1e
Make spans a bit better
compiler-errors May 3, 2023
00ac29d
Output LLVM optimization remark kind in `-Cremark` output
Kobzol May 4, 2023
105adf3
Fix instrument-coverage tests by using Python to sort instantiation g…
Zalathar May 4, 2023
08fc451
asm: loongarch64: Implementation of clobber_abi
heiher May 4, 2023
67ae38a
Expand the LLVM coverage of `--print target-cpus`
cuviper May 6, 2023
9027d20
Check arguments length in trivial diagnostic lint
clubby789 May 6, 2023
92fa8d0
Rollup merge of #111002 - Zalathar:x-suggest-dirs, r=Mark-Simulacrum
matthiaskrgr May 6, 2023
89f0efd
Rollup merge of #111077 - cjgillot:const-prop-unit, r=Mark-Simulacrum
matthiaskrgr May 6, 2023
413cff2
Rollup merge of #111151 - ozkanonur:syntax-check-on-bootstrap-scripts…
matthiaskrgr May 6, 2023
1b015e3
Rollup merge of #111170 - compiler-errors:diag-doc, r=petrochenkov
matthiaskrgr May 6, 2023
f2ac543
Rollup merge of #111179 - Zalathar:sort-groups, r=Mark-Simulacrum
matthiaskrgr May 6, 2023
bd9924b
Rollup merge of #111203 - Kobzol:remark-print-kind, r=tmiasko
matthiaskrgr May 6, 2023
f2f1b75
Rollup merge of #111237 - loongarch-rs:clobber-abi, r=Amanieu
matthiaskrgr May 6, 2023
eb53ccf
Rollup merge of #111274 - cuviper:print-target-cpus, r=Mark-Simulacrum
matthiaskrgr May 6, 2023
c56f165
Rollup merge of #111289 - clubby789:fix-111280, r=jyn514
matthiaskrgr May 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Expand the LLVM coverage of --print target-cpus
We've been relying on a custom patch to add `MCSubtargetInfo::getCPUTable`
for `rustc --print target-cpus`, and just printing that it's not supported
on external LLVM builds. LLVM `main` now has `getAllProcessorDescriptions`
that can replace ours, so now we try to use that. In addition, the fallback
path can at least print the native and default cpu options.

There were also some mismatches in the function signatures here between
`LLVM_RUSTLLVM` and otherwise; this is now mitigated by sharing these
functions and only using cpp to adjust the function bodies.
  • Loading branch information
cuviper committed May 6, 2023
commit 67ae38a336599a7e0d2898a5ea3416b947458f5d
30 changes: 16 additions & 14 deletions compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 297,6 @@ static Reloc::Model fromRust(LLVMRustRelocModel RustReloc) {
report_fatal_error("Bad RelocModel.");
}

#ifdef LLVM_RUSTLLVM
/// getLongestEntryLength - Return the length of the longest entry in the table.
template<typename KV>
static size_t getLongestEntryLength(ArrayRef<KV> Table) {
Expand All @@ -312,13 311,23 @@ extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM, const char* Tar
const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
const Triple::ArchType HostArch = Triple(sys::getDefaultTargetTriple()).getArch();
const Triple::ArchType TargetArch = Target->getTargetTriple().getArch();

#if LLVM_VERSION_GE(17, 0)
const ArrayRef<SubtargetSubTypeKV> CPUTable = MCInfo->getAllProcessorDescriptions();
#elif defined(LLVM_RUSTLLVM)
const ArrayRef<SubtargetSubTypeKV> CPUTable = MCInfo->getCPUTable();
#else
printf("Full target CPU help is not supported by this LLVM version.\n\n");
SubtargetSubTypeKV TargetCPUKV = { TargetCPU, {{}}, {{}} };
const ArrayRef<SubtargetSubTypeKV> CPUTable = TargetCPUKV;
#endif
unsigned MaxCPULen = getLongestEntryLength(CPUTable);

printf("Available CPUs for this target:\n");
// Don't print the "native" entry when the user specifies --target with a
// different arch since that could be wrong or misleading.
if (HostArch == TargetArch) {
MaxCPULen = std::max(MaxCPULen, (unsigned) std::strlen("native"));
const StringRef HostCPU = sys::getHostCPUName();
printf(" %-*s - Select the CPU of the current host (currently %.*s).\n",
MaxCPULen, "native", (int)HostCPU.size(), HostCPU.data());
Expand All @@ -338,34 347,27 @@ extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM, const char* Tar
}

extern "C" size_t LLVMRustGetTargetFeaturesCount(LLVMTargetMachineRef TM) {
#ifdef LLVM_RUSTLLVM
const TargetMachine *Target = unwrap(TM);
const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
const ArrayRef<SubtargetFeatureKV> FeatTable = MCInfo->getFeatureTable();
return FeatTable.size();
#else
return 0;
#endif
}

extern "C" void LLVMRustGetTargetFeature(LLVMTargetMachineRef TM, size_t Index,
const char** Feature, const char** Desc) {
#ifdef LLVM_RUSTLLVM
const TargetMachine *Target = unwrap(TM);
const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
const ArrayRef<SubtargetFeatureKV> FeatTable = MCInfo->getFeatureTable();
const SubtargetFeatureKV Feat = FeatTable[Index];
*Feature = Feat.Key;
*Desc = Feat.Desc;
}

#else

extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef) {
printf("Target CPU help is not supported by this LLVM version.\n\n");
}

extern "C" size_t LLVMRustGetTargetFeaturesCount(LLVMTargetMachineRef) {
return 0;
}

extern "C" void LLVMRustGetTargetFeature(LLVMTargetMachineRef, const char**, const char**) {}
#endif
}

extern "C" const char* LLVMRustGetHostCPUName(size_t *len) {
StringRef Name = sys::getHostCPUName();
Expand Down