[llvm] [llvm] Specialize 'NoCFIValue::getType()' (PR #72923)
Youngsuk Kim via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 21 01:21:15 PST 2023
https://github.com/JOE1994 updated https://github.com/llvm/llvm-project/pull/72923
>From 3fa39f7b92f3415743401411754df0ea4f485f71 Mon Sep 17 00:00:00 2001
From: Youngsuk Kim <youngsuk.kim at hpe.com>
Date: Mon, 20 Nov 2023 16:37:37 -0600
Subject: [PATCH 1/2] [llvm] Specialize 'NoCFIValue::getType()'
Specialize `NoCFIValue::getType()` to give a more detailed type hint to
clients.
---
llvm/include/llvm/IR/Constants.h | 5 +++++
1 file changed, 5 insertions(+)
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;
>From e10971f91cba1c1da658ab171f5bff52b3db8bcb Mon Sep 17 00:00:00 2001
From: Youngsuk Kim <joseph942010 at gmail.com>
Date: Tue, 21 Nov 2023 04:21:08 -0500
Subject: [PATCH 2/2] Remove `inline` specifier from `NoCFIValue::getType()`
Co-authored-by: Nikita Popov <github at npopov.com>
---
llvm/include/llvm/IR/Constants.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/include/llvm/IR/Constants.h b/llvm/include/llvm/IR/Constants.h
index 48890593ce1a9ed..2f7fc5652c2cde4 100644
--- a/llvm/include/llvm/IR/Constants.h
+++ b/llvm/include/llvm/IR/Constants.h
@@ -976,7 +976,7 @@ class NoCFIValue final : public Constant {
}
/// NoCFIValue is always a pointer.
- inline PointerType *getType() const {
+ PointerType *getType() const {
return cast<PointerType>(Value::getType());
}
More information about the llvm-commits
mailing list