Skip to content

Commit 28bda77

Browse files
authored
Introduce MCAsmInfo::UsesSetToEquateSymbol and prefer = to .set
Introduce MCAsmInfo::UsesSetToEquateSymbol to control the preferred syntax for symbol equating. We now favor the more readable and common `symbol = expression` syntax over `.set`. This aligns with pre- https://reviews.llvm.org/D44256 behavior. On Apple platforms, this resolves a clang -S vs -c behavior difference (resolves #104623). For targets whose = support is unconfirmed, UsesSetToEquateSymbol is set to false. This also minimizes test updates. Pull Request: #142289
1 parent 02550da commit 28bda77

File tree

70 files changed

+263
-252
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+263
-252
lines changed

clang/test/CodeGen/alias.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,20 @@ const int wacom_usb_ids[] = {1, 1, 2, 3, 5, 8, 13, 0};
2929
extern const int __mod_usb_device_table __attribute__ ((alias("wacom_usb_ids")));
3030
// CHECKBASIC-DAG: @__mod_usb_device_table ={{.*}} alias i32, ptr @wacom_usb_ids
3131
// CHECKASM-DAG: .globl __mod_usb_device_table
32-
// CHECKASM-DAG: .set __mod_usb_device_table, wacom_usb_ids
32+
// CHECKASM-DAG: __mod_usb_device_table = wacom_usb_ids
3333
// CHECKASM-NOT: .size __mod_usb_device_table
3434

3535
extern int g1;
3636
extern int g1 __attribute((alias("g0")));
3737
// CHECKBASIC-DAG: @g1 ={{.*}} alias i32, ptr @g0
3838
// CHECKASM-DAG: .globl g1
39-
// CHECKASM-DAG: .set g1, g0
39+
// CHECKASM-DAG: g1 = g0
4040
// CHECKASM-NOT: .size g1
4141

4242
extern __thread int __libc_errno __attribute__ ((alias ("TL_WITH_ALIAS")));
4343
// CHECKBASIC-DAG: @__libc_errno ={{.*}} thread_local alias i32, ptr @TL_WITH_ALIAS
4444
// CHECKASM-DAG: .globl __libc_errno
45-
// CHECKASM-DAG: .set __libc_errno, TL_WITH_ALIAS
45+
// CHECKASM-DAG: __libc_errno = TL_WITH_ALIAS
4646
// CHECKASM-NOT: .size __libc_errno
4747

4848
void f0(void) { }

llvm/include/llvm/MC/MCAsmInfo.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@ class LLVM_ABI MCAsmInfo {
141141
/// This is appended to emitted labels. Defaults to ":"
142142
const char *LabelSuffix;
143143

144+
/// Use .set instead of = to equate a symbol to an expression.
145+
bool UsesSetToEquateSymbol = false;
146+
144147
// Print the EH begin symbol with an assignment. Defaults to false.
145148
bool UseAssignmentForEHBegin = false;
146149

@@ -525,6 +528,7 @@ class LLVM_ABI MCAsmInfo {
525528
bool shouldAllowAdditionalComments() const { return AllowAdditionalComments; }
526529
const char *getLabelSuffix() const { return LabelSuffix; }
527530

531+
bool usesSetToEquateSymbol() const { return UsesSetToEquateSymbol; }
528532
bool useAssignmentForEHBegin() const { return UseAssignmentForEHBegin; }
529533
bool needsLocalForSize() const { return NeedsLocalForSize; }
530534
StringRef getPrivateGlobalPrefix() const { return PrivateGlobalPrefix; }

llvm/lib/MC/MCAsmStreamer.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -695,9 +695,11 @@ void MCAsmStreamer::emitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
695695
if (E->inlineAssignedExpr())
696696
EmitSet = false;
697697
if (EmitSet) {
698-
OS << ".set ";
698+
bool UseSet = MAI->usesSetToEquateSymbol();
699+
if (UseSet)
700+
OS << ".set ";
699701
Symbol->print(OS, MAI);
700-
OS << ", ";
702+
OS << (UseSet ? ", " : " = ");
701703
Value->print(OS, MAI);
702704

703705
EmitEOL();

llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCAsmInfo.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ AMDGPUMCAsmInfo::AMDGPUMCAsmInfo(const Triple &TT,
4242
CommentString = ";";
4343
InlineAsmStart = ";#ASMSTART";
4444
InlineAsmEnd = ";#ASMEND";
45+
UsesSetToEquateSymbol = true;
4546

4647
//===--- Data Emission Directives -------------------------------------===//
4748
UsesELFSectionDirectiveForBSS = true;

llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCAsmInfo.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ HexagonMCAsmInfo::HexagonMCAsmInfo(const Triple &TT) {
3838
LCOMMDirectiveAlignmentType = LCOMM::ByteAlignment;
3939
InlineAsmStart = "# InlineAsm Start";
4040
InlineAsmEnd = "# InlineAsm End";
41+
UsesSetToEquateSymbol = true;
4142
ZeroDirective = "\t.space\t";
4243
AscizDirective = "\t.string\t";
4344

llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCAsmInfo.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,5 +155,7 @@ PPCXCOFFMCAsmInfo::PPCXCOFFMCAsmInfo(bool Is64Bit, const Triple &T) {
155155
// Support $ as PC in inline asm
156156
DollarIsPC = true;
157157

158+
UsesSetToEquateSymbol = true;
159+
158160
initializeVariantKinds(variantKindDescs);
159161
}

llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmInfo.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ SystemZMCAsmInfoGOFF::SystemZMCAsmInfoGOFF(const Triple &TT) {
4949
CalleeSaveStackSlotSize = 8;
5050
CodePointerSize = 8;
5151
CommentString = "*";
52+
UsesSetToEquateSymbol = true;
5253
ExceptionsType = ExceptionHandling::ZOS;
5354
IsHLASM = true;
5455
IsLittleEndian = false;

llvm/test/CodeGen/AArch64/arm64ec-alias.ll

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,30 @@ define dso_local void @patchable_func() hybrid_patchable {
1313
@patchable_alias = alias void (), ptr @patchable_func
1414

1515
; CHECK: .weak_anti_dep func_alias
16-
; CHECK-NEXT: .set func_alias, "#func_alias"
16+
; CHECK-NEXT: func_alias = "#func_alias"
1717
; CHECK-NEXT: .weak_anti_dep func_alias2
18-
; CHECK-NEXT: .set func_alias2, "#func_alias2"
18+
; CHECK-NEXT: func_alias2 = "#func_alias2"
1919
; CHECK-NEXT: .weak_anti_dep func
20-
; CHECK-NEXT: .set func, "#func"
20+
; CHECK-NEXT: func = "#func"
2121
; CHECK: .weak_anti_dep patchable_alias
22-
; CHECK-NEXT: .set patchable_alias, "#patchable_alias"
22+
; CHECK-NEXT: patchable_alias = "#patchable_alias"
2323

2424
; CHECK: .globl "#func_alias"
2525
; CHECK-NEXT: .def "#func_alias";
2626
; CHECK-NEXT: .scl 2;
2727
; CHECK-NEXT: .type 32;
2828
; CHECK-NEXT: .endef
29-
; CHECK-NEXT: .set "#func_alias", "#func"
29+
; CHECK-NEXT: "#func_alias" = "#func"
3030
; CHECK-NEXT: .globl "#func_alias2"
3131
; CHECK-NEXT: .def "#func_alias2";
3232
; CHECK-NEXT: .scl 2;
3333
; CHECK-NEXT: .type 32;
3434
; CHECK-NEXT: .endef
35-
; CHECK-NEXT: .set "#func_alias2", "#func_alias"
35+
; CHECK-NEXT: "#func_alias2" = "#func_alias"
3636

3737
; CHECK: .globl "#patchable_alias"
3838
; CHECK-NEXT: .def "#patchable_alias";
3939
; CHECK-NEXT: .scl 2;
4040
; CHECK-NEXT: .type 32;
4141
; CHECK-NEXT: .endef
42-
; CHECK-NEXT: .set "#patchable_alias", "#patchable_func"
42+
; CHECK-NEXT: "#patchable_alias" = "#patchable_func"

llvm/test/CodeGen/AArch64/arm64ec-hybrid-patchable.ll

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ define dso_local void @caller() nounwind {
7676
; CHECK-NEXT: .p2align 2
7777
; CHECK-NEXT: "#caller": // @"#caller"
7878
; CHECK-NEXT: .weak_anti_dep caller
79-
; CHECK-NEXT: .set caller, "#caller"{{$}}
79+
; CHECK-NEXT: caller = "#caller"{{$}}
8080
; CHECK-NEXT: // %bb.0:
8181
; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
8282
; CHECK-NEXT: bl "#func"
@@ -253,13 +253,13 @@ define dso_local void @caller() nounwind {
253253
; CHECK-NEXT: .type 32;
254254
; CHECK-NEXT: .endef
255255
; CHECK-NEXT: .weak func
256-
; CHECK-NEXT: .set func, "EXP+#func"{{$}}
256+
; CHECK-NEXT: func = "EXP+#func"{{$}}
257257
; CHECK-NEXT: .weak "#func"
258258
; CHECK-NEXT: .def "#func";
259259
; CHECK-NEXT: .scl 2;
260260
; CHECK-NEXT: .type 32;
261261
; CHECK-NEXT: .endef
262-
; CHECK-NEXT: .set "#func", "#func$hybpatch_thunk"{{$}}
262+
; CHECK-NEXT: "#func" = "#func$hybpatch_thunk"{{$}}
263263
; CHECK-NEXT: .def "EXP+#has_varargs";
264264
; CHECK-NEXT: .scl 2;
265265
; CHECK-NEXT: .type 32;
@@ -269,13 +269,13 @@ define dso_local void @caller() nounwind {
269269
; CHECK-NEXT: .type 32;
270270
; CHECK-NEXT: .endef
271271
; CHECK-NEXT: .weak has_varargs
272-
; CHECK-NEXT: .set has_varargs, "EXP+#has_varargs"
272+
; CHECK-NEXT: has_varargs = "EXP+#has_varargs"
273273
; CHECK-NEXT: .weak "#has_varargs"
274274
; CHECK-NEXT: .def "#has_varargs";
275275
; CHECK-NEXT: .scl 2;
276276
; CHECK-NEXT: .type 32;
277277
; CHECK-NEXT: .endef
278-
; CHECK-NEXT: .set "#has_varargs", "#has_varargs$hybpatch_thunk"
278+
; CHECK-NEXT: "#has_varargs" = "#has_varargs$hybpatch_thunk"
279279
; CHECK-NEXT: .def "EXP+#has_sret";
280280
; CHECK-NEXT: .scl 2;
281281
; CHECK-NEXT: .type 32;
@@ -285,13 +285,13 @@ define dso_local void @caller() nounwind {
285285
; CHECK-NEXT: .type 32;
286286
; CHECK-NEXT: .endef
287287
; CHECK-NEXT: .weak has_sret
288-
; CHECK-NEXT: .set has_sret, "EXP+#has_sret"
288+
; CHECK-NEXT: has_sret = "EXP+#has_sret"
289289
; CHECK-NEXT: .weak "#has_sret"
290290
; CHECK-NEXT: .def "#has_sret";
291291
; CHECK-NEXT: .scl 2;
292292
; CHECK-NEXT: .type 32;
293293
; CHECK-NEXT: .endef
294-
; CHECK-NEXT: .set "#has_sret", "#has_sret$hybpatch_thunk"
294+
; CHECK-NEXT: "#has_sret" = "#has_sret$hybpatch_thunk"
295295
; CHECK-NEXT: .def "EXP+#exp";
296296
; CHECK-NEXT: .scl 2;
297297
; CHECK-NEXT: .type 32;
@@ -301,13 +301,13 @@ define dso_local void @caller() nounwind {
301301
; CHECK-NEXT: .type 32;
302302
; CHECK-NEXT: .endef
303303
; CHECK-NEXT: .weak exp
304-
; CHECK-NEXT: .set exp, "EXP+#exp"
304+
; CHECK-NEXT: exp = "EXP+#exp"
305305
; CHECK-NEXT: .weak "#exp"
306306
; CHECK-NEXT: .def "#exp";
307307
; CHECK-NEXT: .scl 2;
308308
; CHECK-NEXT: .type 32;
309309
; CHECK-NEXT: .endef
310-
; CHECK-NEXT: .set "#exp", "#exp$hybpatch_thunk"
310+
; CHECK-NEXT: "#exp" = "#exp$hybpatch_thunk"
311311

312312
; SYM: [53](sec 15)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 #func$hybpatch_thunk
313313
; SYM: [58](sec 16)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 #has_varargs$hybpatch_thunk

llvm/test/CodeGen/AArch64/arm64ec-symbols.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ define void @caller() nounwind {
1010
}
1111

1212
; CHECK: .weak_anti_dep caller
13-
; CHECK-NEXT: .set caller, "#caller"{{$}}
13+
; CHECK-NEXT: caller = "#caller"{{$}}
1414

1515
; CHECK: .weak_anti_dep func
16-
; CHECK-NEXT: .set func, "#func"{{$}}
16+
; CHECK-NEXT: func = "#func"{{$}}
1717
; CHECK-NEXT: .weak_anti_dep "#func"
18-
; CHECK-NEXT: .set "#func", "#func$exit_thunk"{{$}}
18+
; CHECK-NEXT: "#func" = "#func$exit_thunk"{{$}}
1919

2020
; SYM: [ 8](sec 4)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 #caller
2121
; SYM: [21](sec 7)(fl 0x00)(ty 20)(scl 2) (nx 0) 0x00000000 #func$exit_thunk

0 commit comments

Comments
 (0)