Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/IRGen/GenConstant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,13 @@ Explosion irgen::emitConstantValue(IRGenModule &IGM, SILValue operand,
strategy.emitValueInjection(IGM, builder, ei->getElement(), data, out);
return replaceUnalignedIntegerValues(IGM, std::move(out));
} else if (auto *ILI = dyn_cast<IntegerLiteralInst>(operand)) {
if (ILI->getType().is<BuiltinIntegerLiteralType>()) {
auto pair = emitConstantIntegerLiteral(IGM, ILI);
Explosion e;
e.add(pair.Data);
e.add(pair.Flags);
return e;
}
return emitConstantInt(IGM, ILI);
} else if (auto *FLI = dyn_cast<FloatLiteralInst>(operand)) {
return emitConstantFP(IGM, FLI);
Expand Down
28 changes: 28 additions & 0 deletions test/SILOptimizer/static_bigint_enums.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// RUN: %target-build-swift -parse-as-library -O %s -module-name=test -emit-sil | %FileCheck %s

// RUN: %empty-directory(%t)
// RUN: %target-build-swift -parse-as-library -O -module-name=test %s -o %t/a.out
// RUN: %target-run %t/a.out | %FileCheck %s -check-prefix=CHECK-OUTPUT

// REQUIRES: executable_test,swift_stdlib_no_asserts,optimized_stdlib
// UNSUPPORTED: use_os_stdlib


@available(SwiftStdlib 5.8, *)
public enum StaticIntStringEnum {
case s(StaticString)
case i(StaticBigInt)

// CHECK-LABEL: sil_global hidden @$s4test19StaticIntStringEnumO1xACvpZ : $StaticIntStringEnum = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you pass -check-prefix to FileCheck, I believe it suppresses the default CHECK prefix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. This check line is for the first compiler run (see line 1)

static var x = Self.i(27)
}

@available(SwiftStdlib 5.8, *)
@main
struct Main {
static func main() {
// CHECK-OUTPUT: StaticIntStringEnum: i(+0x1B)
print("StaticIntStringEnum:", StaticIntStringEnum.x)
}
}