Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Moore][NFC] Fix warning when building Moore components #7566

Merged
merged 3 commits into from
Sep 4, 2024

Conversation

cepheus69
Copy link

The original building warning:

[814/1036] Building CXX object lib/Dialect/Moore/CMakeFiles/obj.CIRCTMoore.dir/MooreOps.cpp.o
In file included from /home/ursa/Projects/circt/lib/Dialect/Moore/MooreOps.cpp:13:
In file included from /home/ursa/Projects/circt/include/circt/Dialect/Moore/MooreOps.h:16:
In file included from /home/ursa/Projects/circt/include/circt/Dialect/HW/HWTypes.h:17:
In file included from /home/ursa/Projects/circt/include/circt/Dialect/HW/HWDialect.h:16:
In file included from /home/ursa/Projects/circt/include/circt/Support/LLVM.h:22:
In file included from /home/ursa/Projects/circt/llvm/mlir/include/mlir/Support/LLVM.h:23:
/home/ursa/Projects/circt/llvm/llvm/include/llvm/Support/Casting.h:490:69: warning: returning reference to local temporary object [-Wreturn-stack-address]
  490 |   static inline CastReturnType castFailed() { return CastReturnType(nullptr); }
      |                                                                     ^~~~~~~
/home/ursa/Projects/circt/llvm/llvm/include/llvm/Support/Casting.h:494:14: note: in instantiation of member function 'llvm::CastInfo<circt::moore::SVModuleOp, const circt::moore::SVModuleOp>::castFailed' requested here
  494 |       return castFailed();
      |              ^
/home/ursa/Projects/circt/llvm/llvm/include/llvm/Support/Casting.h:651:36: note: in instantiation of member function 'llvm::CastInfo<circt::moore::SVModuleOp, const circt::moore::SVModuleOp>::doCastIfPossible' requested here
  651 |   return CastInfo<To, const From>::doCastIfPossible(Val);
      |                                    ^
1 warning generated.

The main problem is handling the result coming from the cast function. To check if the pointer pointing to a module op is a nullptr. This commit rewrites the appropriate code to fix the warning.

The corresponding code snippet has a problem for checking whether the
pointer pointing to a module op is a nullptr. This commit rewrites its
code to fix the warning.
Copy link
Member

@hailongSun2000 hailongSun2000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@hailongSun2000 hailongSun2000 merged commit b441059 into llvm:main Sep 4, 2024
4 checks passed
@cepheus69 cepheus69 deleted the buyun/fix-moore-warning branch September 4, 2024 03:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants