Skip to content

Commit c02c405

Browse files
andykaylorAnthony Tran
authored andcommitted
[CIR] Restore the underscore in dso_local (llvm#145551)
The CIR handling of `dso_local` for globals was upstreamed without the underscore, making it inconsistent with the incubator and LLVM IR. This change restores the underscore.
1 parent 0382b23 commit c02c405

File tree

12 files changed

+29
-29
lines changed

12 files changed

+29
-29
lines changed

clang/include/clang/CIR/Dialect/IR/CIROps.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,15 +1610,15 @@ def GlobalOp : CIR_Op<"global",
16101610
CIR_GlobalLinkageKind:$linkage,
16111611
OptionalAttr<AnyAttr>:$initial_value,
16121612
UnitAttr:$comdat,
1613-
UnitAttr:$dsolocal,
1613+
UnitAttr:$dso_local,
16141614
OptionalAttr<I64Attr>:$alignment);
16151615

16161616
let assemblyFormat = [{
16171617
($sym_visibility^)?
16181618
(`` $global_visibility^)?
16191619
$linkage
16201620
(`comdat` $comdat^)?
1621-
(`dsolocal` $dsolocal^)?
1621+
(`dso_local` $dso_local^)?
16221622
$sym_name
16231623
custom<GlobalOpTypeAndInitialValue>($sym_type, $initial_value)
16241624
attr-dict

clang/include/clang/CIR/Interfaces/CIROpInterfaces.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,13 @@ let cppNamespace = "::cir" in {
138138
InterfaceMethod<"",
139139
"void", "setDSOLocal", (ins "bool":$val), [{}],
140140
/*defaultImplementation=*/[{
141-
$_op.setDsolocal(val);
141+
$_op.setDsoLocal(val);
142142
}]
143143
>,
144144
InterfaceMethod<"",
145145
"bool", "isDSOLocal", (ins), [{}],
146146
/*defaultImplementation=*/[{
147-
return $_op.getDsolocal();
147+
return $_op.getDsoLocal();
148148
}]
149149
>,
150150
InterfaceMethod<"",

clang/include/clang/CIR/MissingFeatures.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ struct MissingFeatures {
7474
static bool opFuncOpenCLKernelMetadata() { return false; }
7575
static bool opFuncCallingConv() { return false; }
7676
static bool opFuncExtraAttrs() { return false; }
77-
static bool opFuncDsolocal() { return false; }
77+
static bool opFuncDsoLocal() { return false; }
7878
static bool opFuncLinkage() { return false; }
7979
static bool opFuncVisibility() { return false; }
8080
static bool opFuncNoProto() { return false; }

clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,7 +1032,7 @@ mlir::LogicalResult CIRToLLVMFuncOpLowering::matchAndRewrite(
10321032
mlir::ConversionPatternRewriter &rewriter) const {
10331033

10341034
cir::FuncType fnType = op.getFunctionType();
1035-
assert(!cir::MissingFeatures::opFuncDsolocal());
1035+
assert(!cir::MissingFeatures::opFuncDsoLocal());
10361036
bool isDsoLocal = false;
10371037
mlir::TypeConverter::SignatureConversion signatureConversion(
10381038
fnType.getNumInputs());
@@ -1119,7 +1119,7 @@ void CIRToLLVMGlobalOpLowering::setupRegionInitializedLLVMGlobalOp(
11191119
const bool isConst = false;
11201120
assert(!cir::MissingFeatures::addressSpace());
11211121
const unsigned addrSpace = 0;
1122-
const bool isDsoLocal = op.getDsolocal();
1122+
const bool isDsoLocal = op.getDsoLocal();
11231123
assert(!cir::MissingFeatures::opGlobalThreadLocal());
11241124
const bool isThreadLocal = false;
11251125
const uint64_t alignment = op.getAlignment().value_or(0);
@@ -1173,7 +1173,7 @@ mlir::LogicalResult CIRToLLVMGlobalOpLowering::matchAndRewrite(
11731173
const bool isConst = false;
11741174
assert(!cir::MissingFeatures::addressSpace());
11751175
const unsigned addrSpace = 0;
1176-
const bool isDsoLocal = op.getDsolocal();
1176+
const bool isDsoLocal = op.getDsoLocal();
11771177
assert(!cir::MissingFeatures::opGlobalThreadLocal());
11781178
const bool isThreadLocal = false;
11791179
const uint64_t alignment = op.getAlignment().value_or(0);

clang/test/CIR/CodeGen/builtin_printf.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux-gnu -Wno-unused-value -emit-llvm %s -o %t.ll
66
// RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG
77

8-
// CIR: cir.global "private" cir_private dsolocal @".str" = #cir.const_array<"%s\00" : !cir.array<!s8i x 3>> : !cir.array<!s8i x 3>
9-
// CIR: cir.global "private" cir_private dsolocal @".str.1" = #cir.const_array<"%s %d\0A\00" : !cir.array<!s8i x 7>> : !cir.array<!s8i x 7>
8+
// CIR: cir.global "private" cir_private dso_local @".str" = #cir.const_array<"%s\00" : !cir.array<!s8i x 3>> : !cir.array<!s8i x 3>
9+
// CIR: cir.global "private" cir_private dso_local @".str.1" = #cir.const_array<"%s %d\0A\00" : !cir.array<!s8i x 7>> : !cir.array<!s8i x 7>
1010
// LLVM: @.str = private global [3 x i8] c"%s\00"
1111
// LLVM: @.str.1 = private global [7 x i8] c"%s %d\0A\00"
1212
// OGCG: @.str = private unnamed_addr constant [3 x i8] c"%s\00"

clang/test/CIR/CodeGen/deferred-defs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ void use() {
1818
}
1919

2020
// CIR: cir.global external @locallyDefined = #cir.int<0> : !s32i
21-
// CIR: cir.global "private" internal dsolocal @_ZN12_GLOBAL__N_112usedInternalE = #cir.int<0> : !s32i
21+
// CIR: cir.global "private" internal dso_local @_ZN12_GLOBAL__N_112usedInternalE = #cir.int<0> : !s32i
2222
// CIR: cir.global "private" external @usedExternal : !s32i

clang/test/CIR/CodeGen/namespace.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace test {
2020
}
2121
}
2222

23-
// CHECK-DAG: cir.global "private" internal dsolocal @_ZN12_GLOBAL__N_12g1E = #cir.int<1> : !s32i
23+
// CHECK-DAG: cir.global "private" internal dso_local @_ZN12_GLOBAL__N_12g1E = #cir.int<1> : !s32i
2424
// CHECK-DAG: cir.global external @_ZN4test2g2E = #cir.int<2> : !s32i
2525
// CHECK-DAG: cir.global external @_ZN4test5test22g3E = #cir.int<3> : !s32i
2626
// CHECK-DAG: cir.func @_ZN12_GLOBAL__N_12f1Ev()

clang/test/CIR/CodeGen/static-vars.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44
void func1(void) {
55
// Should lower default-initialized static vars.
66
static int i;
7-
// CHECK-DAG: cir.global "private" internal dsolocal @func1.i = #cir.int<0> : !s32i
7+
// CHECK-DAG: cir.global "private" internal dso_local @func1.i = #cir.int<0> : !s32i
88

99
// Should lower constant-initialized static vars.
1010
static int j = 1;
11-
// CHECK-DAG: cir.global "private" internal dsolocal @func1.j = #cir.int<1> : !s32i
11+
// CHECK-DAG: cir.global "private" internal dso_local @func1.j = #cir.int<1> : !s32i
1212

1313
// Should properly shadow static vars in nested scopes.
1414
{
1515
static int j = 2;
16-
// CHECK-DAG: cir.global "private" internal dsolocal @func1.j.1 = #cir.int<2> : !s32i
16+
// CHECK-DAG: cir.global "private" internal dso_local @func1.j.1 = #cir.int<2> : !s32i
1717
}
1818
{
1919
static int j = 3;
20-
// CHECK-DAG: cir.global "private" internal dsolocal @func1.j.2 = #cir.int<3> : !s32i
20+
// CHECK-DAG: cir.global "private" internal dso_local @func1.j.2 = #cir.int<3> : !s32i
2121
}
2222

2323
// Should lower basic static vars arithmetics.
@@ -31,7 +31,7 @@ void func1(void) {
3131
// Should shadow static vars on different functions.
3232
void func2(void) {
3333
static char i;
34-
// CHECK-DAG: cir.global "private" internal dsolocal @func2.i = #cir.int<0> : !s8i
34+
// CHECK-DAG: cir.global "private" internal dso_local @func2.i = #cir.int<0> : !s8i
3535
static float j;
36-
// CHECK-DAG: cir.global "private" internal dsolocal @func2.j = #cir.fp<0.000000e+00> : !cir.float
36+
// CHECK-DAG: cir.global "private" internal dso_local @func2.j = #cir.fp<0.000000e+00> : !cir.float
3737
}

clang/test/CIR/CodeGen/static-vars.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@
66
void func1(void) {
77
// Should lower default-initialized static vars.
88
static int i;
9-
// CHECK-DAG: cir.global "private" internal dsolocal @_ZZ5func1vE1i = #cir.int<0> : !s32i
9+
// CHECK-DAG: cir.global "private" internal dso_local @_ZZ5func1vE1i = #cir.int<0> : !s32i
1010

1111
// Should lower constant-initialized static vars.
1212
static int j = 1;
13-
// CHECK-DAG: cir.global "private" internal dsolocal @_ZZ5func1vE1j = #cir.int<1> : !s32i
13+
// CHECK-DAG: cir.global "private" internal dso_local @_ZZ5func1vE1j = #cir.int<1> : !s32i
1414

1515
// Should properly shadow static vars in nested scopes.
1616
{
1717
static int j = 2;
18-
// CHECK-DAG: cir.global "private" internal dsolocal @_ZZ5func1vE1j_0 = #cir.int<2> : !s32i
18+
// CHECK-DAG: cir.global "private" internal dso_local @_ZZ5func1vE1j_0 = #cir.int<2> : !s32i
1919
}
2020
{
2121
static int j = 3;
22-
// CHECK-DAG: cir.global "private" internal dsolocal @_ZZ5func1vE1j_1 = #cir.int<3> : !s32i
22+
// CHECK-DAG: cir.global "private" internal dso_local @_ZZ5func1vE1j_1 = #cir.int<3> : !s32i
2323
}
2424

2525
// Should lower basic static vars arithmetics.
@@ -33,9 +33,9 @@ void func1(void) {
3333
// Should shadow static vars on different functions.
3434
void func2(void) {
3535
static char i;
36-
// CHECK-DAG: cir.global "private" internal dsolocal @_ZZ5func2vE1i = #cir.int<0> : !s8i
36+
// CHECK-DAG: cir.global "private" internal dso_local @_ZZ5func2vE1i = #cir.int<0> : !s8i
3737
static float j;
38-
// CHECK-DAG: cir.global "private" internal dsolocal @_ZZ5func2vE1j = #cir.fp<0.000000e+00> : !cir.float
38+
// CHECK-DAG: cir.global "private" internal dso_local @_ZZ5func2vE1j = #cir.fp<0.000000e+00> : !cir.float
3939
}
4040

4141
// CHECK-DAG: cir.global linkonce_odr comdat @_ZZ4testvE1c = #cir.int<0> : !s32i

clang/test/CIR/CodeGen/string-literals.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ char g_exact[4] = "123";
1717

1818
// CIR: cir.global external @g_exact = #cir.const_array<"123\00" : !cir.array<!s8i x 4>> : !cir.array<!s8i x 4>
1919

20-
// CIR: cir.global "private" cir_private dsolocal @[[STR1_GLOBAL:.*]] = #cir.const_array<"1\00" : !cir.array<!s8i x 2>> : !cir.array<!s8i x 2>
21-
// CIR: cir.global "private" cir_private dsolocal @[[STR2_GLOBAL:.*]] = #cir.zero : !cir.array<!s8i x 1>
22-
// CIR: cir.global "private" cir_private dsolocal @[[STR3_GLOBAL:.*]] = #cir.zero : !cir.array<!s8i x 2>
20+
// CIR: cir.global "private" cir_private dso_local @[[STR1_GLOBAL:.*]] = #cir.const_array<"1\00" : !cir.array<!s8i x 2>> : !cir.array<!s8i x 2>
21+
// CIR: cir.global "private" cir_private dso_local @[[STR2_GLOBAL:.*]] = #cir.zero : !cir.array<!s8i x 1>
22+
// CIR: cir.global "private" cir_private dso_local @[[STR3_GLOBAL:.*]] = #cir.zero : !cir.array<!s8i x 2>
2323

2424
// LLVM: @[[STR1_GLOBAL:.*]] = private global [2 x i8] c"1\00"
2525
// LLVM: @[[STR2_GLOBAL:.*]] = private global [1 x i8] zeroinitializer

clang/test/CIR/CodeGen/string-literals.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// RUN: %clang_cc1 -triple aarch64-none-linux-android21 -emit-llvm %s -o %t.ll
66
// RUN: FileCheck --check-prefix=OGCG --input-file=%t.ll %s
77

8-
// CIR: cir.global "private" cir_private dsolocal @[[STR1_GLOBAL:.*]] = #cir.const_array<"abcd\00" : !cir.array<!s8i x 5>> : !cir.array<!s8i x 5>
8+
// CIR: cir.global "private" cir_private dso_local @[[STR1_GLOBAL:.*]] = #cir.const_array<"abcd\00" : !cir.array<!s8i x 5>> : !cir.array<!s8i x 5>
99

1010
// LLVM: @[[STR1_GLOBAL:.*]] = private global [5 x i8] c"abcd\00"
1111

clang/test/CIR/global-var-linkage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ int aaaa;
1717
// OGCG: @dddd = weak_odr global i32 0, comdat
1818

1919
static int bbbb;
20-
// CIR: cir.global "private" internal dsolocal @_ZL4bbbb
20+
// CIR: cir.global "private" internal dso_local @_ZL4bbbb
2121
// LLVM: @_ZL4bbbb = internal global i32 0
2222
// OGCG: @_ZL4bbbb = internal global i32 0
2323

0 commit comments

Comments
 (0)