Skip to content

Commit d5eee6f

Browse files
committed
[KeyInstr][Clang] Coerced to int atom
1 parent 5725d90 commit d5eee6f

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

clang/lib/CodeGen/CGCall.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1436,7 +1436,8 @@ void CodeGenFunction::CreateCoercedStore(llvm::Value *Src, Address Dst,
14361436
addInstToCurrentSourceAtom(I, Elt);
14371437
}
14381438
} else {
1439-
Builder.CreateStore(Src, Dst.withElementType(SrcTy), DstIsVolatile);
1439+
auto * I = Builder.CreateStore(Src, Dst.withElementType(SrcTy), DstIsVolatile);
1440+
addInstToCurrentSourceAtom(I, Src);
14401441
}
14411442
} else if (SrcTy->isIntegerTy()) {
14421443
// If the source is a simple integer, coerce it directly.

clang/test/KeyInstructions/coerced.c

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,40 @@
11
// RUN: %clang -gkey-instructions -gno-column-info -x c++ %s -gmlt -S -emit-llvm -o - -target x86_64-unknown-linux \
2-
// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank
2+
// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank --check-prefixes=CHECK,CHECK-CXX
33

44
// RUN: %clang -gkey-instructions -gno-column-info -x c %s -gmlt -S -emit-llvm -o - -target x86_64-unknown-linux \
5-
// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank
5+
// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank --check-prefixes=CHECK,CHECK-C
66

77
typedef struct {
88
void* a;
99
void* b;
1010
} Struct;
11-
1211
Struct get();
13-
void store() {
14-
// CHECK: %1 = extractvalue { ptr, ptr } %call, 0, !dbg [[G1R2:!.*]]
15-
// CHECK: store ptr %1, ptr {{.*}}, !dbg [[G1R1:!.*]]
16-
// CHECK: %3 = extractvalue { ptr, ptr } %call, 1, !dbg [[G1R2]]
17-
// CHECK: store ptr %3, ptr {{.*}}, !dbg [[G1R1:!.*]]
12+
13+
void test() {
14+
// CHECK: %1 = extractvalue { ptr, ptr } %call, 0, !dbg [[G1R2:!.*]]
15+
// CHECK: store ptr %1, ptr {{.*}}, !dbg [[G1R1:!.*]]
16+
// CHECK: %3 = extractvalue { ptr, ptr } %call, 1, !dbg [[G1R2]]
17+
// CHECK: store ptr %3, ptr {{.*}}, !dbg [[G1R1:!.*]]
1818
Struct s = get();
19-
// CHECK: ret void, !dbg [[G2R1:!.*]]
19+
// CHECK: ret void, !dbg [[G2R1:!.*]]
20+
}
21+
22+
typedef struct { int i; } Int;
23+
Int getInt(void);
24+
25+
// CHECK-C: @test2
26+
// CHECK-CXX: @_Z5test2v
27+
void test2() {
28+
// CHECK: %call = call i32 @{{(_Z6)?}}getInt{{v?}}(), !dbg [[T2_G1R2:!.*]]
29+
// CHECK: [[gep:%.*]] = getelementptr inbounds nuw %struct.Int, ptr %i, i32 0, i32 0
30+
// CHECK: store i32 %call, ptr [[gep]]{{.*}}, !dbg [[T2_G1R1:!.*]]
31+
Int i = getInt();
32+
// CHECK: ret void, !dbg [[T2_G2R1:!.*]]
2033
}
2134

2235
// CHECK: [[G1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2)
2336
// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
2437
// CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)
38+
// CHECK: [[T2_G1R2]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 2)
39+
// CHECK: [[T2_G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1)
40+
// CHECK: [[T2_G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1)

0 commit comments

Comments
 (0)