diff --git a/lib/IRGen/GenBuiltin.cpp b/lib/IRGen/GenBuiltin.cpp index d97c0dd3f8e29..674c053f2cad6 100644 --- a/lib/IRGen/GenBuiltin.cpp +++ b/lib/IRGen/GenBuiltin.cpp @@ -980,6 +980,7 @@ if (Builtin.ID == BuiltinValueKind::id) { \ } if (Builtin.ID == BuiltinValueKind::ZeroInitializer) { + (void)args.claimAll(); // Build a zero initializer of the result type. auto valueTy = getLoweredTypeAndTypeInfo(IGF.IGM, substitutions.getReplacementTypes()[0]); diff --git a/validation-test/IRGen/builtin-zero-initializer-consume-all-args.sil b/validation-test/IRGen/builtin-zero-initializer-consume-all-args.sil new file mode 100644 index 0000000000000..bc65442b56392 --- /dev/null +++ b/validation-test/IRGen/builtin-zero-initializer-consume-all-args.sil @@ -0,0 +1,16 @@ +// RUN: %swift -module-name main %s -emit-ir | %FileCheck %s + +import Builtin + +// All we need to do here is check that we didn't run into any assertions. +// CHECK-LABEL: define swiftcc void @test +// CHECK: ret void +sil @test : $@convention(thin) () -> () { +bb0: + %0 = alloc_stack $Builtin.Int32 + %1 = builtin "zeroInitializer"(%0 : $*Builtin.Int32) : $() + dealloc_stack %0 : $*Builtin.Int32 + %t = tuple () + return %t : $() +} +