llvm-project/clang/test/CodeGenCXX/ms-union-member-ref.cpp
Juneyoung Lee f193bcc701 Revert D105169 due to the two-stage failure in ASAN
This reverts the following commits:
37ca7a795b277c20c02a218bf44052278c03344b
9aa6c72b92b6c89cc6d23b693257df9af7de2d15
705387c5074bcca36d626882462ebbc2bcc3bed4
8ca4b3ef19fe82d7ad6a6e1515317dcc01b41515
80dba72a669b5416e97a42fd2c2a7bc5a6d3f44a
2021-10-18 23:52:46 +09:00

35 lines
1.3 KiB
C++

// RUN: %clang_cc1 -triple=i686-pc-win32 -fms-extensions %s -emit-llvm -o- | FileCheck %s
union A {
int *&ref;
int **ptr;
};
int *f1(A *a) {
return a->ref;
}
// CHECK-LABEL: define {{.*}}i32* @"?f1@@YAPAHPATA@@@Z"(%union.A* %a)
// CHECK: [[REF:%[^[:space:]]+]] = bitcast %union.A* %{{.*}} to i32***
// CHECK: [[IPP:%[^[:space:]]+]] = load i32**, i32*** [[REF]]
// CHECK: [[IP:%[^[:space:]]+]] = load i32*, i32** [[IPP]]
// CHECK: ret i32* [[IP]]
void f2(A *a) {
*a->ref = 1;
}
// CHECK-LABEL: define {{.*}}void @"?f2@@YAXPATA@@@Z"(%union.A* %a)
// CHECK: [[REF:%[^[:space:]]+]] = bitcast %union.A* %{{.*}} to i32***
// CHECK: [[IPP:%[^[:space:]]+]] = load i32**, i32*** [[REF]]
// CHECK: [[IP:%[^[:space:]]+]] = load i32*, i32** [[IPP]]
// CHECK: store i32 1, i32* [[IP]]
bool f3(A *a, int *b) {
return a->ref != b;
}
// CHECK-LABEL: define {{.*}}i1 @"?f3@@YA_NPATA@@PAH@Z"(%union.A* %a, i32* %b)
// CHECK: [[REF:%[^[:space:]]+]] = bitcast %union.A* %{{.*}} to i32***
// CHECK: [[IPP:%[^[:space:]]+]] = load i32**, i32*** [[REF]]
// CHECK: [[IP:%[^[:space:]]+]] = load i32*, i32** [[IPP]]
// CHECK: [[IP2:%[^[:space:]]+]] = load i32*, i32** %b.addr
// CHECK: icmp ne i32* [[IP]], [[IP2]]