aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2024-05-29 17:09:33 +0200
committerNikita Popov <npopov@redhat.com>2024-05-30 10:24:57 +0200
commitcd9a02e2c76ec2f37409c6f7becd61e605c117d8 (patch)
treef103a7bb659923a8e1b395d5e4b45c48b3347349 /clang/lib/CodeGen/CodeGenModule.cpp
parent8bce40b1eb3eb00358bbc3b7a05ea987a183265f (diff)
downloadllvm-cd9a02e2c76ec2f37409c6f7becd61e605c117d8.zip
llvm-cd9a02e2c76ec2f37409c6f7becd61e605c117d8.tar.gz
llvm-cd9a02e2c76ec2f37409c6f7becd61e605c117d8.tar.bz2
[CodeGen] Remove useless zero-index constant GEPs (NFCI)
Remove zero-index constant expression GEPs, which are not needed with opaque pointers and will get folded away.
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp11
1 files changed, 2 insertions, 9 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 0b0b659..c2314c3 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -6131,9 +6131,6 @@ CodeGenModule::GetAddrOfConstantCFString(const StringLiteral *Literal) {
return ConstantAddress(
C, C->getValueType(), CharUnits::fromQuantity(C->getAlignment()));
- llvm::Constant *Zero = llvm::Constant::getNullValue(Int32Ty);
- llvm::Constant *Zeros[] = { Zero, Zero };
-
const ASTContext &Context = getContext();
const llvm::Triple &Triple = getTriple();
@@ -6204,8 +6201,7 @@ CodeGenModule::GetAddrOfConstantCFString(const StringLiteral *Literal) {
// Decay array -> ptr
CFConstantStringClassRef =
- IsSwiftABI ? llvm::ConstantExpr::getPtrToInt(C, Ty)
- : llvm::ConstantExpr::getGetElementPtr(Ty, C, Zeros);
+ IsSwiftABI ? llvm::ConstantExpr::getPtrToInt(C, Ty) : C;
}
QualType CFTy = Context.getCFConstantStringType();
@@ -6261,10 +6257,7 @@ CodeGenModule::GetAddrOfConstantCFString(const StringLiteral *Literal) {
GV->setSection(".rodata");
// String.
- llvm::Constant *Str =
- llvm::ConstantExpr::getGetElementPtr(GV->getValueType(), GV, Zeros);
-
- Fields.add(Str);
+ Fields.add(GV);
// String length.
llvm::IntegerType *LengthTy =