Skip to content

Commit ce4a7c4

Browse files
authored
LowerTypeTests: Stop creating inline bitset tests on 32-bit architectures.
Tests with a 64-bit inline bitset are not only unlikely to be beneficial on 32-bit architectures but with ThinLTO we are unable to export them correctly, resulting in a miscompile. Reviewers: fmayer Reviewed By: fmayer Pull Request: #143458
1 parent 474db6a commit ce4a7c4

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

llvm/lib/Transforms/IPO/LowerTypeTests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,7 @@ void LowerTypeTestsModule::lowerTypeTestCalls(
11731173
if (BSI.isAllOnes()) {
11741174
TIL.TheKind = (BSI.BitSize == 1) ? TypeTestResolution::Single
11751175
: TypeTestResolution::AllOnes;
1176-
} else if (BSI.BitSize <= 64) {
1176+
} else if (BSI.BitSize <= IntPtrTy->getBitWidth()) {
11771177
TIL.TheKind = TypeTestResolution::Inline;
11781178
uint64_t InlineBits = 0;
11791179
for (auto Bit : BSI.Bits)

llvm/test/Transforms/LowerTypeTests/export-inline.ll

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
; RUN: opt -mtriple=x86_64-unknown-linux -S -passes=lowertypetests -lowertypetests-summary-action=export -lowertypetests-read-summary=%S/Inputs/use-typeid1-typeid2.yaml -lowertypetests-write-summary=%t %s | FileCheck --check-prefix=CHECK %s
2-
; RUN: FileCheck --check-prefixes=SUMMARY,SUMMARY-X86 %s < %t
1+
; RUN: opt -mtriple=i686-unknown-linux -S -passes=lowertypetests -lowertypetests-summary-action=export -lowertypetests-read-summary=%S/Inputs/use-typeid1-typeid2.yaml -lowertypetests-write-summary=%t %s | FileCheck --check-prefixes=CHECK,CHECK-X86-32 %s
2+
; RUN: FileCheck --check-prefixes=SUMMARY,SUMMARY-X86,SUMMARY-X86-32 %s < %t
33

4-
; RUN: opt -mtriple=aarch64-unknown-linux -S -passes=lowertypetests -lowertypetests-summary-action=export -lowertypetests-read-summary=%S/Inputs/use-typeid1-typeid2.yaml -lowertypetests-write-summary=%t %s | FileCheck --check-prefix=CHECK %s
5-
; RUN: FileCheck --check-prefixes=SUMMARY,SUMMARY-ARM %s < %t
4+
; RUN: opt -mtriple=x86_64-unknown-linux -S -passes=lowertypetests -lowertypetests-summary-action=export -lowertypetests-read-summary=%S/Inputs/use-typeid1-typeid2.yaml -lowertypetests-write-summary=%t %s | FileCheck --check-prefixes=CHECK,CHECK-64 %s
5+
; RUN: FileCheck --check-prefixes=SUMMARY,SUMMARY-X86,SUMMARY-64 %s < %t
6+
7+
; RUN: opt -mtriple=aarch64-unknown-linux -S -passes=lowertypetests -lowertypetests-summary-action=export -lowertypetests-read-summary=%S/Inputs/use-typeid1-typeid2.yaml -lowertypetests-write-summary=%t %s | FileCheck --check-prefixes=CHECK,CHECK-64 %s
8+
; RUN: FileCheck --check-prefixes=SUMMARY,SUMMARY-64,SUMMARY-ARM %s < %t
69

710
@foo = constant [2048 x i8] zeroinitializer, !type !0, !type !1, !type !2, !type !3
811

@@ -13,15 +16,19 @@
1316

1417
; CHECK: [[G:@[0-9]+]] = private constant { [2048 x i8] } zeroinitializer
1518

16-
; CHECK: @__typeid_typeid1_global_addr = hidden alias i8, getelementptr (i8, ptr [[G]], i64 6)
19+
; CHECK-X86-32: @__typeid_typeid1_global_addr = hidden alias i8, getelementptr (i8, ptr [[G]], i32 6)
20+
; CHECK-64: @__typeid_typeid1_global_addr = hidden alias i8, getelementptr (i8, ptr [[G]], i64 6)
1721
; CHECK-X86: @__typeid_typeid1_align = hidden alias i8, inttoptr (i8 1 to ptr)
1822
; CHECK-X86: @__typeid_typeid1_size_m1 = hidden alias i8, inttoptr (i64 3 to ptr)
1923
; CHECK-X86: @__typeid_typeid1_inline_bits = hidden alias i8, inttoptr (i32 9 to ptr)
2024

21-
; CHECK: @__typeid_typeid2_global_addr = hidden alias i8, getelementptr (i8, ptr [[G]], i64 136)
25+
; CHECK-X86-32: @__typeid_typeid2_global_addr = hidden alias i8, getelementptr (i8, ptr [[G]], i32 136)
26+
; CHECK-64: @__typeid_typeid2_global_addr = hidden alias i8, getelementptr (i8, ptr [[G]], i64 136)
2227
; CHECK-X86: @__typeid_typeid2_align = hidden alias i8, inttoptr (i8 2 to ptr)
2328
; CHECK-X86: @__typeid_typeid2_size_m1 = hidden alias i8, inttoptr (i64 33 to ptr)
24-
; CHECK-X86: @__typeid_typeid2_inline_bits = hidden alias i8, inttoptr (i64 8589934593 to ptr)
29+
; CHECK-X86-64: @__typeid_typeid2_inline_bits = hidden alias i8, inttoptr (i64 8589934593 to ptr)
30+
; CHECK-X86-32: @__typeid_typeid2_byte_array = hidden alias i8, ptr @bits
31+
; CHECK-X86-32: @__typeid_typeid2_bit_mask = hidden alias i8, inttoptr (i8 1 to ptr)
2532

2633
; CHECK: @foo = alias [2048 x i8], ptr [[G]]
2734

@@ -41,8 +48,10 @@
4148
; SUMMARY-NEXT: WPDRes:
4249
; SUMMARY-NEXT: typeid2:
4350
; SUMMARY-NEXT: TTRes:
44-
; SUMMARY-NEXT: Kind: Inline
45-
; SUMMARY-NEXT: SizeM1BitWidth: 6
51+
; SUMMARY-X86-32-NEXT: Kind: ByteArray
52+
; SUMMARY-X86-32-NEXT: SizeM1BitWidth: 7
53+
; SUMMARY-64-NEXT: Kind: Inline
54+
; SUMMARY-64-NEXT: SizeM1BitWidth: 6
4655
; SUMMARY-X86-NEXT: AlignLog2: 0
4756
; SUMMARY-X86-NEXT: SizeM1: 0
4857
; SUMMARY-X86-NEXT: BitMask: 0

0 commit comments

Comments
 (0)