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

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

Merged
merged 2 commits into from
Nov 21, 2023

Conversation

JOE1994
Copy link
Member

@JOE1994 JOE1994 commented Nov 20, 2023

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

Specialize `NoCFIValue::getType()` to give a more detailed type hint to
clients.
@llvmbot
Copy link
Collaborator

llvmbot commented Nov 20, 2023

@llvm/pr-subscribers-llvm-ir

Author: Youngsuk Kim (JOE1994)

Changes

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 --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;

Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

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

LGTM

llvm/include/llvm/IR/Constants.h Outdated Show resolved Hide resolved
Co-authored-by: Nikita Popov <github@npopov.com>
@JOE1994 JOE1994 merged commit 19cdc0a into llvm:main Nov 21, 2023
1 of 3 checks passed
@JOE1994 JOE1994 deleted the NOCFIValue_tighten_getType branch November 21, 2023 09:23
Copy link

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff 44c796d5669e78dc020fc4b00865ed6fea42dd4d e10971f91cba1c1da658ab171f5bff52b3db8bcb -- llvm/include/llvm/IR/Constants.h
View the diff from clang-format here.
diff --git a/llvm/include/llvm/IR/Constants.h b/llvm/include/llvm/IR/Constants.h
index 2f7fc5652c..b4c43794a5 100644
--- a/llvm/include/llvm/IR/Constants.h
+++ b/llvm/include/llvm/IR/Constants.h
@@ -976,9 +976,7 @@ public:
   }
 
   /// NoCFIValue is always a pointer.
-  PointerType *getType() const {
-    return cast<PointerType>(Value::getType());
-  }
+  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) {

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.

None yet

3 participants