[llvm] r244544 - [libFuzzer] don't crash if the condition in a switch has unusual type (e.g. i72)

Kostya Serebryany via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 10 17:24:39 PDT 2015


Author: kcc
Date: Mon Aug 10 19:24:39 2015
New Revision: 244544

URL: http://llvm.org/viewvc/llvm-project?rev=244544&view=rev
Log:
[libFuzzer] don't crash if the condition in a switch has unusual type (e.g. i72)

Modified:
    llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
    llvm/trunk/test/Instrumentation/SanitizerCoverage/switch-tracing.ll

Modified: llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp?rev=244544&r1=244543&r2=244544&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp Mon Aug 10 19:24:39 2015
@@ -375,6 +375,9 @@ void SanitizerCoverageModule::InjectTrac
       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()));

Modified: llvm/trunk/test/Instrumentation/SanitizerCoverage/switch-tracing.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Instrumentation/SanitizerCoverage/switch-tracing.ll?rev=244544&r1=244543&r2=244544&view=diff
==============================================================================
--- llvm/trunk/test/Instrumentation/SanitizerCoverage/switch-tracing.ll (original)
+++ llvm/trunk/test/Instrumentation/SanitizerCoverage/switch-tracing.ll Mon Aug 10 19:24:39 2015
@@ -30,3 +30,27 @@ sw.bb.2:
 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
+}




More information about the llvm-commits mailing list