mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-26 07:26:09 +00:00

Generate nuw GEPs for struct member accesses, as inbounds + non-negative implies nuw. Regression tests are updated using update scripts where possible, and by find + replace where not.
30 lines
1.1 KiB
C++
30 lines
1.1 KiB
C++
// RUN: %clang_cc1 -std=c++1y -triple i686-pc-windows-msvc -emit-llvm %s -o - | FileCheck %s
|
|
//CHECK: %[[A_LAMBDA:.*]] = type { %struct.A }
|
|
//CHECK: %[[B_LAMBDA:.*]] = type { ptr }
|
|
struct A {
|
|
double a = 111;
|
|
auto foo() { return [*this] { return a; }; }
|
|
};
|
|
|
|
namespace ns1 {
|
|
int X = A{}.foo()();
|
|
} //end ns1
|
|
|
|
//CHECK: @"?foo@A@@QAE?A?<auto>@@XZ"(ptr {{[^,]*}} %this, ptr dead_on_unwind noalias writable sret(%class.anon) align 8 %[[A_LAMBDA_RETVAL:.*]])
|
|
// get the first object with the closure type, which is of type 'struct.A'
|
|
//CHECK: %[[I0:.+]] = getelementptr inbounds nuw %[[A_LAMBDA]], ptr %[[A_LAMBDA_RETVAL]], i32 0, i32 0
|
|
// copy the contents ...
|
|
//CHECK: call void @llvm.memcpy.p0.p0.i32(ptr align 8 %[[I0]], ptr align 8 %this1, i32 8, i1 false)
|
|
|
|
struct B {
|
|
double b = 222;
|
|
auto bar() { return [this] { return b; }; };
|
|
};
|
|
|
|
namespace ns2 {
|
|
int X = B{}.bar()();
|
|
}
|
|
//CHECK: @"?bar@B@@QAE?A?<auto>@@XZ"(ptr {{[^,]*}} %this, ptr dead_on_unwind noalias writable sret(%class.anon.0) align 4 %agg.result)
|
|
//CHECK: %[[I20:.+]] = getelementptr inbounds nuw %class.anon.0, ptr %agg.result, i32 0, i32 0
|
|
//CHECK: store ptr %this1, ptr %[[I20]], align 4
|