[llvm] 42ffba0 - Add a clarifying a comment on CastInst::isNoopCast
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 7 12:17:20 PDT 2020
Author: Philip Reames
Date: 2020-10-07T12:17:07-07:00
New Revision: 42ffba051894a66cf6d7b9a357e765a392d983ed
URL: https://github.com/llvm/llvm-project/commit/42ffba051894a66cf6d7b9a357e765a392d983ed
DIFF: https://github.com/llvm/llvm-project/commit/42ffba051894a66cf6d7b9a357e765a392d983ed.diff
LOG: Add a clarifying a comment on CastInst::isNoopCast
I made exactly the mistake described, so document the precondition. It would be better to have an assert, but there is (currently) no "castIsValid" with purely type arguments.
Added:
Modified:
llvm/include/llvm/IR/InstrTypes.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/InstrTypes.h b/llvm/include/llvm/IR/InstrTypes.h
index 00aa79c4a239..c86448ea72cb 100644
--- a/llvm/include/llvm/IR/InstrTypes.h
+++ b/llvm/include/llvm/IR/InstrTypes.h
@@ -650,8 +650,8 @@ class CastInst : public UnaryInstruction {
/// DataLayout argument is to determine the pointer size when examining casts
/// involving Integer and Pointer types. They are no-op casts if the integer
/// is the same size as the pointer. However, pointer size varies with
- /// platform.
- /// Determine if the described cast is a no-op cast.
+ /// platform. Note that a precondition of this method is that the cast is
+ /// legal - i.e. the instruction formed with these operands would verify.
static bool isNoopCast(
Instruction::CastOps Opcode, ///< Opcode of cast
Type *SrcTy, ///< SrcTy of cast
More information about the llvm-commits
mailing list