Skip to content

Commit dc5827c

Browse files
Merge pull request #16453 from aschwaighofer/irgen_fix_alloc_stack_debugger_initialization
IRGen: Make sure we compare equal units in type size comparison
2 parents ec9b402 + 9ba545d commit dc5827c

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/IRGen/IRGenSIL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4017,7 +4017,7 @@ void IRGenSILFunction::visitAllocStackInst(swift::AllocStackInst *i) {
40174017
return;
40184018

40194019
auto &DL = IGM.DataLayout;
4020-
if (DL.getTypeSizeInBits(AI->getAllocatedType()) < DL.getPointerSize())
4020+
if (DL.getTypeSizeInBits(AI->getAllocatedType()) < DL.getPointerSizeInBits())
40214021
return;
40224022

40234023
auto *BC = Builder.CreateBitCast(AI, IGM.OpaquePtrTy->getPointerTo());

test/IRGen/alloc_stack.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %target-swift-frontend -assume-parsing-unqualified-ownership-sil -primary-file %s -emit-ir | %FileCheck %s
2+
3+
// REQUIRES: CPU=x86_64
4+
5+
class Foobar {
6+
init() {
7+
var a : Bool = true
8+
}
9+
}
10+
11+
// Make sure we are mis-initializing the alloca.
12+
// CHECK-LABEL: define {{.*}}swiftcc %T11alloc_stack6FoobarC* @"$S11alloc_stack6FoobarCACycfc"(%T11alloc_stack6FoobarC* swiftself)
13+
// CHECK-NOT: store{{.*}}opaque
14+
// CHECK: ret {{.*}}%0
15+
// CHECK:}
16+

0 commit comments

Comments
 (0)