mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-03-04 02:18:46 +00:00
[sanitizer-coverage] sort the switch cases
llvm-svn: 290628
This commit is contained in:
parent
2cd4d50d15
commit
aece9ad2f5
@ -601,6 +601,11 @@ void SanitizerCoverageModule::InjectTraceForSwitch(
|
||||
C = ConstantExpr::getCast(CastInst::ZExt, It.getCaseValue(), Int64Ty);
|
||||
Initializers.push_back(C);
|
||||
}
|
||||
std::sort(Initializers.begin() + 2, Initializers.end(),
|
||||
[](const Constant *A, const Constant *B) {
|
||||
return cast<ConstantInt>(A)->getLimitedValue() <
|
||||
cast<ConstantInt>(B)->getLimitedValue();
|
||||
});
|
||||
ArrayType *ArrayOfInt64Ty = ArrayType::get(Int64Ty, Initializers.size());
|
||||
GlobalVariable *GV = new GlobalVariable(
|
||||
*CurModule, ArrayOfInt64Ty, false, GlobalVariable::InternalLinkage,
|
||||
|
@ -11,8 +11,8 @@ entry:
|
||||
; CHECK-NEXT: call void @__sanitizer_cov_trace_switch(i64 [[TMP]], i64* getelementptr inbounds ([5 x i64], [5 x i64]* @__sancov_gen_cov_switch_values, i32 0, i32 0))
|
||||
switch i32 %x, label %sw.epilog [
|
||||
i32 1, label %sw.bb
|
||||
i32 101, label %sw.bb.1
|
||||
i32 1001, label %sw.bb.2
|
||||
i32 1001, label %sw.bb.1
|
||||
i32 101, label %sw.bb.2
|
||||
]
|
||||
|
||||
sw.bb: ; preds = %entry
|
||||
|
Loading…
x
Reference in New Issue
Block a user