
Currently iterators over EquivalenceClasses will iterate over std::set, which guarantees the order specified by the comperator. Unfortunately in many cases, EquivalenceClasses are used with pointers, so iterating over std::set of pointers will not be deterministic across runs. There are multiple places that explicitly try to sort the equivalence classes before using them to try to get a deterministic order (LowerTypeTests, SplitModule), but there are others that do not at the moment and this can result at least in non-determinstic value naming in Float2Int. This patch updates EquivalenceClasses to keep track of all members via a extra SmallVector and removes code from LowerTypeTests and SplitModule to sort the classes before processing. Overall it looks like compile-time slightly decreases in most cases, but close to noise: https://llvm-compile-time-tracker.com/compare.php?from=7d441d9892295a6eb8aaf481e1715f039f6f224f&to=b0c2ac67a88d3ef86987e2f82115ea0170675a17&stat=instructions PR: https://github.com/llvm/llvm-project/pull/134075
54 lines
1.2 KiB
LLVM
54 lines
1.2 KiB
LLVM
; RUN: opt -S -passes=lowertypetests %s | llc -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-keep-registers | FileCheck %s
|
|
|
|
; Tests that we correctly assign indexes for control flow integrity.
|
|
|
|
target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
|
|
target triple = "wasm32-unknown-unknown"
|
|
|
|
@0 = private unnamed_addr constant [2 x ptr] [ptr @f, ptr @g], align 16
|
|
|
|
; CHECK-LABEL: h:
|
|
; CHECK-NOT: .indidx
|
|
define void @h() !type !0 {
|
|
ret void
|
|
}
|
|
|
|
; CHECK-LABEL: f:
|
|
; CHECK: .indidx 2
|
|
define void @f() !type !0 {
|
|
ret void
|
|
}
|
|
|
|
; CHECK-LABEL: g:
|
|
; CHECK: .indidx 1
|
|
define void @g() !type !1 {
|
|
ret void
|
|
}
|
|
|
|
!0 = !{i32 0, !"typeid1"}
|
|
!1 = !{i32 0, !"typeid2"}
|
|
|
|
declare i1 @llvm.type.test(ptr %ptr, metadata %bitset) nounwind readnone
|
|
declare void @llvm.trap() nounwind noreturn
|
|
|
|
; CHECK-LABEL: foo:
|
|
; CHECK: br_if
|
|
; CHECK: br_if
|
|
; CHECK: unreachable
|
|
define i1 @foo(ptr %p) {
|
|
%x = call i1 @llvm.type.test(ptr %p, metadata !"typeid1")
|
|
br i1 %x, label %contx, label %trap
|
|
|
|
trap:
|
|
tail call void @llvm.trap() #1
|
|
unreachable
|
|
|
|
contx:
|
|
%y = call i1 @llvm.type.test(ptr %p, metadata !"typeid2")
|
|
br i1 %y, label %conty, label %trap
|
|
|
|
conty:
|
|
%z = add i1 %x, %y
|
|
ret i1 %z
|
|
}
|