summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGen/pass-object-size.c
diff options
context:
space:
mode:
authorGeorge Burgess IV <george.burgess.iv@gmail.com>2017-02-23 05:59:56 +0000
committerGeorge Burgess IV <george.burgess.iv@gmail.com>2017-02-23 05:59:56 +0000
commit0d6592a899954772f45a951cb3a48df0268d736d (patch)
treec4d54f1ae8892fca3c1284d405d5ab48fffc547c /clang/test/CodeGen/pass-object-size.c
parent0af90586e767ea6699c30d9e4a89caf85496cfa5 (diff)
downloadbcm5719-llvm-0d6592a899954772f45a951cb3a48df0268d736d.tar.gz
bcm5719-llvm-0d6592a899954772f45a951cb3a48df0268d736d.zip
[CodeGen] Don't reemit expressions for pass_object_size params.
This fixes an assertion failure in cases where we had expression statements that declared variables nested inside of pass_object_size args. Since we were emitting the same ExprStmt twice (once for the arg, once for the @llvm.objectsize call), we were getting issues with redefining locals. This also means that we can be more lax about when we emit @llvm.objectsize for pass_object_size args: since we're reusing the arg's value itself, we don't have to care so much about side-effects. llvm-svn: 295935
Diffstat (limited to 'clang/test/CodeGen/pass-object-size.c')
-rw-r--r--clang/test/CodeGen/pass-object-size.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/clang/test/CodeGen/pass-object-size.c b/clang/test/CodeGen/pass-object-size.c
index 4842c09c3b9..f5c12317ec3 100644
--- a/clang/test/CodeGen/pass-object-size.c
+++ b/clang/test/CodeGen/pass-object-size.c
@@ -343,16 +343,26 @@ void test12(void *const p __attribute__((pass_object_size(3)))) {
// CHECK-LABEL: define void @test13
void test13() {
- // Ensuring that we don't lower objectsize if the expression has side-effects
char c[10];
+ unsigned i = 0;
char *p = c;
// CHECK: @llvm.objectsize
ObjectSize0(p);
- // CHECK-NOT: @llvm.objectsize
- ObjectSize0(++p);
- ObjectSize0(p++);
+ // Allow side-effects, since they always need to happen anyway. Just make sure
+ // we don't perform them twice.
+ // CHECK: = add
+ // CHECK-NOT: = add
+ // CHECK: @llvm.objectsize
+ // CHECK: call i32 @ObjectSize0
+ ObjectSize0(p + ++i);
+
+ // CHECK: = add
+ // CHECK: @llvm.objectsize
+ // CHECK-NOT: = add
+ // CHECK: call i32 @ObjectSize0
+ ObjectSize0(p + i++);
}
// There was a bug where variadic functions with pass_object_size would cause
@@ -395,3 +405,16 @@ void test16(__attribute__((address_space(1))) unsigned *I) {
// CHECK: call void @pass_size_unsigned_as1
pass_size_unsigned_as1(I);
}
+
+// This used to cause assertion failures, since we'd try to emit the statement
+// expression (and definitions for `a`) twice.
+// CHECK-LABEL: define void @test17
+void test17(char *C) {
+ // Check for 65535 to see if we're emitting this pointer twice.
+ // CHECK: 65535
+ // CHECK-NOT: 65535
+ // CHECK: @llvm.objectsize.i64.p0i8(i8* [[PTR:%[^,]+]],
+ // CHECK-NOT: 65535
+ // CHECK: call i32 @ObjectSize0(i8* [[PTR]]
+ ObjectSize0(C + ({ int a = 65535; a; }));
+}
OpenPOWER on IntegriCloud