about summary refs log tree commit diff
path: root/instrumentation/split-compares-pass.so.cc
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2024-05-14 13:18:22 +0200
committerGitHub <noreply@github.com>2024-05-14 13:18:22 +0200
commita26bb0b0f247a571cad56c9566235321cc93ba41 (patch)
treeae0d66d8a364ae4674f9a915457d83d55ed56fac /instrumentation/split-compares-pass.so.cc
parent90fbf59bf16f057e50132b81be759414787ce1a3 (diff)
parent7d3530a22ea44eba0aa578041e41980b0d9c976a (diff)
downloadafl++-a26bb0b0f247a571cad56c9566235321cc93ba41.tar.gz
Merge pull request #2090 from AFLplusplus/dev
push to stable
Diffstat (limited to 'instrumentation/split-compares-pass.so.cc')
-rw-r--r--instrumentation/split-compares-pass.so.cc11
1 files changed, 10 insertions, 1 deletions
diff --git a/instrumentation/split-compares-pass.so.cc b/instrumentation/split-compares-pass.so.cc
index 728ebc22..effafe50 100644
--- a/instrumentation/split-compares-pass.so.cc
+++ b/instrumentation/split-compares-pass.so.cc
@@ -266,8 +266,11 @@ bool SplitComparesTransform::simplifyFPCompares(Module &M) {
 
             /* this is probably not needed but we do it anyway */
             if (TyOp0 != TyOp1) { continue; }
-
             if (TyOp0->isArrayTy() || TyOp0->isVectorTy()) { continue; }
+            int constants = 0;
+            if (llvm::isa<llvm::Constant>(op0)) { ++constants; }
+            if (llvm::isa<llvm::Constant>(op1)) { ++constants; }
+            if (constants != 1) { continue; }
 
             fcomps.push_back(selectcmpInst);
 
@@ -1778,7 +1781,13 @@ bool SplitComparesTransform::runOnModule(Module &M) {
 
             auto op0 = CI->getOperand(0);
             auto op1 = CI->getOperand(1);
+            // has to valid operands
             if (!op0 || !op1) { continue; }
+            // has exactly one constant and one variable
+            int constants = 0;
+            if (dyn_cast<ConstantInt>(op0)) { ++constants; }
+            if (dyn_cast<ConstantInt>(op1)) { ++constants; }
+            if (constants != 1) { continue; }
 
             auto iTy1 = dyn_cast<IntegerType>(op0->getType());
             if (iTy1 && isa<IntegerType>(op1->getType())) {