This is an archive of the discontinued LLVM Phabricator instance.

[clang-cl] Enable -march
ClosedPublic

Authored by aganea on Sep 7 2018, 11:24 AM.

Details

Summary

Currently, -march does not work in the clang-cl driver.

We are currently migrating from MSVC. The project size makes that we have to stick with clang-cl for a little while. However, we don't want to loose optimisation oportunities in the runtime code, and the MSVC flag /arch only supports a limited set of options.

Diff Detail

Repository
rC Clang

Event Timeline

aganea created this revision.Sep 7 2018, 11:24 AM
hans added a comment.Sep 10 2018, 12:52 AM

All flags in the m_x86_Features_Group, i.e. -msse, -mavx and so on are all supported. I'm just curious to hear what it is that you need from -march?

@hans I want to target precisely a given CPU when using clang-cl. The options in the m_x86_Features_Group are too granular. It is easier to just add -march=skylake on the cmd-line. Is there any other way?

hans added a comment.Sep 10 2018, 6:46 AM

Okay, that sounds good to me.

Please also add a test for this in test/Driver/cl-options.c in the "Accept "core" clang options" section.

aganea updated this revision to Diff 164666.Sep 10 2018, 7:15 AM

Updated diff with coverage test as requested.

hans accepted this revision.Sep 10 2018, 7:16 AM

lgtm

This revision is now accepted and ready to land.Sep 10 2018, 7:16 AM

@hans Just an after thought: maybe we should prevent usage of -march= and /arch: at the same time. What do you think? I can add another patch for that purpose.

hans added a comment.Sep 10 2018, 7:33 AM

@hans Just an after thought: maybe we should prevent usage of -march= and /arch: at the same time. What do you think? I can add another patch for that purpose.

Hmm, yes, at least we should warn or do something smart. Currently it doesn't look like they'd interact well together in x86::getX86TargetCPU

aganea added a subscriber: thakis.Sep 10 2018, 10:54 AM

Yes, indeed. The code in clang/lib/Driver/ToolChains/Arch/X86.cpp makes that –march is always parsed, leaving out /arch unused, no matter in which order they appear.

De : Nico Weber <thakis@chromium.org>
Envoyé : 10 septembre 2018 12:14
À : reviews+D51806+public+c25b17a1aa94d0fa@reviews.llvm.org; Senthil Kumar Selvaraj via Phabricator <reviews@reviews.llvm.org>
Cc : Alexandre Ganea <alexandre.ganea@ubisoft.com>; cfe-commits <cfe-commits@lists.llvm.org>
Objet : Re: [PATCH] D51806: [clang-cl] Enable -march

This revision was automatically updated to reflect the committed changes.