Skip to content

Commit 13d933e

Browse files
Merge pull request #62141 from aschwaighofer/debug_info_resilient
DebugInfo: Fix shadow variable emisson for non-loadable types
2 parents 888fe84 + a667c73 commit 13d933e

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

lib/IRGen/IRGenSIL.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,10 @@ class IRGenSILFunction :
915915
Address = Builder.CreateElementBitCast(Address, Storage->getType());
916916
}
917917

918+
// This might happen because of non-loadable types.
919+
if (Storage->stripPointerCasts()->getType() == Alloca.getElementType())
920+
Storage = Storage->stripPointerCasts();
921+
918922
assert(canAllocaStoreValue(Address, Storage, VarInfo, Scope) &&
919923
"bad scope?");
920924

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// RUN: %empty-directory(%t)
2+
//
3+
// Compile the external swift module.
4+
// RUN: %target-swift-frontend -g -emit-module -enable-library-evolution \
5+
// RUN: -emit-module-path=%t/resilient_struct.swiftmodule \
6+
// RUN: -module-name=resilient_struct %S/../Inputs/resilient_struct.swift
7+
//
8+
// RUN: %target-swift-frontend -g -I %t -emit-ir %s -o - | %FileCheck %s
9+
10+
// REQUIRES: CPU=arm64 || CPU=x86_64
11+
12+
import resilient_struct
13+
14+
// This test case used to crash/assert.
15+
16+
sil @test_debug_value_resilient : $@convention(thin) () -> () {
17+
bb0:
18+
%0 = alloc_stack $Size, var, name "assertions", implicit
19+
debug_value %0 : $*Size, var, name "assertions", implicit
20+
dealloc_stack %0: $*Size
21+
%1 = tuple ()
22+
return %1 : $()
23+
}
24+
25+
// CHECK: %assertions.debug = alloca i8*
26+
// CHECK: %assertions = alloca i8, i64 %size
27+
// CHECK: store i8* %assertions, i8** %assertions.debug

0 commit comments

Comments
 (0)