This fixes an issue with the emission of lifetime markers for struct-returning Obj-C msgSend calls. When the result of a struct-returning call is ignored, the temporary storage is only marked with lifetime markers in one of the two branches of the nil-receiver-check. The check is, however, not required when the result is unused. If we still need to emit the check (due to consumer arguments), let's not emit the memset to zero out the result if it's unused. This fixes a use-after-scope false positive with AddressSanitizer. Differential Revision: https://reviews.llvm.org/D34834 llvm-svn: 306837
35 lines
1.2 KiB
Objective-C
35 lines
1.2 KiB
Objective-C
// RUN: %clang_cc1 -triple arm64-apple-darwin -S -emit-llvm -o - -O2 -disable-llvm-passes %s | FileCheck %s
|
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -S -emit-llvm -o - -O2 -disable-llvm-passes %s | FileCheck %s
|
|
// RUN: %clang_cc1 -triple arm64-apple-darwin -fobjc-arc -S -emit-llvm -o - -O2 -disable-llvm-passes %s | FileCheck %s --check-prefixes=CHECK,ARC
|
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc -S -emit-llvm -o - -O2 -disable-llvm-passes %s | FileCheck %s --check-prefixes=CHECK,ARC
|
|
|
|
struct stret { int x[100]; };
|
|
struct stret one = {{1}};
|
|
|
|
@interface Test
|
|
+(struct stret) method;
|
|
+(struct stret) methodConsuming:(id __attribute__((ns_consumed)))consumed;
|
|
@end
|
|
|
|
void foo(id o, id p) {
|
|
[o method];
|
|
// CHECK: @llvm.lifetime.start
|
|
// CHECK: call void bitcast {{.*}} @objc_msgSend
|
|
// CHECK: @llvm.lifetime.end
|
|
// CHECK-NOT: call void @llvm.memset
|
|
|
|
[o methodConsuming:p];
|
|
// ARC: [[T0:%.*]] = icmp eq i8*
|
|
// ARC: br i1 [[T0]]
|
|
|
|
// CHECK: @llvm.lifetime.start
|
|
// CHECK: call void bitcast {{.*}} @objc_msgSend
|
|
// CHECK: @llvm.lifetime.end
|
|
// ARC: br label
|
|
|
|
// ARC: call void @objc_release
|
|
// ARC: br label
|
|
|
|
// CHECK-NOT: call void @llvm.memset
|
|
}
|