[Mlir-commits] [mlir] bcf6f64 - [mlir] Add workaround for false positive in -Wfree-nonheap-object
Fangrui Song
llvmlistbot at llvm.org
Wed Jul 21 16:16:26 PDT 2021
Author: Fangrui Song
Date: 2021-07-21T16:16:20-07:00
New Revision: bcf6f641acdbeb208ea07a9e8ded37cd5b796d26
URL: https://github.com/llvm/llvm-project/commit/bcf6f641acdbeb208ea07a9e8ded37cd5b796d26
DIFF: https://github.com/llvm/llvm-project/commit/bcf6f641acdbeb208ea07a9e8ded37cd5b796d26.diff
LOG: [mlir] Add workaround for false positive in -Wfree-nonheap-object
Restore 499571ea835daf786626a0db1e12f890b6cd8f8d
reverted by 0082764605cc0e7e0363a41ffa77d214c3157aa6.
A compiler slightly older than
"[clang][Sema] removes -Wfree-nonheap-object reference param false positive"
may report the false positive.
We need to retain the workaround a bit longer so that such compilers
can be used to compile MLIR in a warning-free way.
Added:
Modified:
mlir/lib/IR/OperationSupport.cpp
Removed:
################################################################################
diff --git a/mlir/lib/IR/OperationSupport.cpp b/mlir/lib/IR/OperationSupport.cpp
index b1feab3a60a8..cfa130233171 100644
--- a/mlir/lib/IR/OperationSupport.cpp
+++ b/mlir/lib/IR/OperationSupport.cpp
@@ -237,7 +237,9 @@ detail::OperandStorage::~OperandStorage() {
if (isDynamicStorage()) {
TrailingOperandStorage &storage = getDynamicStorage();
storage.~TrailingOperandStorage();
- free(&storage);
+ // Work around -Wfree-nonheap-object false positive fixed by D102728.
+ auto *mem = &storage;
+ free(mem);
} else {
getInlineStorage().~TrailingOperandStorage();
}
@@ -371,8 +373,11 @@ MutableArrayRef<OpOperand> detail::OperandStorage::resize(Operation *owner,
new (&newOperands[numOperands]) OpOperand(owner);
// If the current storage is also dynamic, free it.
- if (isDynamicStorage())
- free(&storage);
+ if (isDynamicStorage()) {
+ // Work around -Wfree-nonheap-object false positive fixed by D102728.
+ auto *mem = &storage;
+ free(mem);
+ }
// Update the storage representation to use the new dynamic storage.
dynamicStorage.setPointerAndInt(newStorage, true);
More information about the Mlir-commits
mailing list