diff --git a/lib/IRGen/IRGenSIL.cpp b/lib/IRGen/IRGenSIL.cpp index 0b26c21535c92..32a4eb2351a0c 100644 --- a/lib/IRGen/IRGenSIL.cpp +++ b/lib/IRGen/IRGenSIL.cpp @@ -915,6 +915,10 @@ class IRGenSILFunction : Address = Builder.CreateElementBitCast(Address, Storage->getType()); } + // This might happen because of non-loadable types. + if (Storage->stripPointerCasts()->getType() == Alloca.getElementType()) + Storage = Storage->stripPointerCasts(); + assert(canAllocaStoreValue(Address, Storage, VarInfo, Scope) && "bad scope?"); diff --git a/test/DebugInfo/resilient_debug_value.sil b/test/DebugInfo/resilient_debug_value.sil new file mode 100644 index 0000000000000..7ff9d169c06d1 --- /dev/null +++ b/test/DebugInfo/resilient_debug_value.sil @@ -0,0 +1,27 @@ +// RUN: %empty-directory(%t) +// +// Compile the external swift module. +// RUN: %target-swift-frontend -g -emit-module -enable-library-evolution \ +// RUN: -emit-module-path=%t/resilient_struct.swiftmodule \ +// RUN: -module-name=resilient_struct %S/../Inputs/resilient_struct.swift +// +// RUN: %target-swift-frontend -g -I %t -emit-ir %s -o - | %FileCheck %s + +// REQUIRES: CPU=arm64 || CPU=x86_64 + +import resilient_struct + +// This test case used to crash/assert. + +sil @test_debug_value_resilient : $@convention(thin) () -> () { +bb0: + %0 = alloc_stack $Size, var, name "assertions", implicit + debug_value %0 : $*Size, var, name "assertions", implicit + dealloc_stack %0: $*Size + %1 = tuple () + return %1 : $() +} + +// CHECK: %assertions.debug = alloca i8* +// CHECK: %assertions = alloca i8, i64 %size +// CHECK: store i8* %assertions, i8** %assertions.debug