diff options
author | Kostya Serebryany <kcc@google.com> | 2015-08-11 00:24:39 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2015-08-11 00:24:39 +0000 |
commit | 2569118621228f811d9dbaba447063e97cc3ae76 (patch) | |
tree | c9752330f1bc84270c876587f657435df56b6340 | |
parent | 7742b8ba15aa923b8be8347c5a20c4e88f15c5a0 (diff) | |
download | bcm5719-llvm-2569118621228f811d9dbaba447063e97cc3ae76.tar.gz bcm5719-llvm-2569118621228f811d9dbaba447063e97cc3ae76.zip |
[libFuzzer] don't crash if the condition in a switch has unusual type (e.g. i72)
llvm-svn: 244544
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp | 3 | ||||
-rw-r--r-- | llvm/test/Instrumentation/SanitizerCoverage/switch-tracing.ll | 24 |
2 files changed, 27 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp index c91b89df830..b6829aef2d5 100644 --- a/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp +++ b/llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp @@ -375,6 +375,9 @@ void SanitizerCoverageModule::InjectTraceForSwitch( IRBuilder<> IRB(I); SmallVector<Constant *, 16> Initializers; Value *Cond = SI->getCondition(); + if (Cond->getType()->getScalarSizeInBits() > + Int64Ty->getScalarSizeInBits()) + continue; Initializers.push_back(ConstantInt::get(Int64Ty, SI->getNumCases())); Initializers.push_back( ConstantInt::get(Int64Ty, Cond->getType()->getScalarSizeInBits())); diff --git a/llvm/test/Instrumentation/SanitizerCoverage/switch-tracing.ll b/llvm/test/Instrumentation/SanitizerCoverage/switch-tracing.ll index 9ad1c7acf63..aac56dbdeb7 100644 --- a/llvm/test/Instrumentation/SanitizerCoverage/switch-tracing.ll +++ b/llvm/test/Instrumentation/SanitizerCoverage/switch-tracing.ll @@ -30,3 +30,27 @@ sw.bb.2: ; preds = %entry sw.epilog: ; preds = %entry, %sw.bb.2, %sw.bb.1, %sw.bb ret void } + +define void @fooi72(i72 %x) { +entry: + switch i72 %x, label %sw.epilog [ + i72 1, label %sw.bb + i72 101, label %sw.bb.1 + i72 1001, label %sw.bb.2 + ] + +sw.bb: ; preds = %entry + tail call void @_Z3bari(i32 4) + br label %sw.epilog + +sw.bb.1: ; preds = %entry + tail call void @_Z3bari(i32 5) + br label %sw.epilog + +sw.bb.2: ; preds = %entry + tail call void @_Z3bari(i32 6) + br label %sw.epilog + +sw.epilog: ; preds = %entry, %sw.bb.2, %sw.bb.1, %sw.bb + ret void +} |