Skip to content

Commit 56b1d42

Browse files
authored
[CIR] Mark globals as constants (#168463)
We previously added support for marking GlobalOp operations as constant, but the handling to actually do so was left mostly unimplemented. This fills in the missing pieces.
1 parent e1bb50b commit 56b1d42

File tree

8 files changed

+77
-52
lines changed

8 files changed

+77
-52
lines changed

clang/include/clang/CIR/MissingFeatures.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ struct MissingFeatures {
2929

3030
// Unhandled global/linkage information.
3131
static bool opGlobalThreadLocal() { return false; }
32-
static bool opGlobalConstant() { return false; }
3332
static bool opGlobalWeakRef() { return false; }
3433
static bool opGlobalUnnamedAddr() { return false; }
3534
static bool opGlobalSection() { return false; }

clang/lib/CIR/CodeGen/CIRGenDecl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,8 @@ cir::GlobalOp CIRGenFunction::addInitializerToStaticVarDecl(
526526
bool needsDtor =
527527
d.needsDestruction(getContext()) == QualType::DK_cxx_destructor;
528528

529-
assert(!cir::MissingFeatures::opGlobalConstant());
529+
gv.setConstant(d.getType().isConstantStorage(
530+
getContext(), /*ExcludeCtor=*/true, !needsDtor));
530531
gv.setInitialValueAttr(init);
531532

532533
emitter.finalize(gv);

clang/lib/CIR/CodeGen/CIRGenModule.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,10 @@ CIRGenModule::getOrCreateCIRGlobal(StringRef mangledName, mlir::Type ty,
675675
errorNYI(d->getSourceRange(), "OpenMP target global variable");
676676

677677
gv.setAlignmentAttr(getSize(astContext.getDeclAlign(d)));
678-
assert(!cir::MissingFeatures::opGlobalConstant());
678+
// FIXME: This code is overly simple and should be merged with other global
679+
// handling.
680+
gv.setConstant(d->getType().isConstantStorage(
681+
astContext, /*ExcludeCtor=*/false, /*ExcludeDtor=*/false));
679682

680683
setLinkageForGV(gv, d);
681684

@@ -864,7 +867,11 @@ void CIRGenModule::emitGlobalVarDefinition(const clang::VarDecl *vd,
864867
if (emitter)
865868
emitter->finalize(gv);
866869

867-
assert(!cir::MissingFeatures::opGlobalConstant());
870+
// If it is safe to mark the global 'constant', do so now.
871+
gv.setConstant((vd->hasAttr<CUDAConstantAttr>() && langOpts.CUDAIsDevice) ||
872+
(!needsGlobalCtor && !needsGlobalDtor &&
873+
vd->getType().isConstantStorage(
874+
astContext, /*ExcludeCtor=*/true, /*ExcludeDtor=*/true)));
868875
assert(!cir::MissingFeatures::opGlobalSection());
869876

870877
// Set CIR's linkage type as appropriate.

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1995,7 +1995,6 @@ void CIRToLLVMGlobalOpLowering::setupRegionInitializedLLVMGlobalOp(
19951995
// attributes are available on cir.global ops. This duplicates code
19961996
// in CIRToLLVMGlobalOpLowering::matchAndRewrite() but that will go
19971997
// away when the placeholders are no longer needed.
1998-
assert(!cir::MissingFeatures::opGlobalConstant());
19991998
const bool isConst = op.getConstant();
20001999
assert(!cir::MissingFeatures::addressSpace());
20012000
const unsigned addrSpace = 0;
@@ -2055,8 +2054,7 @@ mlir::LogicalResult CIRToLLVMGlobalOpLowering::matchAndRewrite(
20552054
convertTypeForMemory(*getTypeConverter(), dataLayout, cirSymType);
20562055
// FIXME: These default values are placeholders until the the equivalent
20572056
// attributes are available on cir.global ops.
2058-
assert(!cir::MissingFeatures::opGlobalConstant());
2059-
const bool isConst = false;
2057+
const bool isConst = op.getConstant();
20602058
assert(!cir::MissingFeatures::addressSpace());
20612059
const unsigned addrSpace = 0;
20622060
const bool isDsoLocal = op.getDsoLocal();

clang/test/CIR/CodeGen/constant-inits.cpp

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -105,79 +105,79 @@ void function() {
105105
// CIR-DAG: !rec_anon_struct = !cir.record<struct {!u8i, !u8i, !u8i, !u8i}>
106106
// CIR-DAG: !rec_anon_struct1 = !cir.record<struct {!u8i, !u8i, !cir.array<!u8i x 2>}>
107107

108-
// CIR-DAG: cir.global "private" internal dso_local @_ZZ8functionvE1e = #cir.zero : !rec_empty
109-
// CIR-DAG: cir.global "private" internal dso_local @_ZZ8functionvE1s = #cir.const_record<{#cir.int<0> : !s32i, #cir.int<-1> : !s32i}> : !rec_simple
110-
// CIR-DAG: cir.global "private" internal dso_local @_ZZ8functionvE2p1 = #cir.const_record<{#cir.int<10> : !s32i, #cir.int<20> : !s32i, #cir.const_array<[#cir.int<99> : !s8i, #cir.int<88> : !s8i, #cir.int<77> : !s8i]> : !cir.array<!s8i x 3>, #cir.int<40> : !s32i}> : !rec_Point
111-
// CIR-DAG: cir.global "private" internal dso_local @_ZZ8functionvE2p2 = #cir.const_record<{#cir.int<123> : !s8i, #cir.int<456> : !s32i}> : !rec_packed
112-
// CIR-DAG: cir.global "private" internal dso_local @_ZZ8functionvE3paa = #cir.const_record<{#cir.int<1> : !s16i, #cir.int<2> : !s8i, #cir.fp<3.000000e+00> : !cir.float, #cir.zero : !u8i}> : !rec_packed_and_aligned
108+
// CIR-DAG: cir.global "private" constant internal dso_local @_ZZ8functionvE1e = #cir.zero : !rec_empty
109+
// CIR-DAG: cir.global "private" constant internal dso_local @_ZZ8functionvE1s = #cir.const_record<{#cir.int<0> : !s32i, #cir.int<-1> : !s32i}> : !rec_simple
110+
// CIR-DAG: cir.global "private" constant internal dso_local @_ZZ8functionvE2p1 = #cir.const_record<{#cir.int<10> : !s32i, #cir.int<20> : !s32i, #cir.const_array<[#cir.int<99> : !s8i, #cir.int<88> : !s8i, #cir.int<77> : !s8i]> : !cir.array<!s8i x 3>, #cir.int<40> : !s32i}> : !rec_Point
111+
// CIR-DAG: cir.global "private" constant internal dso_local @_ZZ8functionvE2p2 = #cir.const_record<{#cir.int<123> : !s8i, #cir.int<456> : !s32i}> : !rec_packed
112+
// CIR-DAG: cir.global "private" constant internal dso_local @_ZZ8functionvE3paa = #cir.const_record<{#cir.int<1> : !s16i, #cir.int<2> : !s8i, #cir.fp<3.000000e+00> : !cir.float, #cir.zero : !u8i}> : !rec_packed_and_aligned
113113

114-
// CIR-DAG: cir.global "private" internal dso_local @_ZZ8functionvE5array = #cir.const_array<[
114+
// CIR-DAG: cir.global "private" constant internal dso_local @_ZZ8functionvE5array = #cir.const_array<[
115115
// CIR-DAG-SAME: #cir.const_record<{#cir.int<123> : !s32i, #cir.int<456> : !s32i, #cir.const_array<[#cir.int<11> : !s8i, #cir.int<22> : !s8i, #cir.int<33> : !s8i]> : !cir.array<!s8i x 3>, #cir.int<789> : !s32i}> : !rec_Point
116116
// CIR-DAG-SAME: #cir.const_record<{#cir.int<10> : !s32i, #cir.int<20> : !s32i, #cir.zero : !cir.array<!s8i x 3>, #cir.int<40> : !s32i}> : !rec_Point
117117
// CIR-DAG-SAME: ]> : !cir.array<!rec_Point x 2>
118118

119-
// CIR-DAG: cir.global "private" internal dso_local @_ZZ8functionvE12simple_array = #cir.const_array<[
119+
// CIR-DAG: cir.global "private" constant internal dso_local @_ZZ8functionvE12simple_array = #cir.const_array<[
120120
// CIR-DAG-SAME: #cir.const_record<{#cir.int<0> : !s32i, #cir.int<-1> : !s32i}> : !rec_simple,
121121
// CIR-DAG-SAME: #cir.const_record<{#cir.int<1111> : !s32i, #cir.int<2222> : !s32i}> : !rec_simple,
122122
// CIR-DAG-SAME: #cir.const_record<{#cir.int<0> : !s32i, #cir.int<-1> : !s32i}> : !rec_simple
123123
// CIR-DAG-SAME: ]> : !cir.array<!rec_simple x 3>
124124

125-
// CIR-DAG: cir.global "private" internal dso_local @_ZZ8functionvE12packed_array = #cir.const_array<[
125+
// CIR-DAG: cir.global "private" constant internal dso_local @_ZZ8functionvE12packed_array = #cir.const_array<[
126126
// CIR-DAG-SAME: #cir.const_record<{#cir.int<123> : !s8i, #cir.int<456> : !s32i}> : !rec_packed,
127127
// CIR-DAG-SAME: #cir.const_record<{#cir.int<123> : !s8i, #cir.int<456> : !s32i}> : !rec_packed
128128
// CIR-DAG-SAME: ]> : !cir.array<!rec_packed x 2>
129129

130-
// CIR-DAG: cir.global "private" internal dso_local @_ZZ8functionvE9paa_array = #cir.const_array<[
130+
// CIR-DAG: cir.global "private" constant internal dso_local @_ZZ8functionvE9paa_array = #cir.const_array<[
131131
// CIR-DAG-SAME: #cir.const_record<{#cir.int<1> : !s16i, #cir.int<2> : !s8i, #cir.fp<3.000000e+00> : !cir.float, #cir.zero : !u8i}> : !rec_packed_and_aligned,
132132
// CIR-DAG-SAME: #cir.zero : !rec_packed_and_aligned
133133
// CIR-DAG-SAME: ]> : !cir.array<!rec_packed_and_aligned x 2>
134134

135-
// CIR-DAG: cir.global "private" internal dso_local @_ZZ8functionvE6ba_bf1 = #cir.const_record<{
135+
// CIR-DAG: cir.global "private" constant internal dso_local @_ZZ8functionvE6ba_bf1 = #cir.const_record<{
136136
// CIR-DAG-SAME: #cir.int<255> : !u8i,
137137
// CIR-DAG-SAME: #cir.int<170> : !u8i,
138138
// CIR-DAG-SAME: #cir.int<52> : !u8i,
139139
// CIR-DAG-SAME: #cir.int<18> : !u8i
140140
// CIR-DAG-SAME: }> : !rec_anon_struct
141-
// CIR-DAG: cir.global "private" internal dso_local @_ZZ8functionvE6ba_bf2 = #cir.const_record<{
141+
// CIR-DAG: cir.global "private" constant internal dso_local @_ZZ8functionvE6ba_bf2 = #cir.const_record<{
142142
// CIR-DAG-SAME: #cir.int<255> : !u8i,
143143
// CIR-DAG-SAME: #cir.int<127> : !u8i,
144144
// CIR-DAG-SAME: #cir.const_array<[#cir.zero : !u8i, #cir.zero : !u8i]> : !cir.array<!u8i x 2>
145145
// CIR-DAG-SAME: }> : !rec_anon_struct1
146-
// CIR-DAG: cir.global "private" internal dso_local @_ZZ8functionvE6ba_bf3 = #cir.const_record<{
146+
// CIR-DAG: cir.global "private" constant internal dso_local @_ZZ8functionvE6ba_bf3 = #cir.const_record<{
147147
// CIR-DAG-SAME: #cir.int<42> : !u8i
148148
// CIR-DAG-SAME: }> : !rec_single_byte_bitfield
149-
// CIR-DAG: cir.global "private" internal dso_local @_ZZ8functionvE5p_bf1 = #cir.const_record<{
149+
// CIR-DAG: cir.global "private" constant internal dso_local @_ZZ8functionvE5p_bf1 = #cir.const_record<{
150150
// CIR-DAG-SAME: #cir.int<17> : !u8i,
151151
// CIR-DAG-SAME: #cir.int<3> : !u8i,
152152
// CIR-DAG-SAME: #cir.const_array<[#cir.zero : !u8i, #cir.zero : !u8i]> : !cir.array<!u8i x 2>
153153
// CIR-DAG-SAME: }> : !rec_anon_struct1
154-
// CIR-DAG: cir.global "private" internal dso_local @_ZZ8functionvE5p_bf2 = #cir.const_record<{
154+
// CIR-DAG: cir.global "private" constant internal dso_local @_ZZ8functionvE5p_bf2 = #cir.const_record<{
155155
// CIR-DAG-SAME: #cir.int<127> : !u8i,
156156
// CIR-DAG-SAME: #cir.const_array<[#cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i]> : !cir.array<!u8i x 3>
157157
// CIR-DAG-SAME: }> : !rec_signed_partial_bitfields
158-
// CIR-DAG: cir.global "private" internal dso_local @_ZZ8functionvE5p_bf3 = #cir.const_record<{
158+
// CIR-DAG: cir.global "private" constant internal dso_local @_ZZ8functionvE5p_bf3 = #cir.const_record<{
159159
// CIR-DAG-SAME: #cir.int<125> : !u8i
160160
// CIR-DAG-SAME: }> : !rec_mixed_partial_bitfields
161161

162162
// CIR-LABEL: cir.func dso_local @_Z8functionv()
163163
// CIR: cir.return
164164

165165

166-
// LLVM-DAG: @_ZZ8functionvE12packed_array = internal global [2 x %struct.packed] [%struct.packed <{ i8 123, i32 456 }>, %struct.packed <{ i8 123, i32 456 }>]
167-
// LLVM-DAG: @_ZZ8functionvE12simple_array = internal global [3 x %struct.simple] [%struct.simple { i32 0, i32 -1 }, %struct.simple { i32 1111, i32 2222 }, %struct.simple { i32 0, i32 -1 }]
168-
// LLVM-DAG: @_ZZ8functionvE1e = internal global %struct.empty zeroinitializer
169-
// LLVM-DAG: @_ZZ8functionvE1s = internal global %struct.simple { i32 0, i32 -1 }
170-
// LLVM-DAG: @_ZZ8functionvE2p1 = internal global %struct.Point { i32 10, i32 20, [3 x i8] c"cXM", i32 40 }
171-
// LLVM-DAG: @_ZZ8functionvE2p2 = internal global %struct.packed <{ i8 123, i32 456 }>
172-
// LLVM-DAG: @_ZZ8functionvE3paa = internal global %struct.packed_and_aligned <{ i16 1, i8 2, float 3.000000e+00, i8 0 }>
173-
// LLVM-DAG: @_ZZ8functionvE5array = internal global [2 x %struct.Point] [%struct.Point { i32 123, i32 456, [3 x i8] c"\0B\16!", i32 789 }, %struct.Point { i32 10, i32 20, [3 x i8] zeroinitializer, i32 40 }]
174-
// LLVM-DAG: @_ZZ8functionvE9paa_array = internal global [2 x %struct.packed_and_aligned] [%struct.packed_and_aligned <{ i16 1, i8 2, float 3.000000e+00, i8 0 }>, %struct.packed_and_aligned zeroinitializer]
175-
// LLVM-DAG: @_ZZ8functionvE6ba_bf1 = internal global { i8, i8, i8, i8 } { i8 -1, i8 -86, i8 52, i8 18 }
176-
// LLVM-DAG: @_ZZ8functionvE6ba_bf2 = internal global { i8, i8, [2 x i8] } { i8 -1, i8 127, [2 x i8] zeroinitializer }
177-
// LLVM-DAG: @_ZZ8functionvE6ba_bf3 = internal global %struct.single_byte_bitfield { i8 42 }
178-
// LLVM-DAG: @_ZZ8functionvE5p_bf1 = internal global { i8, i8, [2 x i8] } { i8 17, i8 3, [2 x i8] zeroinitializer }
179-
// LLVM-DAG: @_ZZ8functionvE5p_bf2 = internal global %struct.signed_partial_bitfields { i8 127, [3 x i8] zeroinitializer }
180-
// LLVM-DAG: @_ZZ8functionvE5p_bf3 = internal global %struct.mixed_partial_bitfields { i8 125 }
166+
// LLVM-DAG: @_ZZ8functionvE12packed_array = internal constant [2 x %struct.packed] [%struct.packed <{ i8 123, i32 456 }>, %struct.packed <{ i8 123, i32 456 }>]
167+
// LLVM-DAG: @_ZZ8functionvE12simple_array = internal constant [3 x %struct.simple] [%struct.simple { i32 0, i32 -1 }, %struct.simple { i32 1111, i32 2222 }, %struct.simple { i32 0, i32 -1 }]
168+
// LLVM-DAG: @_ZZ8functionvE1e = internal constant %struct.empty zeroinitializer
169+
// LLVM-DAG: @_ZZ8functionvE1s = internal constant %struct.simple { i32 0, i32 -1 }
170+
// LLVM-DAG: @_ZZ8functionvE2p1 = internal constant %struct.Point { i32 10, i32 20, [3 x i8] c"cXM", i32 40 }
171+
// LLVM-DAG: @_ZZ8functionvE2p2 = internal constant %struct.packed <{ i8 123, i32 456 }>
172+
// LLVM-DAG: @_ZZ8functionvE3paa = internal constant %struct.packed_and_aligned <{ i16 1, i8 2, float 3.000000e+00, i8 0 }>
173+
// LLVM-DAG: @_ZZ8functionvE5array = internal constant [2 x %struct.Point] [%struct.Point { i32 123, i32 456, [3 x i8] c"\0B\16!", i32 789 }, %struct.Point { i32 10, i32 20, [3 x i8] zeroinitializer, i32 40 }]
174+
// LLVM-DAG: @_ZZ8functionvE9paa_array = internal constant [2 x %struct.packed_and_aligned] [%struct.packed_and_aligned <{ i16 1, i8 2, float 3.000000e+00, i8 0 }>, %struct.packed_and_aligned zeroinitializer]
175+
// LLVM-DAG: @_ZZ8functionvE6ba_bf1 = internal constant { i8, i8, i8, i8 } { i8 -1, i8 -86, i8 52, i8 18 }
176+
// LLVM-DAG: @_ZZ8functionvE6ba_bf2 = internal constant { i8, i8, [2 x i8] } { i8 -1, i8 127, [2 x i8] zeroinitializer }
177+
// LLVM-DAG: @_ZZ8functionvE6ba_bf3 = internal constant %struct.single_byte_bitfield { i8 42 }
178+
// LLVM-DAG: @_ZZ8functionvE5p_bf1 = internal constant { i8, i8, [2 x i8] } { i8 17, i8 3, [2 x i8] zeroinitializer }
179+
// LLVM-DAG: @_ZZ8functionvE5p_bf2 = internal constant %struct.signed_partial_bitfields { i8 127, [3 x i8] zeroinitializer }
180+
// LLVM-DAG: @_ZZ8functionvE5p_bf3 = internal constant %struct.mixed_partial_bitfields { i8 125 }
181181

182182
// LLVM-LABEL: define{{.*}} void @_Z8functionv
183183
// LLVM: ret void
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
2+
// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
3+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t-cir.ll
4+
// RUN: FileCheck --check-prefix=LLVM --input-file=%t-cir.ll %s
5+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll
6+
// RUN: FileCheck --check-prefix=OGCG --input-file=%t.ll %s
7+
8+
const int global_no_use = 12;
9+
// CIR: cir.global constant {{.*}}@global_no_use
10+
// LLVM: @global_no_use = constant
11+
// OGCG: @global_no_use = constant
12+
13+
const float global_used = 1.2f;
14+
// CIR: cir.global constant {{.*}}@global_used
15+
// LLVM: @global_used = constant
16+
// OGCG: @global_used = constant
17+
18+
float const * get_float_ptr() {
19+
return &global_used;
20+
}

clang/test/CIR/CodeGen/record-zero-init-padding.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,28 +41,28 @@ void test_zero_init_padding(void) {
4141
// CIR-DAG: !rec_anon_struct3 = !cir.record<struct {!s8i, !cir.array<!u8i x 3>, !s32i}>
4242

4343
// paf: char + 3 bytes padding + int -> uses !rec_anon_struct3
44-
// CIR-DAG: cir.global "private" internal dso_local @test_zero_init_padding.paf = #cir.const_record<{
44+
// CIR-DAG: cir.global "private" constant internal dso_local @test_zero_init_padding.paf = #cir.const_record<{
4545
// CIR-DAG-SAME: #cir.int<1> : !s8i,
4646
// CIR-DAG-SAME: #cir.const_array<[#cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i]> : !cir.array<!u8i x 3>,
4747
// CIR-DAG-SAME: #cir.int<42> : !s32i
4848
// CIR-DAG-SAME: }> : !rec_anon_struct3
4949

5050
// bfp: unsigned bitfield byte + 3 bytes padding + int -> uses !rec_anon_struct2
51-
// CIR-DAG: cir.global "private" internal dso_local @test_zero_init_padding.bfp = #cir.const_record<{
51+
// CIR-DAG: cir.global "private" constant internal dso_local @test_zero_init_padding.bfp = #cir.const_record<{
5252
// CIR-DAG-SAME: #cir.int<17> : !u8i,
5353
// CIR-DAG-SAME: #cir.const_array<[#cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i]> : !cir.array<!u8i x 3>,
5454
// CIR-DAG-SAME: #cir.int<99> : !s32i
5555
// CIR-DAG-SAME: }> : !rec_anon_struct2
5656

5757
// tp: int + char + 3 bytes tail padding -> uses !rec_anon_struct1
58-
// CIR-DAG: cir.global "private" internal dso_local @test_zero_init_padding.tp = #cir.const_record<{
58+
// CIR-DAG: cir.global "private" constant internal dso_local @test_zero_init_padding.tp = #cir.const_record<{
5959
// CIR-DAG-SAME: #cir.int<10> : !s32i,
6060
// CIR-DAG-SAME: #cir.int<20> : !s8i,
6161
// CIR-DAG-SAME: #cir.const_array<[#cir.zero : !u8i, #cir.zero : !u8i, #cir.zero : !u8i]> : !cir.array<!u8i x 3>
6262
// CIR-DAG-SAME: }> : !rec_anon_struct1
6363

6464
// mp: char + 1 byte padding + short + 4 bytes padding + long long -> uses !rec_anon_struct
65-
// CIR-DAG: cir.global "private" internal dso_local @test_zero_init_padding.mp = #cir.const_record<{
65+
// CIR-DAG: cir.global "private" constant internal dso_local @test_zero_init_padding.mp = #cir.const_record<{
6666
// CIR-DAG-SAME: #cir.int<5> : !s8i,
6767
// CIR-DAG-SAME: #cir.zero : !u8i,
6868
// CIR-DAG-SAME: #cir.int<10> : !s16i,
@@ -73,10 +73,10 @@ void test_zero_init_padding(void) {
7373
// CIR-LABEL: cir.func {{.*}}@test_zero_init_padding
7474
// CIR: cir.return
7575

76-
// LLVM-DAG: @test_zero_init_padding.paf = internal global { i8, [3 x i8], i32 } { i8 1, [3 x i8] zeroinitializer, i32 42 }
77-
// LLVM-DAG: @test_zero_init_padding.bfp = internal global { i8, [3 x i8], i32 } { i8 17, [3 x i8] zeroinitializer, i32 99 }
78-
// LLVM-DAG: @test_zero_init_padding.tp = internal global { i32, i8, [3 x i8] } { i32 10, i8 20, [3 x i8] zeroinitializer }
79-
// LLVM-DAG: @test_zero_init_padding.mp = internal global { i8, i8, i16, [4 x i8], i64 } { i8 5, i8 0, i16 10, [4 x i8] zeroinitializer, i64 100 }
76+
// LLVM-DAG: @test_zero_init_padding.paf = internal constant { i8, [3 x i8], i32 } { i8 1, [3 x i8] zeroinitializer, i32 42 }
77+
// LLVM-DAG: @test_zero_init_padding.bfp = internal constant { i8, [3 x i8], i32 } { i8 17, [3 x i8] zeroinitializer, i32 99 }
78+
// LLVM-DAG: @test_zero_init_padding.tp = internal constant { i32, i8, [3 x i8] } { i32 10, i8 20, [3 x i8] zeroinitializer }
79+
// LLVM-DAG: @test_zero_init_padding.mp = internal constant { i8, i8, i16, [4 x i8], i64 } { i8 5, i8 0, i16 10, [4 x i8] zeroinitializer, i64 100 }
8080

8181
// LLVM-LABEL: define{{.*}} void @test_zero_init_padding
8282
// LLVM: ret void

clang/test/CIR/CodeGen/vtt.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fno-rtti -emit-llvm %s -o %t.ll
66
// RUN: FileCheck --check-prefixes=OGCG-NO-RTTI,OGCG-COMMON --input-file=%t.ll %s
77

8-
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
9-
// RUN: FileCheck --check-prefixes=CIR-RTTI,CIR-COMMON --input-file=%t.cir %s
10-
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t-cir.ll
11-
// RUN: FileCheck --check-prefixes=LLVM-RTTI,LLVM-COMMON --input-file=%t-cir.ll %s
12-
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll
13-
// RUN: FileCheck --check-prefixes=OGCG-RTTI,OGCG-COMMON --input-file=%t.ll %s
8+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t-rtti.cir
9+
// RUN: FileCheck --check-prefixes=CIR-RTTI,CIR-COMMON --input-file=%t-rtti.cir %s
10+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t-cir-rtti.ll
11+
// RUN: FileCheck --check-prefixes=LLVM-RTTI,LLVM-COMMON --input-file=%t-cir-rtti.ll %s
12+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t-rtti.ll
13+
// RUN: FileCheck --check-prefixes=OGCG-RTTI,OGCG-COMMON --input-file=%t-rtti.ll %s
1414

1515
// Note: This test will be expanded to verify VTT emission and VTT implicit
1616
// argument handling. For now, it's just test the record layout.
@@ -170,7 +170,7 @@ void D::y() {}
170170

171171
// CIR-RTTI: cir.global{{.*}} @_ZTI1B : !cir.ptr<!u8i>
172172

173-
// LLVM-RTTI: @_ZTI1B = external global ptr
173+
// LLVM-RTTI: @_ZTI1B = external constant ptr
174174

175175
// OGCG-RTTI: @_ZTI1B = external constant ptr
176176

0 commit comments

Comments
 (0)