<div dir="ltr">Could you explain how/why there's a null size expr? I would've thought it must have /some/ size for code generation purposes...</div><br><div class="gmail_quote"><div dir="ltr">On Fri, Oct 7, 2016 at 11:33 AM Erich Keane <<a href="mailto:erich.keane@intel.com">erich.keane@intel.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">erichkeane created this revision.<br class="gmail_msg">
erichkeane added reviewers: cfe-commits, dblaikie, majnemer, gbenyei.<br class="gmail_msg">
erichkeane set the repository for this revision to rL LLVM.<br class="gmail_msg">
<br class="gmail_msg">
OpenMP creates a variable array type with a a null size-expr. The Debug generation failed to properly consider this case. This patch adds a null check to prevent a null dereference seg-fault in this case, plus adds a test.<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
Repository:<br class="gmail_msg">
rL LLVM<br class="gmail_msg">
<br class="gmail_msg">
<a href="https://reviews.llvm.org/D25373" rel="noreferrer" class="gmail_msg" target="_blank">https://reviews.llvm.org/D25373</a><br class="gmail_msg">
<br class="gmail_msg">
Files:<br class="gmail_msg">
lib/CodeGen/CGDebugInfo.cpp<br class="gmail_msg">
test/CodeGenCXX/debug-info-openmp-array.cpp<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
Index: lib/CodeGen/CGDebugInfo.cpp<br class="gmail_msg">
===================================================================<br class="gmail_msg">
--- lib/CodeGen/CGDebugInfo.cpp<br class="gmail_msg">
+++ lib/CodeGen/CGDebugInfo.cpp<br class="gmail_msg">
@@ -2181,7 +2181,8 @@<br class="gmail_msg">
Count = CAT->getSize().getZExtValue();<br class="gmail_msg">
else if (const auto *VAT = dyn_cast<VariableArrayType>(Ty)) {<br class="gmail_msg">
llvm::APSInt V;<br class="gmail_msg">
- if (VAT->getSizeExpr()->EvaluateAsInt(V, CGM.getContext()))<br class="gmail_msg">
+ if (VAT->getSizeExpr() &&<br class="gmail_msg">
+ VAT->getSizeExpr()->EvaluateAsInt(V, CGM.getContext()))<br class="gmail_msg">
Count = V.getExtValue();<br class="gmail_msg">
}<br class="gmail_msg">
<br class="gmail_msg">
Index: test/CodeGenCXX/debug-info-openmp-array.cpp<br class="gmail_msg">
===================================================================<br class="gmail_msg">
--- test/CodeGenCXX/debug-info-openmp-array.cpp<br class="gmail_msg">
+++ test/CodeGenCXX/debug-info-openmp-array.cpp<br class="gmail_msg">
@@ -0,0 +1,17 @@<br class="gmail_msg">
+// RUN: %clang -target x86_64-unknown-unknown -fverbose-asm -fopenmp -g -O0 -S -emit-llvm %s -o - | FileCheck %s<br class="gmail_msg">
+<br class="gmail_msg">
+<br class="gmail_msg">
+void f(int m) {<br class="gmail_msg">
+ int i;<br class="gmail_msg">
+ int cen[m];<br class="gmail_msg">
+#pragma omp parallel for<br class="gmail_msg">
+ for (i = 0; i < m; ++i) {<br class="gmail_msg">
+ cen[i] = i;<br class="gmail_msg">
+ }<br class="gmail_msg">
+}<br class="gmail_msg">
+<br class="gmail_msg">
+// CHECK: !DICompositeType(tag: DW_TAG_array_type,<br class="gmail_msg">
+// CHECK-NOT: size:<br class="gmail_msg">
+// CHECK-SAME: align: 32<br class="gmail_msg">
+// CHECK-SAME: elements: [[ELEM_TYPE:![0-9]+]]<br class="gmail_msg">
+// CHECK: !DISubrange(count: -1)<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
</blockquote></div>