[llvm] [WindowsSecureHotPatching] Remove redundant getGetElementPtr() (NFC) (PR #222019)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 8 07:53:03 PDT 2026


https://github.com/nikic created https://github.com/llvm/llvm-project/pull/222019

This was creating a degenerate getelementptr without any indices,
which is equivalent to the base pointer and will fold away.

>From afc574fbca4adae028484f0cbf00631190468532 Mon Sep 17 00:00:00 2001
From: Nikita Popov <npopov at redhat.com>
Date: Tue, 8 Sep 2026 16:50:46 +0200
Subject: [PATCH] [WindowsSecureHotPatching] Remove redundant
 getGetElementPtr() (NFC)

This was creating a degenerate getelementptr without any indices,
which is equivalent to the base pointer and will fold away.
---
 llvm/lib/CodeGen/WindowsSecureHotPatching.cpp | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/llvm/lib/CodeGen/WindowsSecureHotPatching.cpp b/llvm/lib/CodeGen/WindowsSecureHotPatching.cpp
index 4a4d911844584..0aa4d3296ebda 100644
--- a/llvm/lib/CodeGen/WindowsSecureHotPatching.cpp
+++ b/llvm/lib/CodeGen/WindowsSecureHotPatching.cpp
@@ -359,12 +359,9 @@ static GlobalVariable *getOrCreateRefVariable(
 
   auto PtrTy = PointerType::get(M->getContext(), 0);
 
-  Constant *AddrOfOldGV =
-      ConstantExpr::getGetElementPtr(PtrTy, GV, ArrayRef<Value *>{});
-
   GlobalVariable *RefGV =
       new GlobalVariable(*M, PtrTy, false, GlobalValue::LinkOnceAnyLinkage,
-                         AddrOfOldGV, Twine("__ref_").concat(GV->getName()),
+                         GV, Twine("__ref_").concat(GV->getName()),
                          nullptr, GlobalVariable::NotThreadLocal);
 
   // RefGV is created with isConstant = false, but we want to place RefGV into



More information about the llvm-commits mailing list