[PATCH] Fix for http://llvm.org/PR23392: magick/feature.c from ImageMagick-6.9.1-2 ICEs
Alexey Bataev
a.bataev at hotmail.com
Wed May 6 23:32:19 PDT 2015
REPOSITORY
rL LLVM
http://reviews.llvm.org/D9522
Files:
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/test/CodeGen/captured-statements.c
cfe/trunk/test/CodeGenCXX/captured-statements.cpp
Index: cfe/trunk/test/CodeGenCXX/captured-statements.cpp
===================================================================
--- cfe/trunk/test/CodeGenCXX/captured-statements.cpp
+++ cfe/trunk/test/CodeGenCXX/captured-statements.cpp
@@ -21,30 +21,36 @@
Foo f;
#pragma clang __debug captured
{
+ static double inner = x;
+ (void)inner;
f.y = x;
}
}
};
void test1() {
TestClass c;
c.MemberFunc();
- // CHECK-1: %[[Capture:struct\.anon[\.0-9]*]] = type { %struct.Foo*, %struct.TestClass* }
+ // CHECK-1: %[[Capture:struct\.anon[\.0-9]*]] = type { %struct.TestClass*, %struct.Foo* }
+ // CHECK-1: [[INNER:@.+]] = {{.+}} global double
// CHECK-1: define {{.*}} void @_ZN9TestClass10MemberFuncEv
// CHECK-1: alloca %struct.anon
// CHECK-1: getelementptr inbounds %[[Capture]], %[[Capture]]* %{{[^,]*}}, i32 0, i32 0
- // CHECK-1: store %struct.Foo* %f, %struct.Foo**
// CHECK-1: getelementptr inbounds %[[Capture]], %[[Capture]]* %{{[^,]*}}, i32 0, i32 1
+ // CHECK-1: store %struct.Foo* %f, %struct.Foo**
// CHECK-1: call void @[[HelperName:[A-Za-z0-9_]+]](%[[Capture]]*
// CHECK-1: call {{.*}}FooD1Ev
// CHECK-1: ret
}
// CHECK-1: define internal void @[[HelperName]]
-// CHECK-1: getelementptr inbounds %[[Capture]], %[[Capture]]* {{[^,]*}}, i32 0, i32 1
-// CHECK-1: getelementptr inbounds %struct.TestClass, %struct.TestClass* {{[^,]*}}, i32 0, i32 0
// CHECK-1: getelementptr inbounds %[[Capture]], %[[Capture]]* {{[^,]*}}, i32 0, i32 0
+// CHECK-1: call i32 @__cxa_guard_acquire(
+// CHECK-1: store double %{{.+}}, double* [[INNER]],
+// CHECK-1: call void @__cxa_guard_release(
+// CHECK-1: getelementptr inbounds %struct.TestClass, %struct.TestClass* {{[^,]*}}, i32 0, i32 0
+// CHECK-1: getelementptr inbounds %[[Capture]], %[[Capture]]* {{[^,]*}}, i32 0, i32 1
void test2(int x) {
int y = [&]() {
Index: cfe/trunk/test/CodeGen/captured-statements.c
===================================================================
--- cfe/trunk/test/CodeGen/captured-statements.c
+++ cfe/trunk/test/CodeGen/captured-statements.c
@@ -14,9 +14,12 @@
int i = 0;
#pragma clang __debug captured
{
+ static float inner = 3.0;
+ (void)inner;
i++;
}
// CHECK-1: %struct.anon = type { i32* }
+ // CHECK-1: {{.+}} global float 3.0
//
// CHECK-1: test1
// CHECK-1: alloca %struct.anon
Index: cfe/trunk/lib/CodeGen/CGDecl.cpp
===================================================================
--- cfe/trunk/lib/CodeGen/CGDecl.cpp
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp
@@ -156,6 +156,8 @@
assert(!D.isExternallyVisible() && "name shouldn't matter");
std::string ContextName;
const DeclContext *DC = D.getDeclContext();
+ if (auto *CD = dyn_cast<CapturedDecl>(DC))
+ DC = cast<DeclContext>(CD->getNonClosureContext());
if (const auto *FD = dyn_cast<FunctionDecl>(DC))
ContextName = CGM.getMangledName(FD);
else if (const auto *BD = dyn_cast<BlockDecl>(DC))
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9522.25132.patch
Type: text/x-patch
Size: 3015 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150507/0b085a75/attachment.bin>
More information about the cfe-commits
mailing list