@@ -674,7 +674,7 @@ bool CheckHashRange(const std::vector<HashRange>& hashes)
674674 return false ;
675675}
676676
677- static void LoadFromRegKeyOrEnvVarOrOptions (const std::string& options = " " , std::string registrykeypath = IGC_REGISTRY_KEY)
677+ static void LoadFromRegKeyOrEnvVarOrOptions (const std::string& options = " " , bool * RegFlagNameError = nullptr , std::string registrykeypath = IGC_REGISTRY_KEY)
678678{
679679 SRegKeyVariableMetaData* pRegKeyVariable = (SRegKeyVariableMetaData*)&g_RegKeyList;
680680 unsigned NUM_REGKEY_ENTRIES = sizeof (SRegKeysList) / sizeof (SRegKeyVariableMetaData);
@@ -703,32 +703,39 @@ static void LoadFromRegKeyOrEnvVarOrOptions(const std::string& options = "", std
703703 std::size_t foundComma = options.find (' ,' , found);
704704 if (foundComma != std::string::npos)
705705 {
706- std::string token = options.substr (found + nameWithEqual.size (), foundComma - (found + nameWithEqual.size ()));
707- unsigned int size = sizeof (value);
708- void * pValueFromOptions = &valueFromOptions;
709-
710- const char * envValFromOptions = token.c_str ();
711- bool valueIsInt = false ;
712- if (envValFromOptions != NULL )
706+ if (found == 0 || options[found - 1 ] == ' ' || options[found - 1 ] == ' ,' )
713707 {
714- if (size >= sizeof (unsigned int ))
708+ std::string token = options.substr (found + nameWithEqual.size (), foundComma - (found + nameWithEqual.size ()));
709+ unsigned int size = sizeof (value);
710+ void * pValueFromOptions = &valueFromOptions;
711+
712+ const char * envValFromOptions = token.c_str ();
713+ bool valueIsInt = false ;
714+ if (envValFromOptions != NULL )
715715 {
716- // Try integer conversion
717- char * pStopped = nullptr ;
718- unsigned int * puValFromOptions = (unsigned int *)pValueFromOptions;
719- *puValFromOptions = strtoul (envValFromOptions, &pStopped, 0 );
720- if (pStopped == envValFromOptions + strlen (envValFromOptions))
716+ if (size >= sizeof (unsigned int ))
721717 {
722- valueIsInt = true ;
718+ // Try integer conversion
719+ char * pStopped = nullptr ;
720+ unsigned int * puValFromOptions = (unsigned int *)pValueFromOptions;
721+ *puValFromOptions = strtoul (envValFromOptions, &pStopped, 0 );
722+ if (pStopped == envValFromOptions + strlen (envValFromOptions))
723+ {
724+ valueIsInt = true ;
725+ }
726+ }
727+ if (!valueIsInt)
728+ {
729+ // Just return the string
730+ strncpy_s ((char *)pValueFromOptions, size, envValFromOptions, size);
723731 }
724732 }
725- if (!valueIsInt)
726- {
727- // Just return the string
728- strncpy_s (( char *)pValueFromOptions, size, envValFromOptions, size);
729- }
733+ memcpy_s (pRegKeyVariable[i]. m_string , sizeof (valueFromOptions), valueFromOptions, sizeof (valueFromOptions));
734+ }
735+ else if (RegFlagNameError != nullptr )
736+ {
737+ *RegFlagNameError = true ;
730738 }
731- memcpy_s (pRegKeyVariable[i].m_string , sizeof (valueFromOptions), valueFromOptions, sizeof (valueFromOptions));
732739 }
733740 }
734741 }
@@ -754,7 +761,7 @@ void SetCurrentDebugHash(unsigned long long hash)
754761 None
755762
756763\*****************************************************************************/
757- void LoadRegistryKeys (const std::string& options)
764+ void LoadRegistryKeys (const std::string& options, bool *RegFlagNameError )
758765{
759766 // only load the debug flags once before compiling to avoid any multi-threading issue
760767 static std::mutex loadFlags;
@@ -772,12 +779,12 @@ void LoadRegistryKeys(const std::string& options)
772779 {
773780 std::string driverStoreRegKeyPath = getNewRegistryPath (driverInfo);
774781 std::string registryKeyPath = " SYSTEM\\ ControlSet001\\ Control\\ Class\\ " + driverStoreRegKeyPath + " \\ IGC" ;
775- LoadFromRegKeyOrEnvVarOrOptions (options, registryKeyPath);
782+ LoadFromRegKeyOrEnvVarOrOptions (options, RegFlagNameError, registryKeyPath);
776783 }
777784#endif
778785 // DumpIGCRegistryKeyDefinitions();
779786 LoadDebugFlagsFromFile ();
780- LoadFromRegKeyOrEnvVarOrOptions (options);
787+ LoadFromRegKeyOrEnvVarOrOptions (options, RegFlagNameError );
781788
782789 if (IGC_IS_FLAG_ENABLED (LLVMCommandLine))
783790 {
0 commit comments