File tree Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change 1+ # RUN: llvm-mc -filetype=obj -o %t -mcpu=native %s 2> %t.stderr
2+ # RUN: FileCheck --allow-empty %s < %t.stderr
3+
4+ # CHECK-NOT: {{.+}}
Original file line number Diff line number Diff line change @@ -459,14 +459,23 @@ int main(int argc, char **argv) {
459459 MAI->setCommentColumn (CommentColumn);
460460
461461 // Package up features to be passed to target/subtarget
462+ SubtargetFeatures Features;
462463 std::string FeaturesStr;
463- if (MAttrs.size ()) {
464- SubtargetFeatures Features;
465- for (unsigned i = 0 ; i != MAttrs.size (); ++i)
466- Features.AddFeature (MAttrs[i]);
467- FeaturesStr = Features.getString ();
464+
465+ // Replace -mcpu=native with Host CPU and features.
466+ if (MCPU == " native" ) {
467+ MCPU = std::string (llvm::sys::getHostCPUName ());
468+
469+ llvm::StringMap<bool > TargetFeatures = llvm::sys::getHostCPUFeatures ();
470+ for (auto const &[FeatureName, IsSupported] : TargetFeatures)
471+ Features.AddFeature (FeatureName, IsSupported);
468472 }
469473
474+ // Handle features passed to target/subtarget.
475+ for (unsigned i = 0 ; i != MAttrs.size (); ++i)
476+ Features.AddFeature (MAttrs[i]);
477+ FeaturesStr = Features.getString ();
478+
470479 std::unique_ptr<MCSubtargetInfo> STI (
471480 TheTarget->createMCSubtargetInfo (TheTriple, MCPU, FeaturesStr));
472481 if (!STI) {
You can’t perform that action at this time.
0 commit comments