r246880 - Don't use unreachable as a placeholder, it confuses EmitBlock
Reid Kleckner via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 4 14:39:15 PDT 2015
Author: rnk
Date: Fri Sep 4 16:39:15 2015
New Revision: 246880
URL: http://llvm.org/viewvc/llvm-project?rev=246880&view=rev
Log:
Don't use unreachable as a placeholder, it confuses EmitBlock
This fixes an issue raised in D12412, where we generated invalid IR.
Thanks to Vedant Kumar for coming up with the initial work around.
Differential Revision: http://reviews.llvm.org/D12412
Added:
cfe/trunk/test/CodeGenCXX/partial-init.cpp
Modified:
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
Modified: cfe/trunk/lib/CodeGen/CGExprAgg.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprAgg.cpp?rev=246880&r1=246879&r2=246880&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprAgg.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprAgg.cpp Fri Sep 4 16:39:15 2015
@@ -1253,7 +1253,9 @@ void AggExprEmitter::VisitInitListExpr(I
assert(LV.isSimple());
if (CGF.needsEHCleanup(dtorKind)) {
if (!cleanupDominator)
- cleanupDominator = CGF.Builder.CreateUnreachable(); // placeholder
+ cleanupDominator = CGF.Builder.CreateLoad(
+ CGF.Int8Ty,
+ llvm::Constant::getNullValue(CGF.Int8PtrTy)); // placeholder
CGF.pushDestroy(EHCleanup, LV.getAddress(), field->getType(),
CGF.getDestroyer(dtorKind), false);
Added: cfe/trunk/test/CodeGenCXX/partial-init.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/partial-init.cpp?rev=246880&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/partial-init.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/partial-init.cpp Fri Sep 4 16:39:15 2015
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -std=c++11 -fcxx-exceptions -fexceptions -S -emit-llvm -o - %s | FileCheck %s
+
+namespace std {
+ struct string {
+ const char *p;
+ string(const char *s);
+ ~string();
+ };
+}
+
+struct Bar {
+ int a;
+};
+
+struct Foo {
+ std::string c;
+ Bar d[32];
+};
+
+static Foo table[] = {
+ { "blerg" },
+};
+
+// CHECK: define internal void @__cxx_global_var_init
+// CHECK: invoke void @_ZNSt6stringC1EPKc(
+// CHECK-NOT: unreachable
+// CHECK: br label
More information about the cfe-commits
mailing list