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

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


Author: Nikita Popov
Date: 2026-09-08T16:53:07+02:00
New Revision: b5395ed14ee6d3bc7a98c0abc9e592a1675e0bcc

URL: https://github.com/llvm/llvm-project/commit/b5395ed14ee6d3bc7a98c0abc9e592a1675e0bcc
DIFF: https://github.com/llvm/llvm-project/commit/b5395ed14ee6d3bc7a98c0abc9e592a1675e0bcc.diff

LOG: [WindowsSecureHotPatching] Remove redundant getGetElementPtr() (NFC) (#222019)

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

Added: 
    

Modified: 
    llvm/lib/CodeGen/WindowsSecureHotPatching.cpp

Removed: 
    


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