Skip to content

Commit e43d3d7

Browse files
committed
fix pathsolver
1 parent f57ada2 commit e43d3d7

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lifter/PathSolver.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,14 @@ PATH_info lifterClass::solvePath(Function* function, uint64_t& dest,
155155
return nullopt;
156156
};
157157
Value* condition = nullptr;
158+
159+
// condition value is a kind of hack
160+
// 1- if its a select, we can extract the condition
161+
// 1a- if firstcase is in the select, extract the condition
162+
// 1b- if secondcase is in the select, extract the condition and reverse
163+
// values
164+
// 2- create a hacky compare for condition == potentialvalue
165+
158166
if (auto can_simplify = try_simplify(firstcase, simplifyValue))
159167
condition = can_simplify.value();
160168
else if (auto can_simplify2 = try_simplify(secondcase, simplifyValue)) {
@@ -166,21 +174,21 @@ PATH_info lifterClass::solvePath(Function* function, uint64_t& dest,
166174
builder.getIntN(simplifyValue->getType()->getIntegerBitWidth(),
167175
firstcase.getZExtValue()));
168176
printvalue(condition);
169-
auto BR = builder.CreateCondBr(condition, bb_false, bb_true);
177+
auto BR = builder.CreateCondBr(condition, bb_true, bb_false);
170178

171179
RegisterBranch(BR);
172180

173181
printvalue2(firstcase);
174182
printvalue2(secondcase);
175-
blockInfo = BBInfo(secondcase.getZExtValue(), bb_true);
183+
blockInfo = BBInfo(secondcase.getZExtValue(), bb_false);
176184
// for [this], we can assume condition is true
177185
// we can simplify any value tied to is dependent on condition,
178186
// and try to simplify any value calculates condition
179187

180188
lifterClass* newlifter = new lifterClass(*this);
181189

182190
// for [newlifter], we can assume condition is false
183-
newlifter->blockInfo = BBInfo(firstcase.getZExtValue(), bb_false);
191+
newlifter->blockInfo = BBInfo(firstcase.getZExtValue(), bb_true);
184192
printvalue(condition);
185193
newlifter->assumptions[cast<Instruction>(condition)] = 1;
186194

0 commit comments

Comments
 (0)