Skip to content

Commit 3333ec1

Browse files
committed
[Driver] Make CodeGenOptions name match MCTargetOptions names
* Initialize `X86RelaxRelocations`. * Fix #96860 test to actually test -Wa,-msse2avx for non-x86.
1 parent 7156bcf commit 3333ec1

File tree

5 files changed

+20
-18
lines changed

5 files changed

+20
-18
lines changed

clang/include/clang/Basic/CodeGenOptions.def

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ VALUE_CODEGENOPT(Name, Bits, Default)
3737

3838
CODEGENOPT(DisableIntegratedAS, 1, 0) ///< -no-integrated-as
3939
CODEGENOPT(Crel, 1, 0) ///< -Wa,--crel
40-
CODEGENOPT(RelaxELFRelocations, 1, 1) ///< -Wa,-mrelax-relocations={yes,no}
41-
CODEGENOPT(SSE2AVX , 1, 0) ///< -msse2avx
4240
CODEGENOPT(AsmVerbose , 1, 0) ///< -dA, -fverbose-asm.
4341
CODEGENOPT(PreserveAsmComments, 1, 1) ///< -dA, -fno-preserve-as-comments.
4442
CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) operator new
@@ -194,6 +192,8 @@ CODEGENOPT(HIPSaveKernelArgName, 1, 0) ///< Set when -fhip-kernel-arg-name is en
194192
CODEGENOPT(UniqueInternalLinkageNames, 1, 0) ///< Internal Linkage symbols get unique names.
195193
CODEGENOPT(SplitMachineFunctions, 1, 0) ///< Split machine functions using profile information.
196194
CODEGENOPT(PPCUseFullRegisterNames, 1, 0) ///< Print full register names in assembly
195+
CODEGENOPT(X86RelaxRelocations, 1, 1) ///< -Wa,-mrelax-relocations={yes,no}
196+
CODEGENOPT(X86Sse2Avx , 1, 0) ///< -Wa,-msse2avx
197197

198198
/// When false, this attempts to generate code as if the result of an
199199
/// overflowing conversion matches the overflowing behavior of a target's native

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5231,7 +5231,7 @@ let Flags = [TargetSpecific] in {
52315231
def msse2avx : Flag<["-"], "msse2avx">, Group<m_Group>,
52325232
Visibility<[ClangOption, CC1Option, CC1AsOption]>,
52335233
HelpText<"Specify that the assembler should encode SSE instructions with VEX prefix">,
5234-
MarshallingInfoFlag<CodeGenOpts<"SSE2AVX">>;
5234+
MarshallingInfoFlag<CodeGenOpts<"X86Sse2Avx">>;
52355235
} // let Flags = [TargetSpecific]
52365236

52375237
defm zvector : BoolFOption<"zvector",
@@ -7133,7 +7133,7 @@ def crel : Flag<["--"], "crel">,
71337133
MarshallingInfoFlag<CodeGenOpts<"Crel">>;
71347134
def mrelax_relocations_no : Flag<["-"], "mrelax-relocations=no">,
71357135
HelpText<"Disable x86 relax relocations">,
7136-
MarshallingInfoNegativeFlag<CodeGenOpts<"RelaxELFRelocations">>;
7136+
MarshallingInfoNegativeFlag<CodeGenOpts<"X86RelaxRelocations">>;
71377137
def msave_temp_labels : Flag<["-"], "msave-temp-labels">,
71387138
HelpText<"Save temporary labels in the symbol table. "
71397139
"Note this may change .s semantics and shouldn't generally be used "

clang/lib/CodeGen/BackendUtil.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ static bool initTargetOptions(DiagnosticsEngine &Diags,
471471
Options.MCOptions.Dwarf64 = CodeGenOpts.Dwarf64;
472472
Options.MCOptions.PreserveAsmComments = CodeGenOpts.PreserveAsmComments;
473473
Options.MCOptions.Crel = CodeGenOpts.Crel;
474-
Options.MCOptions.X86RelaxRelocations = CodeGenOpts.RelaxELFRelocations;
474+
Options.MCOptions.X86RelaxRelocations = CodeGenOpts.X86RelaxRelocations;
475475
Options.MCOptions.CompressDebugSections =
476476
CodeGenOpts.getCompressDebugSections();
477477
Options.MCOptions.ABIName = TargetOpts.ABI;

clang/test/Driver/msse2avx.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// RUN: %clang -### -c -target x86_64 -march=x86-64 -Xassembler -msse2avx %s 2>&1 | FileCheck %s
2-
// RUN: %clang -### -c -target x86_64 -march=x86-64 -x assembler -Xassembler -msse2avx %s 2>&1 | FileCheck %s
1+
// RUN: %clang -### -c --target=x86_64 -march=x86-64 -Wa,-msse2avx %s 2>&1 | FileCheck %s
2+
// RUN: %clang -### -c --target=x86_64 -march=x86-64 -x assembler -Xassembler -msse2avx %s 2>&1 | FileCheck %s
33

44
// CHECK: "-msse2avx"
55

6-
// RUN: not %clang -### -c -target aarch64 -march=armv8a -msse2avx %s 2>&1 | FileCheck --check-prefix=ERR %s
7-
// ERR: error: unsupported option '-msse2avx' for target 'aarch64'
6+
// RUN: not %clang -### -c --target=aarch64 -march=armv8a -Wa,-msse2avx %s 2>&1 | FileCheck --check-prefix=ERR %s
7+
// ERR: error: unsupported argument '-msse2avx' to option '-Wa,'

clang/tools/driver/cc1as_main.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,6 @@ struct AssemblerInvocation {
9696
LLVM_PREFERRED_TYPE(bool)
9797
unsigned GenDwarfForAssembly : 1;
9898
LLVM_PREFERRED_TYPE(bool)
99-
unsigned RelaxELFRelocations : 1;
100-
LLVM_PREFERRED_TYPE(bool)
101-
unsigned SSE2AVX : 1;
102-
LLVM_PREFERRED_TYPE(bool)
10399
unsigned Dwarf64 : 1;
104100
unsigned DwarfVersion;
105101
std::string DwarfDebugFlags;
@@ -169,6 +165,11 @@ struct AssemblerInvocation {
169165
LLVM_PREFERRED_TYPE(bool)
170166
unsigned Crel : 1;
171167

168+
LLVM_PREFERRED_TYPE(bool)
169+
unsigned X86RelaxRelocations : 1;
170+
LLVM_PREFERRED_TYPE(bool)
171+
unsigned X86Sse2Avx : 1;
172+
172173
/// The name of the relocation model to use.
173174
std::string RelocationModel;
174175

@@ -199,7 +200,6 @@ struct AssemblerInvocation {
199200
ShowInst = 0;
200201
ShowEncoding = 0;
201202
RelaxAll = 0;
202-
SSE2AVX = 0;
203203
NoExecStack = 0;
204204
FatalWarnings = 0;
205205
NoWarn = 0;
@@ -211,6 +211,8 @@ struct AssemblerInvocation {
211211
EmitDwarfUnwind = EmitDwarfUnwindType::Default;
212212
EmitCompactUnwindNonCanonical = false;
213213
Crel = false;
214+
X86RelaxRelocations = 0;
215+
X86Sse2Avx = 0;
214216
}
215217

216218
static bool CreateFromArgs(AssemblerInvocation &Res,
@@ -290,8 +292,6 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
290292
.Default(llvm::DebugCompressionType::None);
291293
}
292294

293-
Opts.RelaxELFRelocations = !Args.hasArg(OPT_mrelax_relocations_no);
294-
Opts.SSE2AVX = Args.hasArg(OPT_msse2avx);
295295
if (auto *DwarfFormatArg = Args.getLastArg(OPT_gdwarf64, OPT_gdwarf32))
296296
Opts.Dwarf64 = DwarfFormatArg->getOption().matches(OPT_gdwarf64);
297297
Opts.DwarfVersion = getLastArgIntValue(Args, OPT_dwarf_version_EQ, 2, Diags);
@@ -382,6 +382,8 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
382382
Opts.EmitCompactUnwindNonCanonical =
383383
Args.hasArg(OPT_femit_compact_unwind_non_canonical);
384384
Opts.Crel = Args.hasArg(OPT_crel);
385+
Opts.X86RelaxRelocations = !Args.hasArg(OPT_mrelax_relocations_no);
386+
Opts.X86Sse2Avx = Args.hasArg(OPT_msse2avx);
385387

386388
Opts.AsSecureLogFile = Args.getLastArgValue(OPT_as_secure_log_file);
387389

@@ -440,8 +442,8 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation &Opts,
440442
MCOptions.EmitCompactUnwindNonCanonical = Opts.EmitCompactUnwindNonCanonical;
441443
MCOptions.MCSaveTempLabels = Opts.SaveTemporaryLabels;
442444
MCOptions.Crel = Opts.Crel;
443-
MCOptions.X86RelaxRelocations = Opts.RelaxELFRelocations;
444-
MCOptions.X86Sse2Avx = Opts.SSE2AVX;
445+
MCOptions.X86RelaxRelocations = Opts.X86RelaxRelocations;
446+
MCOptions.X86Sse2Avx = Opts.X86Sse2Avx;
445447
MCOptions.CompressDebugSections = Opts.CompressDebugSections;
446448
MCOptions.AsSecureLogFile = Opts.AsSecureLogFile;
447449

0 commit comments

Comments
 (0)