[llvm] 7314d38 - [NFC][AutoUpgrade] Use `ConstantPointerNull::get` instead of `Constant::getNullValue` for known pointer types (#139984)
via llvm-commits
llvm-commits at lists.llvm.org
Thu May 15 07:03:25 PDT 2025
Author: Shilei Tian
Date: 2025-05-15T10:03:20-04:00
New Revision: 7314d38b72ea647c67ceab0de4755d2d61073dac
URL: https://github.com/llvm/llvm-project/commit/7314d38b72ea647c67ceab0de4755d2d61073dac
DIFF: https://github.com/llvm/llvm-project/commit/7314d38b72ea647c67ceab0de4755d2d61073dac.diff
LOG: [NFC][AutoUpgrade] Use `ConstantPointerNull::get` instead of `Constant::getNullValue` for known pointer types (#139984)
This is a preparation change for upcoming PRs that will update the
semantics of
`ConstantPointerNull`, making it to represent an actual `nullptr` rather
than a
zero-valued pointer.
Added:
Modified:
llvm/lib/IR/AutoUpgrade.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index 9091e7585f9d9..41aa06add6aba 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -1613,7 +1613,7 @@ GlobalVariable *llvm::UpgradeGlobalVariable(GlobalVariable *GV) {
auto Ctor = cast<Constant>(Init->getOperand(i));
NewCtors[i] = ConstantStruct::get(EltTy, Ctor->getAggregateElement(0u),
Ctor->getAggregateElement(1),
- Constant::getNullValue(IRB.getPtrTy()));
+ ConstantPointerNull::get(IRB.getPtrTy()));
}
Constant *NewInit = ConstantArray::get(ArrayType::get(EltTy, N), NewCtors);
@@ -4721,10 +4721,10 @@ void llvm::UpgradeIntrinsicCall(CallBase *CI, Function *NewFn) {
}
// Create a new call with an added null annotation attribute argument.
- NewCall =
- Builder.CreateCall(NewFn, {CI->getArgOperand(0), CI->getArgOperand(1),
- CI->getArgOperand(2), CI->getArgOperand(3),
- Constant::getNullValue(Builder.getPtrTy())});
+ NewCall = Builder.CreateCall(
+ NewFn,
+ {CI->getArgOperand(0), CI->getArgOperand(1), CI->getArgOperand(2),
+ CI->getArgOperand(3), ConstantPointerNull::get(Builder.getPtrTy())});
NewCall->takeName(CI);
CI->replaceAllUsesWith(NewCall);
CI->eraseFromParent();
@@ -4737,10 +4737,10 @@ void llvm::UpgradeIntrinsicCall(CallBase *CI, Function *NewFn) {
return;
}
// Create a new call with an added null annotation attribute argument.
- NewCall =
- Builder.CreateCall(NewFn, {CI->getArgOperand(0), CI->getArgOperand(1),
- CI->getArgOperand(2), CI->getArgOperand(3),
- Constant::getNullValue(Builder.getPtrTy())});
+ NewCall = Builder.CreateCall(
+ NewFn,
+ {CI->getArgOperand(0), CI->getArgOperand(1), CI->getArgOperand(2),
+ CI->getArgOperand(3), ConstantPointerNull::get(Builder.getPtrTy())});
NewCall->takeName(CI);
CI->replaceAllUsesWith(NewCall);
CI->eraseFromParent();
More information about the llvm-commits
mailing list