Skip to content

Commit ecb98f9

Browse files
committed
[IRBuilder] Remove uses of CreateGlobalStringPtr() (NFC)
Since the migration to opaque pointers, CreateGlobalStringPtr() is the same as CreateGlobalString(). Normalize to the latter.
1 parent 0b524ef commit ecb98f9

File tree

10 files changed

+22
-21
lines changed

10 files changed

+22
-21
lines changed

clang/lib/CodeGen/CGBuiltin.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -13649,7 +13649,7 @@ Value *CodeGenFunction::EmitBPFBuiltinExpr(unsigned BuiltinID,
1364913649
else
1365013650
InitValStr = std::to_string(InitVal.getZExtValue());
1365113651
std::string EnumStr = Enumerator->getNameAsString() + ":" + InitValStr;
13652-
Value *EnumStrVal = Builder.CreateGlobalStringPtr(EnumStr);
13652+
Value *EnumStrVal = Builder.CreateGlobalString(EnumStr);
1365313653

1365413654
ConstantInt *Flag = cast<ConstantInt>(EmitScalarExpr(E->getArg(1)));
1365513655
Value *FlagValue = ConstantInt::get(Int64Ty, Flag->getSExtValue());

clang/lib/CodeGen/CGExprScalar.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1807,7 +1807,7 @@ ScalarExprEmitter::VisitSYCLUniqueStableNameExpr(SYCLUniqueStableNameExpr *E) {
18071807
ASTContext &Context = CGF.getContext();
18081808
unsigned AddrSpace =
18091809
Context.getTargetAddressSpace(CGF.CGM.GetGlobalConstantAddressSpace());
1810-
llvm::Constant *GlobalConstStr = Builder.CreateGlobalStringPtr(
1810+
llvm::Constant *GlobalConstStr = Builder.CreateGlobalString(
18111811
E->ComputeName(Context), "__usn_str", AddrSpace);
18121812

18131813
llvm::Type *ExprTy = ConvertType(E->getType());

llvm/include/llvm-c/Core.h

+3
Original file line numberDiff line numberDiff line change
@@ -4526,6 +4526,9 @@ LLVMValueRef LLVMBuildStructGEP2(LLVMBuilderRef B, LLVMTypeRef Ty,
45264526
const char *Name);
45274527
LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,
45284528
const char *Name);
4529+
/**
4530+
* Deprecated: Use LLVMBuildGlobalString instead, which has identical behavior.
4531+
*/
45294532
LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str,
45304533
const char *Name);
45314534
LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst);

llvm/lib/CodeGen/StackProtector.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ BasicBlock *CreateFailBB(Function *F, const Triple &Trip) {
705705
StackChkFail = M->getOrInsertFunction("__stack_smash_handler",
706706
Type::getVoidTy(Context),
707707
PointerType::getUnqual(Context));
708-
Args.push_back(B.CreateGlobalStringPtr(F->getName(), "SSH"));
708+
Args.push_back(B.CreateGlobalString(F->getName(), "SSH"));
709709
} else {
710710
StackChkFail =
711711
M->getOrInsertFunction("__stack_chk_fail", Type::getVoidTy(Context));

llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -886,8 +886,8 @@ Constant *OpenMPIRBuilder::getOrCreateSrcLocStr(StringRef LocStr,
886886
GV.getInitializer() == Initializer)
887887
return SrcLocStr = ConstantExpr::getPointerCast(&GV, Int8Ptr);
888888

889-
SrcLocStr = Builder.CreateGlobalStringPtr(LocStr, /* Name */ "",
890-
/* AddressSpace */ 0, &M);
889+
SrcLocStr = Builder.CreateGlobalString(LocStr, /* Name */ "",
890+
/* AddressSpace */ 0, &M);
891891
}
892892
return SrcLocStr;
893893
}

llvm/lib/IR/Core.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -4060,7 +4060,7 @@ LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str,
40604060

40614061
LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str,
40624062
const char *Name) {
4063-
return wrap(unwrap(B)->CreateGlobalStringPtr(Str, Name));
4063+
return wrap(unwrap(B)->CreateGlobalString(Str, Name));
40644064
}
40654065

40664066
LLVMBool LLVMGetVolatile(LLVMValueRef MemAccessInst) {

llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp

+6-8
Original file line numberDiff line numberDiff line change
@@ -1077,17 +1077,16 @@ void DFSanFunction::addReachesFunctionCallbacksIfEnabled(IRBuilder<> &IRB,
10771077

10781078
if (dbgloc.get() == nullptr) {
10791079
CILine = llvm::ConstantInt::get(I.getContext(), llvm::APInt(32, 0));
1080-
FilePathPtr = IRB.CreateGlobalStringPtr(
1080+
FilePathPtr = IRB.CreateGlobalString(
10811081
I.getFunction()->getParent()->getSourceFileName());
10821082
} else {
10831083
CILine = llvm::ConstantInt::get(I.getContext(),
10841084
llvm::APInt(32, dbgloc.getLine()));
1085-
FilePathPtr =
1086-
IRB.CreateGlobalStringPtr(dbgloc->getFilename());
1085+
FilePathPtr = IRB.CreateGlobalString(dbgloc->getFilename());
10871086
}
10881087

10891088
llvm::Value *FunctionNamePtr =
1090-
IRB.CreateGlobalStringPtr(I.getFunction()->getName());
1089+
IRB.CreateGlobalString(I.getFunction()->getName());
10911090

10921091
CallInst *CB;
10931092
std::vector<Value *> args;
@@ -1293,7 +1292,7 @@ void DataFlowSanitizer::buildExternWeakCheckIfNeeded(IRBuilder<> &IRB,
12931292
if (GlobalValue::isExternalWeakLinkage(F->getLinkage())) {
12941293
std::vector<Value *> Args;
12951294
Args.push_back(F);
1296-
Args.push_back(IRB.CreateGlobalStringPtr(F->getName()));
1295+
Args.push_back(IRB.CreateGlobalString(F->getName()));
12971296
IRB.CreateCall(DFSanWrapperExternWeakNullFn, Args);
12981297
}
12991298
}
@@ -1313,8 +1312,7 @@ DataFlowSanitizer::buildWrapperFunction(Function *F, StringRef NewFName,
13131312
if (F->isVarArg()) {
13141313
NewF->removeFnAttr("split-stack");
13151314
CallInst::Create(DFSanVarargWrapperFn,
1316-
IRBuilder<>(BB).CreateGlobalStringPtr(F->getName()), "",
1317-
BB);
1315+
IRBuilder<>(BB).CreateGlobalString(F->getName()), "", BB);
13181316
new UnreachableInst(*Ctx, BB);
13191317
} else {
13201318
auto ArgIt = pointer_iterator<Argument *>(NewF->arg_begin());
@@ -3086,7 +3084,7 @@ bool DFSanVisitor::visitWrappedCallBase(Function &F, CallBase &CB) {
30863084
case DataFlowSanitizer::WK_Warning:
30873085
CB.setCalledFunction(&F);
30883086
IRB.CreateCall(DFSF.DFS.DFSanUnimplementedFn,
3089-
IRB.CreateGlobalStringPtr(F.getName()));
3087+
IRB.CreateGlobalString(F.getName()));
30903088
DFSF.DFS.buildExternWeakCheckIfNeeded(IRB, &F);
30913089
DFSF.setShadow(&CB, DFSF.DFS.getZeroShadow(&CB));
30923090
DFSF.setOrigin(&CB, DFSF.DFS.ZeroOrigin);

llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,7 @@ Function *GCOVProfiler::insertCounterWriteout(
11261126
uint32_t CfgChecksum = FileChecksums.empty() ? 0 : FileChecksums[i];
11271127
auto *StartFileCallArgs = ConstantStruct::get(
11281128
StartFileCallArgsTy,
1129-
{Builder.CreateGlobalStringPtr(FilenameGcda),
1129+
{Builder.CreateGlobalString(FilenameGcda),
11301130
Builder.getInt32(endian::read32be(Options.Version)),
11311131
Builder.getInt32(CfgChecksum)});
11321132

llvm/unittests/IR/IRBuilderTest.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1142,12 +1142,12 @@ TEST_F(IRBuilderTest, InsertExtractElement) {
11421142
EXPECT_EQ(Elt2, X2);
11431143
}
11441144

1145-
TEST_F(IRBuilderTest, CreateGlobalStringPtr) {
1145+
TEST_F(IRBuilderTest, CreateGlobalString) {
11461146
IRBuilder<> Builder(BB);
11471147

1148-
auto String1a = Builder.CreateGlobalStringPtr("TestString", "String1a");
1149-
auto String1b = Builder.CreateGlobalStringPtr("TestString", "String1b", 0);
1150-
auto String2 = Builder.CreateGlobalStringPtr("TestString", "String2", 1);
1148+
auto String1a = Builder.CreateGlobalString("TestString", "String1a");
1149+
auto String1b = Builder.CreateGlobalString("TestString", "String1b", 0);
1150+
auto String2 = Builder.CreateGlobalString("TestString", "String2", 1);
11511151
auto String3 = Builder.CreateGlobalString("TestString", "String3", 2);
11521152

11531153
EXPECT_TRUE(String1a->getType()->getPointerAddressSpace() == 0);

polly/lib/CodeGen/RuntimeDebugBuilder.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ llvm::Value *RuntimeDebugBuilder::getPrintableString(PollyIRBuilder &Builder,
2323
// because CPU backends typically ignore the address space. For constant
2424
// strings as returned by getPrintableString, the format string should instead
2525
// directly spell out the string.
26-
return Builder.CreateGlobalStringPtr(Str, "", 4);
26+
return Builder.CreateGlobalString(Str, "", 4);
2727
}
2828

2929
Function *RuntimeDebugBuilder::getVPrintF(PollyIRBuilder &Builder) {
@@ -131,7 +131,7 @@ Function *RuntimeDebugBuilder::getPrintF(PollyIRBuilder &Builder) {
131131
void RuntimeDebugBuilder::createPrintF(PollyIRBuilder &Builder,
132132
std::string Format,
133133
ArrayRef<Value *> Values) {
134-
Value *FormatString = Builder.CreateGlobalStringPtr(Format);
134+
Value *FormatString = Builder.CreateGlobalString(Format);
135135
std::vector<Value *> Arguments;
136136

137137
Arguments.push_back(FormatString);

0 commit comments

Comments
 (0)