[llvm] [llvm] Specialize 'NoCFIValue::getType()' (PR #72923)

via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 20 15:07:56 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-ir

Author: Youngsuk Kim (JOE1994)

<details>
<summary>Changes</summary>

Specialize `NoCFIValue::getType()` to give a more detailed type hint to clients.

---
Full diff: https://github.com/llvm/llvm-project/pull/72923.diff


1 Files Affected:

- (modified) llvm/include/llvm/IR/Constants.h (+5) 


``````````diff
diff --git a/llvm/include/llvm/IR/Constants.h b/llvm/include/llvm/IR/Constants.h
index c443ec58822b007..48890593ce1a9ed 100644
--- a/llvm/include/llvm/IR/Constants.h
+++ b/llvm/include/llvm/IR/Constants.h
@@ -975,6 +975,11 @@ class NoCFIValue final : public Constant {
     return cast<GlobalValue>(Op<0>().get());
   }
 
+  /// NoCFIValue is always a pointer.
+  inline PointerType *getType() const {
+    return cast<PointerType>(Value::getType());
+  }
+
   /// Methods for support type inquiry through isa, cast, and dyn_cast:
   static bool classof(const Value *V) {
     return V->getValueID() == NoCFIValueVal;

``````````

</details>


https://github.com/llvm/llvm-project/pull/72923


More information about the llvm-commits mailing list