[llvm-dev] False Negatives Wunused-function in clang found by gcc

Luke Benes via llvm-dev llvm-dev at lists.llvm.org
Mon Mar 1 15:58:25 PST 2021


By building llvm-project with gcc 7 and 10, I found multiple Wunused-function warnings that clang 11/12 missed.

All of these warnings were recently introduced, and the authors fixed many of them.   Any ideas why clang misses so many of this category? And why the ones missed are recent changes to the llvm codebase? 

-Luke


==========

 After dab953c8e44a2 with gcc 10.2.1, I see the following new warnings:

[ 65%] Building CXX object lib/Linker/CMakeFiles/LLVMLinker.dir/IRMover.cpp.o
/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp:1600:1: warning: ‘std::pair<llvm::Value*, llvm::Value*> {anonymous}::DataFlowSanitizer::getShadowOriginAddress(llvm::Value*, llvm::Align, llvm::Instruction*)’ defined but not used [-Wunused-function]
 1600 | DataFlowSanitizer::getShadowOriginAddress(Value *Addr, Align InstAlignment,
      | ^~~~~~~~~~~~~~~~~
/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp:1510:6: warning: ‘void {anonymous}::DFSanFunction::setOrigin(llvm::Instruction*, llvm::Value*)’ defined but not used [-Wunused-function]
 1510 | void DFSanFunction::setOrigin(Instruction *I, Value *Origin) {
      |      ^~~~~~~~~~~~~
/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp:1476:8: warning: ‘llvm::Value* {anonymous}::DFSanFunction::getOrigin(llvm::Value*)’ defined but not used [-Wunused-function]
 1476 | Value *DFSanFunction::getOrigin(Value *V) {
      |        ^~~~~~~~~~~~~
/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp:1469:8: warning: ‘llvm::Value* {anonymous}::DFSanFunction::getRetvalOriginTLS()’ defined but not used [-Wunused-function]
 1469 | Value *DFSanFunction::getRetvalOriginTLS() { return DFS.RetvalOriginTLS; }
      |        ^~~~~~~~~~~~~

FIX: https://github.com/llvm/llvm-project/commit/9524632fa2bf8c894e4aac27f03631a1915d84d3

==========

After bc8e262afe83, with gcc 10.1 but not clang 11, I'm seeing:

[ 21%] Building CXX object lib/MC/MCParser/CMakeFiles/LLVMMCParser.dir/MasmParser.cpp.o
/llvm/lib/MC/MCParser/MasmParser.cpp:3836:6: warning: ‘bool {anonymous}::MasmParser::emitStructValue(const {anonymous}::StructInfo&)’ defined but not used [-Wunused-function]
 3836 | bool MasmParser::emitStructValue(const StructInfo &Structure) {
      |      ^~~~~~~~~~

FIX: https://reviews.llvm.org/D83898

==========

In 931a68f26b9a3, I'm seeing the following warning with gcc7 and gcc10:
[ 70%] Building CXX object lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/RegAllocPBQP.cpp.o
/llvm/lib/CodeGen/RegAllocFast.cpp:384:6: warning: ‘bool {anonymous}::RegAllocFast::verifyRegStateMapping(const {anonymous}::RegAllocFast::LiveReg&) const’ defined but not used [-Wunused-function]
 bool RegAllocFast::verifyRegStateMapping(const LiveReg &LR) const {
      ^~~~~~~~~~~~

FIX: 0671a4c5087d40450603d9d26cf239f1a8b1367e



More information about the llvm-dev mailing list