Skip to content

Commit 3bd7879

Browse files
committed
[KeyInstr][Clang] Coerce packed struct atom
1 parent 391f2b4 commit 3bd7879

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
@@ -1444,7 +1444,8 @@ void CodeGenFunction::CreateCoercedStore(llvm::Value *Src, Address Dst,
14441444
// If the source is a simple integer, coerce it directly.
14451445
llvm::Type *DstIntTy = Builder.getIntNTy(DstSize.getFixedValue() * 8);
14461446
Src = CoerceIntOrPtrToIntOrPtr(Src, DstIntTy, *this);
1447-
Builder.CreateStore(Src, Dst.withElementType(DstIntTy), DstIsVolatile);
1447+
auto *I = Builder.CreateStore(Src, Dst.withElementType(DstIntTy), DstIsVolatile);
1448+
addInstToCurrentSourceAtom(I, Src);
14481449
} else {
14491450
// Otherwise do coercion through memory. This is stupid, but
14501451
// 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)