Skip to content

Commit e5779b9

Browse files
committed
[KeyInstr][Clang] Coerce through memory atom
1 parent 51bedf4 commit e5779b9

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

clang/lib/CodeGen/CGCall.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,10 +1435,11 @@ void CodeGenFunction::CreateCoercedStore(llvm::Value *Src, Address Dst,
14351435
RawAddress Tmp =
14361436
CreateTempAllocaForCoercion(*this, SrcTy, Dst.getAlignment());
14371437
Builder.CreateStore(Src, Tmp);
1438-
Builder.CreateMemCpy(Dst.emitRawPointer(*this),
1439-
Dst.getAlignment().getAsAlign(), Tmp.getPointer(),
1440-
Tmp.getAlignment().getAsAlign(),
1441-
Builder.CreateTypeSize(IntPtrTy, DstSize));
1438+
auto *I = Builder.CreateMemCpy(
1439+
Dst.emitRawPointer(*this), Dst.getAlignment().getAsAlign(),
1440+
Tmp.getPointer(), Tmp.getAlignment().getAsAlign(),
1441+
Builder.CreateTypeSize(IntPtrTy, DstSize));
1442+
addInstToCurrentSourceAtom(I, Src);
14421443
}
14431444
}
14441445

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// RUN: %clang -gkey-instructions -gno-column-info -x c++ %s -gmlt -S -emit-llvm -o - -target aarch64-windows-msvc \
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 aarch64-windows-msvc \
5+
// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank
6+
7+
typedef struct {
8+
short a;
9+
int b;
10+
short c;
11+
} S;
12+
13+
S getS(void);
14+
15+
void f() {
16+
// CHECK: %call = call [2 x i64] {{.*}}getS{{.*}}(), !dbg [[G1R2:!.*]]
17+
//// Note: The store to the tmp alloca isn't part of the atom.
18+
// CHECK: store [2 x i64] %call, ptr %tmp.coerce, align 8
19+
// CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %s, ptr align 8 %tmp.coerce, i64 12, i1 false), !dbg [[G1R1:!.*]]
20+
S s = getS();
21+
// CHECK: ret void, !dbg [[G2R1:!.*]]
22+
}
23+
24+
// CHECK: [[G1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2)
25+
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
26+
// CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)

0 commit comments

Comments
 (0)