Skip to content

Commit 51bedf4

Browse files
committed
[KeyInstr][Clang] Coerce packed struct atom
1 parent cbc0ee6 commit 51bedf4

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

clang/lib/CodeGen/CGCall.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1420,7 +1420,8 @@ void CodeGenFunction::CreateCoercedStore(llvm::Value *Src, Address Dst,
14201420
// If the source is a simple integer, coerce it directly.
14211421
llvm::Type *DstIntTy = Builder.getIntNTy(DstSize.getFixedValue() * 8);
14221422
Src = CoerceIntOrPtrToIntOrPtr(Src, DstIntTy, *this);
1423-
Builder.CreateStore(Src, Dst.withElementType(DstIntTy), DstIsVolatile);
1423+
auto *I = Builder.CreateStore(Src, Dst.withElementType(DstIntTy), DstIsVolatile);
1424+
addInstToCurrentSourceAtom(I, Src);
14241425
} else {
14251426
// Otherwise do coercion through memory. This is stupid, but
14261427
// simple.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: %clang -gkey-instructions -gno-column-info -x c++ %s -gmlt -S -emit-llvm -o - -target arm64-apple-ios11 \
2+
// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank
3+
4+
// RUN: %clang -gkey-instructions -gno-column-info -x c %s -gmlt -S -emit-llvm -o - -target arm64-apple-ios11 \
5+
// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank
6+
7+
typedef struct {
8+
char a;
9+
int x;
10+
} __attribute((packed)) S;
11+
12+
S getS();
13+
void f() {
14+
// CHECK: [[call:%.*]] = call i40{{.*}}getS{{.*}}, !dbg [[G1R2:!.*]]
15+
// CHECK: store i40 [[call]], ptr %s, align 1, !dbg [[G1R1:!.*]]
16+
S s = getS();
17+
// CHECK: ret void, !dbg [[G2R1:!.*]]
18+
}
19+
20+
// CHECK: [[G1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2)
21+
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
22+
// CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)

0 commit comments

Comments
 (0)