-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[NFC][AutoUpgrade] Use ConstantPointerNull::get
instead of Constant::getNullValue
for known pointer types
#139984
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
[NFC][AutoUpgrade] Use ConstantPointerNull::get
instead of Constant::getNullValue
for known pointer types
#139984
Conversation
…t::getNullValue` for pointer types 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.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
@llvm/pr-subscribers-llvm-ir Author: Shilei Tian (shiltian) ChangesThis is a preparation change for upcoming PRs that will update the semantics of Full diff: https://github.com/llvm/llvm-project/pull/139984.diff 1 Files Affected:
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();
|
ConstantPointerNull::get
instead of Constant::getNullValue
for pointer typesConstantPointerNull::get
instead of Constant::getNullValue
for known pointer types
@@ -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())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a preexisting bug here. It's not using the type of this value, which may not be addrspace(0)
…t::getNullValue` for known pointer types (llvm#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.
This is a preparation change for upcoming PRs that will update the semantics of
ConstantPointerNull
, making it to represent an actualnullptr
rather than azero-valued pointer.