[compiler-rt] 94e0975 - [ORC] Drop 'const' for __orc_rt_CWrapperFunctionResultDataUnion::ValuePtr.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 19 04:04:56 PDT 2021
Author: Lang Hames
Date: 2021-07-19T21:03:12+10:00
New Revision: 94e0975450daa57060248c2231ea8bf902b3e86a
URL: https://github.com/llvm/llvm-project/commit/94e0975450daa57060248c2231ea8bf902b3e86a
DIFF: https://github.com/llvm/llvm-project/commit/94e0975450daa57060248c2231ea8bf902b3e86a.diff
LOG: [ORC] Drop 'const' for __orc_rt_CWrapperFunctionResultDataUnion::ValuePtr.
This member is now only used when storage is heap-allocated so it does not
need to be const. Dropping 'const' eliminates cast warnings on many builders.
Added:
Modified:
compiler-rt/lib/orc/c_api.h
Removed:
################################################################################
diff --git a/compiler-rt/lib/orc/c_api.h b/compiler-rt/lib/orc/c_api.h
index 6da616c869aa..6677da06ede5 100644
--- a/compiler-rt/lib/orc/c_api.h
+++ b/compiler-rt/lib/orc/c_api.h
@@ -49,7 +49,7 @@
ORC_RT_C_EXTERN_C_BEGIN
typedef union {
- const char *ValuePtr;
+ char *ValuePtr;
char Value[sizeof(ValuePtr)];
} __orc_rt_CWrapperFunctionResultDataUnion;
@@ -94,14 +94,12 @@ __orc_rt_CWrapperFunctionResultInit(__orc_rt_CWrapperFunctionResult *R) {
static inline char *
__orc_rt_CWrapperFunctionResultAllocate(__orc_rt_CWrapperFunctionResult *R,
size_t Size) {
- char *DataPtr;
R->Size = Size;
- if (Size > sizeof(R->Data.Value)) {
- DataPtr = (char *)malloc(Size);
- R->Data.ValuePtr = DataPtr;
- } else
- DataPtr = R->Data.Value;
- return DataPtr;
+ if (Size <= sizeof(R->Data.Value))
+ return R->Data.Value;
+
+ R->Data.ValuePtr = (char *)malloc(Size);
+ return R->Data.ValuePtr;
}
/**
@@ -158,7 +156,7 @@ static inline void
__orc_rt_DisposeCWrapperFunctionResult(__orc_rt_CWrapperFunctionResult *R) {
if (R->Size > sizeof(R->Data.Value) ||
(R->Size == 0 && R->Data.ValuePtr))
- free((void *)R->Data.ValuePtr);
+ free(R->Data.ValuePtr);
}
/**
More information about the llvm-commits
mailing list