Skip to content

Commit cbc0ee6

Browse files
committed
[KeyInstr][Clang] Coerced ptr to int atom
1 parent 1956972 commit cbc0ee6

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

clang/lib/CodeGen/CGCall.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1400,7 +1400,8 @@ void CodeGenFunction::CreateCoercedStore(llvm::Value *Src, Address Dst,
14001400
SrcSize == CGM.getDataLayout().getTypeAllocSize(Dst.getElementType())) {
14011401
// If the value is supposed to be a pointer, convert it before storing it.
14021402
Src = CoerceIntOrPtrToIntOrPtr(Src, Dst.getElementType(), *this);
1403-
Builder.CreateStore(Src, Dst, DstIsVolatile);
1403+
auto *I = Builder.CreateStore(Src, Dst, DstIsVolatile);
1404+
addInstToCurrentSourceAtom(I, Src);
14041405
} else if (llvm::StructType *STy =
14051406
dyn_cast<llvm::StructType>(Src->getType())) {
14061407
// Prefer scalar stores to first-class aggregate stores.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: %clang -gkey-instructions -gno-column-info -x c++ %s -gmlt -S -emit-llvm -o - -target x86_64-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 x86_64-windows-msvc \
5+
// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank
6+
7+
typedef struct { int *p; } Ptr;
8+
Ptr getPtr();
9+
void f() {
10+
// CHECK: %call = call i64{{.*}}, !dbg [[G1R3:!.*]]
11+
// CHECK: [[gep:%.*]] = getelementptr inbounds nuw %struct.Ptr, ptr %p, i32 0, i32 0
12+
// CHECK: [[i2p:%.*]] = inttoptr i64 %call to ptr, !dbg [[G1R2:!.*]]
13+
// CHECK: store ptr [[i2p]], ptr [[gep]], align 8, !dbg [[G1R1:!.*]]
14+
Ptr p = getPtr();
15+
// CHECK: ret void, !dbg [[G2R1:!.*]]
16+
}
17+
18+
// CHECK: [[G1R3]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 3)
19+
// CHECK: [[G1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2)
20+
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
21+
// CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)

0 commit comments

Comments
 (0)