Skip to content

Commit b6f42ab

Browse files
committed
[KeyInstr][Clang] Multiple assignment (x = y = z)
1 parent cdf3eef commit b6f42ab

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

clang/lib/CodeGen/CGExprScalar.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4973,6 +4973,7 @@ llvm::Value *CodeGenFunction::EmitWithOriginalRHSBitfieldAssignment(
49734973
}
49744974

49754975
Value *ScalarExprEmitter::VisitBinAssign(const BinaryOperator *E) {
4976+
ApplyAtomGroup Grp(CGF.getDebugInfo());
49764977
bool Ignore = TestAndClearIgnoreResultAssign();
49774978

49784979
Value *RHS;

clang/test/KeyInstructions/assign.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,22 @@
22
// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank
33

44
unsigned long long g;
5-
void fun() { g = 0; }
6-
5+
void fun() {
76
// CHECK: store i64 0, ptr @g{{.*}}, !dbg [[G1R1:!.*]]
7+
g = 0;
8+
9+
// Treat the two assignments as two atoms.
10+
//
11+
// FIXME: Because of the atomGroup implementation the load can only be
12+
// associated with one of the two stores, despite being a good backup
13+
// loction for both.
14+
// CHECK-NEXT: %0 = load i64, ptr @g{{.*}}, !dbg [[G2R2:!.*]]
15+
// CHECK-NEXT: store i64 %0, ptr @g{{.*}}, !dbg [[G3R1:!.*]]
16+
// CHECK-NEXT: store i64 %0, ptr @g{{.*}}, !dbg [[G2R1:!.*]]
17+
g = g = g;
18+
}
819

920
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
21+
// CHECK: [[G2R2]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 2)
22+
// CHECK: [[G3R1]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 1)
23+
// CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)

0 commit comments

Comments
 (0)