From d82ada89fee37068b0ff44f340338af3fc07cc37 Mon Sep 17 00:00:00 2001 From: van Hauser Date: Tue, 5 May 2020 14:08:24 +0200 Subject: support older llvm versions --- llvm_mode/compare-transform-pass.so.cc | 42 ++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 17 deletions(-) (limited to 'llvm_mode/compare-transform-pass.so.cc') diff --git a/llvm_mode/compare-transform-pass.so.cc b/llvm_mode/compare-transform-pass.so.cc index 9cf4169e..10413076 100644 --- a/llvm_mode/compare-transform-pass.so.cc +++ b/llvm_mode/compare-transform-pass.so.cc @@ -211,20 +211,24 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp, } // not literal? maybe global or local variable - if (!(HasStr1 ^ HasStr2)) { + if (!(HasStr1 || HasStr2)) { auto *Ptr = dyn_cast(Str2P); if (Ptr && Ptr->isGEPWithNoNotionalOverIndexing()) { if (auto *Var = dyn_cast(Ptr->getOperand(0))) { - if (auto *Array = - dyn_cast(Var->getInitializer())) { + if (Var->hasInitializer()) { - HasStr2 = true; - Str2 = Array->getAsString(); - valueMap[Str2P] = new std::string(Str2.str()); - // fprintf(stderr, "glo2 %s\n", Str2.str().c_str()); + if (auto *Array = + dyn_cast(Var->getInitializer())) { + + HasStr2 = true; + Str2 = Array->getAsString(); + valueMap[Str2P] = new std::string(Str2.str()); + fprintf(stderr, "glo2 %s\n", Str2.str().c_str()); + + } } @@ -239,13 +243,17 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp, if (auto *Var = dyn_cast(Ptr->getOperand(0))) { - if (auto *Array = - dyn_cast(Var->getInitializer())) { + if (Var->hasInitializer()) { + + if (auto *Array = dyn_cast( + Var->getInitializer())) { + + HasStr1 = true; + Str1 = Array->getAsString(); + valueMap[Str1P] = new std::string(Str1.str()); + // fprintf(stderr, "glo1 %s\n", Str1.str().c_str()); - HasStr1 = true; - Str1 = Array->getAsString(); - valueMap[Str1P] = new std::string(Str1.str()); - // fprintf(stderr, "glo1 %s\n", Str1.str().c_str()); + } } @@ -260,13 +268,13 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp, } - if ((HasStr1 ^ HasStr2)) indirect = true; + if ((HasStr1 || HasStr2)) indirect = true; } if (isIntMemcpy) continue; - if (!(HasStr1 ^ HasStr2)) { + if (!(HasStr1 || HasStr2)) { // do we have a saved local variable initialization? std::string *val = valueMap[Str1P]; @@ -294,7 +302,7 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp, } /* handle cases of one string is const, one string is variable */ - if (!(HasStr1 ^ HasStr2)) continue; + if (!(HasStr1 || HasStr2)) continue; if (isMemcmp || isStrncmp || isStrncasecmp) { @@ -359,7 +367,7 @@ bool CompareTransform::transformCmps(Module &M, const bool processStrcmp, } - if (!(HasStr1 ^ HasStr2)) { + if (!(HasStr1 || HasStr2)) { // do we have a saved local or global variable initialization? std::string *val = valueMap[Str1P]; -- cgit 1.4.1