
D150464 updated the cost model for function specialization. Unfortunately, this also crashes when trying to build stage2 LLD with thinLTO and assertions. It looks like the issue is caused by a mishandling of the Constant in a SwitchInst since the Constant cannot always be assumed to safely casted to a ConstantInt. In the case of the crash, Constant was a ConstantExpr which triggered the assertion. Reviewed By: ChuanqiXu Differential Revision: https://reviews.llvm.org/D154159
23 lines
420 B
LLVM
23 lines
420 B
LLVM
; RUN: opt -passes="ipsccp<func-spec>" -force-specialization -S < %s
|
|
; Check that we don't crash when SwitchInst Constant is not ConstantInt.
|
|
|
|
@S = external constant [1 x i8]
|
|
|
|
define i1 @foo() {
|
|
entry:
|
|
%tmp = call i32 @bar(ptr @S)
|
|
ret i1 0
|
|
}
|
|
|
|
define i32 @bar(ptr %arg) {
|
|
entry:
|
|
%magicptr = ptrtoint ptr %arg to i64
|
|
switch i64 %magicptr, label %bb2 [
|
|
i64 0, label %bb1
|
|
]
|
|
bb1:
|
|
ret i32 0
|
|
bb2:
|
|
ret i32 1
|
|
}
|