From 2fe29882fa35d01818388ba1528f8a0524d07719 Mon Sep 17 00:00:00 2001 From: foreman Date: Tue, 16 Sep 2014 09:39:53 -0400 Subject: [PATCH] P4 to Git Change 1077270 by emankov@em-hsa-amd on 2014/09/16 09:26:09 ECR #333753 - Compiler Lib: Bug fix in string options comparison Tests: smoke, precheck-in Reviewer: Brian Sumner, Artem Tamazov Affected files ... ... //depot/stg/opencl/drivers/opencl/compiler/lib/utils/options.cpp#30 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/utils/options.hpp#15 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpucompiler.cpp#149 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuprogram.cpp#176 edit [ROCm/clr commit: 9c02c73c2fb79fb31045d2bdfe0e4d181dc29355] --- projects/clr/rocclr/compiler/lib/utils/options.cpp | 8 ++++++-- projects/clr/rocclr/compiler/lib/utils/options.hpp | 2 +- projects/clr/rocclr/runtime/device/gpu/gpuprogram.cpp | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/projects/clr/rocclr/compiler/lib/utils/options.cpp b/projects/clr/rocclr/compiler/lib/utils/options.cpp index 0d1e309202..5ab7c7c64a 100644 --- a/projects/clr/rocclr/compiler/lib/utils/options.cpp +++ b/projects/clr/rocclr/compiler/lib/utils/options.cpp @@ -1489,10 +1489,14 @@ Options::getDumpFileName(const std::string& ext) } bool -Options::isCStrEqual(const char *cs1, const char* cs2) +Options::isCStrOptionsEqual(const char *cs1, const char* cs2) const { if ((cs1 != NULL) && (cs2 != NULL)) { return (strcmp(cs1, cs2) == 0); + } else if ((cs1 == NULL || strcmp(cs1,"") == 0) && + (cs2 == NULL || strcmp(cs2,"") == 0)) { + // consider empty string and NULL ptr (no string) as equal + return true; } return false; } @@ -1527,7 +1531,7 @@ bool Options::equals(const Options& other, bool ignoreClcOptions) const else if (OPTION_type(od) == OT_CSTRING) { OT_CSTRING_t* o = reinterpret_cast(addr); OT_CSTRING_t* o2 = reinterpret_cast(addr2); - if (*o != *o2) return false; + if (!isCStrOptionsEqual(*o,*o2)) return false; } else { return false; diff --git a/projects/clr/rocclr/compiler/lib/utils/options.hpp b/projects/clr/rocclr/compiler/lib/utils/options.hpp index 29d40b9483..6897762f58 100644 --- a/projects/clr/rocclr/compiler/lib/utils/options.hpp +++ b/projects/clr/rocclr/compiler/lib/utils/options.hpp @@ -263,7 +263,7 @@ public: std::string getDumpFileName(const std::string& ext); void setPerBuildInfo(const char* val, int encrypt, bool device); - bool isCStrEqual(const char *cs1, const char* cs2); + bool isCStrOptionsEqual(const char *cs1, const char* cs2) const; bool useDefaultWGS() { return UseDefaultWGS; } diff --git a/projects/clr/rocclr/runtime/device/gpu/gpuprogram.cpp b/projects/clr/rocclr/runtime/device/gpu/gpuprogram.cpp index 09b3afb24c..a2991b3c5c 100644 --- a/projects/clr/rocclr/runtime/device/gpu/gpuprogram.cpp +++ b/projects/clr/rocclr/runtime/device/gpu/gpuprogram.cpp @@ -1300,7 +1300,7 @@ NullProgram::parseAllILFuncs(const std::string& source) { bool doPatch = true; amd::option::Options *opts = getCompilerOptions(); - if (opts->isCStrEqual(opts->oVariables->XLang, "il")) { + if (opts->isCStrOptionsEqual(opts->oVariables->XLang, "il")) { doPatch = false; } // Find the patch position