|  | 
|  | 1 | +// RUN: %clang -gkey-instructions -x c++ -std=c++17 %s -gmlt -S -emit-llvm -o - \ | 
|  | 2 | +// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank --check-prefixes=CHECK,CHECK-CXX | 
|  | 3 | + | 
|  | 4 | +// RUN: %clang -gkey-instructions -x c %s -gmlt -S -emit-llvm -o -  \ | 
|  | 5 | +// RUN: | FileCheck %s --implicit-check-not atomGroup --implicit-check-not atomRank | 
|  | 6 | + | 
|  | 7 | +int g; | 
|  | 8 | +void a(int A, int B) { | 
|  | 9 | +// CHECK: entry: | 
|  | 10 | +// The load gets associated with the branch rather than the store. | 
|  | 11 | +// FIXME: Is that the best thing to do? | 
|  | 12 | +// CHECK: %0 = load i32, ptr %A.addr{{.*}}, !dbg [[G2R2:!.*]] | 
|  | 13 | +// CHECK: store i32 %0, ptr @g{{.*}}, !dbg [[G1R1:!.*]] | 
|  | 14 | +// CHECK: switch i32 %0, label %{{.*}} [ | 
|  | 15 | +// CHECK:   i32 0, label %sw.bb | 
|  | 16 | +// CHECK:   i32 1, label %sw.bb1 | 
|  | 17 | +// CHECK: ], !dbg [[G2R1:!.*]] | 
|  | 18 | +    switch ((g = A)) { | 
|  | 19 | +    case 0: break; | 
|  | 20 | +    case 1: { | 
|  | 21 | +// CHECK: sw.bb1: | 
|  | 22 | +// CHECK: %1 = load i32, ptr %B.addr{{.*}}, !dbg [[G3R2:!.*]] | 
|  | 23 | +// CHECK: switch i32 %1, label %{{.*}} [ | 
|  | 24 | +// CHECK:   i32 0, label %sw.bb2 | 
|  | 25 | +// CHECK: ], !dbg [[G3R1:!.*]] | 
|  | 26 | +    switch ((B)) { | 
|  | 27 | +        case 0: { | 
|  | 28 | +// Test that assignments in constant-folded switches don't go missing. | 
|  | 29 | +// CHECK-CXX: sw.bb2: | 
|  | 30 | +// CHECK-CXX: store i32 1, ptr %C{{.*}}, !dbg [[G4R1:!.*]] | 
|  | 31 | +#ifdef __cplusplus | 
|  | 32 | +            switch (const int C = 1; C) { | 
|  | 33 | +                case 0: break; | 
|  | 34 | +                case 1: break; | 
|  | 35 | +                default: break; | 
|  | 36 | +            } | 
|  | 37 | +#endif | 
|  | 38 | +        } break; | 
|  | 39 | +        default: break; | 
|  | 40 | +    } | 
|  | 41 | +    } break; | 
|  | 42 | +    default: break; | 
|  | 43 | +    } | 
|  | 44 | +} | 
|  | 45 | + | 
|  | 46 | +// CHECK: [[G2R2]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 2) | 
|  | 47 | +// CHECK: [[G1R1]] = !DILocation({{.*}}, atomGroup: 1, atomRank: 1) | 
|  | 48 | +// CHECK: [[G2R1]] = !DILocation({{.*}}, atomGroup: 2, atomRank: 1) | 
|  | 49 | +// CHECK: [[G3R2]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 2) | 
|  | 50 | +// CHECK: [[G3R1]] = !DILocation({{.*}}, atomGroup: 3, atomRank: 1) | 
|  | 51 | +// CHECK-CXX: [[G4R1]] = !DILocation({{.*}}, atomGroup: 4, atomRank: 1) | 
0 commit comments