summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGen/annotations-var.c
diff options
context:
space:
mode:
authorVolodymyr Sapsai <vsapsai@apple.com>2019-03-01 02:15:39 +0000
committerVolodymyr Sapsai <vsapsai@apple.com>2019-03-01 02:15:39 +0000
commit93317d82daf864956ae0608594ee94293e3a4257 (patch)
tree19ee56e895c5f39b60e9048777433d02c8716b29 /clang/test/CodeGen/annotations-var.c
parentdc3870d64dfec1d332894b373357cc62ae6e2c01 (diff)
downloadbcm5719-llvm-93317d82daf864956ae0608594ee94293e3a4257.tar.gz
bcm5719-llvm-93317d82daf864956ae0608594ee94293e3a4257.zip
[CodeGen] Fix calling llvm.var.annotation outside of a basic block.
When we have an annotated local variable after a function returns, we generate IR that fails verification with the error > Instruction referencing instruction not embedded in a basic block! And it means that bitcast referencing alloca doesn't have a parent basic block. Fix by checking if we are at an unreachable point and skip emitting annotations. This approach is similar to the way we emit variable initializer and debug info. rdar://problem/46200420 Reviewers: rjmccall Reviewed By: rjmccall Subscribers: aprantl, jkorous, dexonsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D58147 llvm-svn: 355166
Diffstat (limited to 'clang/test/CodeGen/annotations-var.c')
-rw-r--r--clang/test/CodeGen/annotations-var.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/clang/test/CodeGen/annotations-var.c b/clang/test/CodeGen/annotations-var.c
index 6e8ad34c651..3dc6dca3e75 100644
--- a/clang/test/CodeGen/annotations-var.c
+++ b/clang/test/CodeGen/annotations-var.c
@@ -39,10 +39,19 @@ void local(void) {
// LOCAL-NEXT: call void @llvm.var.annotation(i8* [[T0]], i8* getelementptr inbounds ([15 x i8], [15 x i8]* @{{.*}}), i8* getelementptr inbounds ({{.*}}), i32 33)
}
+void local_after_return(void) {
+ return;
+ int localvar __attribute__((annotate("localvar_after_return"))) = 3;
+// Test we are not emitting instructions like bitcast or call outside of a basic block.
+// LOCAL-LABEL: define void @local_after_return()
+// LOCAL: [[LOCALVAR:%.*]] = alloca i32,
+// LOCAL-NEXT: ret void
+}
+
void undef(void) {
int undefvar __attribute__((annotate("undefvar_ann_0")));
// UNDEF-LABEL: define void @undef()
// UNDEF: [[UNDEFVAR:%.*]] = alloca i32,
// UNDEF-NEXT: [[T0:%.*]] = bitcast i32* [[UNDEFVAR]] to i8*
-// UNDEF-NEXT: call void @llvm.var.annotation(i8* [[T0]], i8* getelementptr inbounds ([15 x i8], [15 x i8]* @{{.*}}), i8* getelementptr inbounds ({{.*}}), i32 43)
+// UNDEF-NEXT: call void @llvm.var.annotation(i8* [[T0]], i8* getelementptr inbounds ([15 x i8], [15 x i8]* @{{.*}}), i8* getelementptr inbounds ({{.*}}), i32 52)
}
OpenPOWER on IntegriCloud