[JITLink] Fix think-o in handwritten CWrapperFunctionResult -> Error converter.
authorLang Hames <lhames@gmail.com>
Fri, 12 Nov 2021 16:46:03 +0000 (08:46 -0800)
committerLang Hames <lhames@gmail.com>
Fri, 12 Nov 2021 18:36:17 +0000 (10:36 -0800)
We need to skip the length field when generating error strings.

No test case: This hand-hacked deserializer should be removed in the near future
once JITLink can use generic ORC APIs (including SPS and WrapperFunction).

llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp

index 0e5ed8e3d1ce3a83d0eb66c02f14cb4d06ec4b66..4fb349255f75c0fb4842a8b720a5b9b1ec936263 100644 (file)
@@ -40,8 +40,9 @@ Error toError(CWrapperFunctionResult R) {
     char *Content = Large ? R.Data.ValuePtr : R.Data.Value;
     if (Content[0]) {
       HasError = true;
-      ErrMsg.resize(R.Size - 1);
-      memcpy(&ErrMsg[0], Content + 1, R.Size - 1);
+      constexpr unsigned StrStart = 1 + sizeof(uint64_t);
+      ErrMsg.resize(R.Size - StrStart);
+      memcpy(&ErrMsg[0], Content + StrStart, R.Size - StrStart);
     }
     if (Large)
       free(R.Data.ValuePtr);