bugfixes from pbst for laf-intel transformations
MODIFY
llvm_mode/compare-transform-pass.so.cc
llvm_mode/compare-transform-pass.so.cc
@@ -144,7 +144,7 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp, const
if (!isStrcmp && !isMemcmp && !isStrncmp && !isStrcasecmp && !isStrncasecmp)
continue;
- /* is a str{n,}{case,}cmp/memcmp, check is we have
+ /* is a str{n,}{case,}cmp/memcmp, check if we have
* str{case,}cmp(x, "const") or str{case,}cmp("const", x)
* strn{case,}cmp(x, "const", ..) or strn{case,}cmp("const", x, ..)
* memcmp(x, "const", ..) or memcmp("const", x, ..) */
@@ -211,6 +211,13 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp, const
VarStr = Str1P;
constLen = isMemcmp ? sizedLen : GetStringLength(Str2P);
}
+
+ /* bugfix thanks to pbst */
+ /* ignore terminating '\0' in string for strcmp */
+ if (!isSizedcmp && constLen > 0) {
+ constLen--;
+ }
+
if (isSizedcmp && constLen > sizedLen) {
constLen = sizedLen;
}

MODIFY
llvm_mode/split-switches-pass.so.cc
llvm_mode/split-switches-pass.so.cc
@@ -259,7 +259,9 @@ bool SplitSwitchesTransform::splitSwitches(Module &M) {
#else
Cases.push_back(CaseExpr(i->getCaseValue(), i->getCaseSuccessor()));
#endif
- std::vector<bool> bytesChecked(Cases[0].Val->getBitWidth() / 8, false);
+ /* bugfix thanks to pbst
+ * round up bytesChecked (in case getBitWidth() % 8 != 0) */
+ std::vector<bool> bytesChecked((7 + Cases[0].Val->getBitWidth()) / 8, false);
BasicBlock* SwitchBlock = switchConvert(Cases, bytesChecked, OrigBlock, NewDefault, Val, 0);
/* Branch to our shiny new if-then stuff... */

bugfixes from pbst for laf-intel transformations