Skip to content

Commit dd3184c

Browse files
committed
[unittest,examples] Replace uses of IRBuilder::getInt8PtrTy with getPtrTy. NFC
1 parent 3c23ed1 commit dd3184c

File tree

5 files changed

+61
-82
lines changed

5 files changed

+61
-82
lines changed

llvm/examples/ExceptionDemo/ExceptionDemo.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ void generateStringPrint(llvm::LLVMContext &context,
875875
}
876876

877877
llvm::Value *cast = builder.CreatePointerCast(stringVar,
878-
builder.getInt8PtrTy());
878+
builder.getPtrTy());
879879
builder.CreateCall(printFunct, cast);
880880
}
881881

@@ -919,7 +919,7 @@ void generateIntegerPrint(llvm::LLVMContext &context,
919919
}
920920

921921
llvm::Value *cast = builder.CreateBitCast(stringVar,
922-
builder.getInt8PtrTy());
922+
builder.getPtrTy());
923923
builder.CreateCall(&printFunct, {&toPrint, cast});
924924
}
925925

@@ -970,7 +970,7 @@ static llvm::BasicBlock *createFinallyBlock(llvm::LLVMContext &context,
970970
ourExceptionNotThrownState->getType(),
971971
ourExceptionNotThrownState);
972972

973-
llvm::PointerType *exceptionStorageType = builder.getInt8PtrTy();
973+
llvm::PointerType *exceptionStorageType = builder.getPtrTy();
974974
*exceptionStorage = createEntryBlockAlloca(toAddTo,
975975
"exceptionStorage",
976976
exceptionStorageType,
@@ -1289,7 +1289,7 @@ static llvm::Function *createCatchWrappedInvokeFunction(
12891289
typeInfoThrown = builder.CreateStructGEP(ourExceptionType, typeInfoThrown, 0);
12901290

12911291
llvm::Value *typeInfoThrownType =
1292-
builder.CreateStructGEP(builder.getInt8PtrTy(), typeInfoThrown, 0);
1292+
builder.CreateStructGEP(builder.getPtrTy(), typeInfoThrown, 0);
12931293

12941294
generateIntegerPrint(context,
12951295
module,
@@ -1614,7 +1614,7 @@ static void createStandardUtilityFunctions(unsigned numTypeInfos,
16141614
TypeArray(builder.getInt32Ty()));
16151615

16161616
llvm::Type *caughtResultFieldTypes[] = {
1617-
builder.getInt8PtrTy(),
1617+
builder.getPtrTy(),
16181618
builder.getInt32Ty()
16191619
};
16201620

@@ -1697,7 +1697,7 @@ static void createStandardUtilityFunctions(unsigned numTypeInfos,
16971697

16981698
argTypes.clear();
16991699
argTypes.push_back(builder.getInt32Ty());
1700-
argTypes.push_back(builder.getInt8PtrTy());
1700+
argTypes.push_back(builder.getPtrTy());
17011701

17021702
argNames.clear();
17031703

@@ -1716,7 +1716,7 @@ static void createStandardUtilityFunctions(unsigned numTypeInfos,
17161716

17171717
argTypes.clear();
17181718
argTypes.push_back(builder.getInt64Ty());
1719-
argTypes.push_back(builder.getInt8PtrTy());
1719+
argTypes.push_back(builder.getPtrTy());
17201720

17211721
argNames.clear();
17221722

@@ -1734,7 +1734,7 @@ static void createStandardUtilityFunctions(unsigned numTypeInfos,
17341734
retType = builder.getVoidTy();
17351735

17361736
argTypes.clear();
1737-
argTypes.push_back(builder.getInt8PtrTy());
1737+
argTypes.push_back(builder.getPtrTy());
17381738

17391739
argNames.clear();
17401740

@@ -1770,7 +1770,7 @@ static void createStandardUtilityFunctions(unsigned numTypeInfos,
17701770
retType = builder.getVoidTy();
17711771

17721772
argTypes.clear();
1773-
argTypes.push_back(builder.getInt8PtrTy());
1773+
argTypes.push_back(builder.getPtrTy());
17741774

17751775
argNames.clear();
17761776

@@ -1785,7 +1785,7 @@ static void createStandardUtilityFunctions(unsigned numTypeInfos,
17851785

17861786
// createOurException
17871787

1788-
retType = builder.getInt8PtrTy();
1788+
retType = builder.getPtrTy();
17891789

17901790
argTypes.clear();
17911791
argTypes.push_back(builder.getInt32Ty());
@@ -1806,7 +1806,7 @@ static void createStandardUtilityFunctions(unsigned numTypeInfos,
18061806
retType = builder.getInt32Ty();
18071807

18081808
argTypes.clear();
1809-
argTypes.push_back(builder.getInt8PtrTy());
1809+
argTypes.push_back(builder.getPtrTy());
18101810

18111811
argNames.clear();
18121812

@@ -1826,7 +1826,7 @@ static void createStandardUtilityFunctions(unsigned numTypeInfos,
18261826
retType = builder.getInt32Ty();
18271827

18281828
argTypes.clear();
1829-
argTypes.push_back(builder.getInt8PtrTy());
1829+
argTypes.push_back(builder.getPtrTy());
18301830

18311831
argNames.clear();
18321832

@@ -1849,8 +1849,8 @@ static void createStandardUtilityFunctions(unsigned numTypeInfos,
18491849
argTypes.push_back(builder.getInt32Ty());
18501850
argTypes.push_back(builder.getInt32Ty());
18511851
argTypes.push_back(builder.getInt64Ty());
1852-
argTypes.push_back(builder.getInt8PtrTy());
1853-
argTypes.push_back(builder.getInt8PtrTy());
1852+
argTypes.push_back(builder.getPtrTy());
1853+
argTypes.push_back(builder.getPtrTy());
18541854

18551855
argNames.clear();
18561856

llvm/unittests/Analysis/MemorySSATest.cpp

Lines changed: 44 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,8 @@ TEST_F(MemorySSATest, CreateALoad) {
7676
// We create a diamond where there is a store on one side, and then after
7777
// building MemorySSA, create a load after the merge point, and use it to test
7878
// updating by creating an access for the load.
79-
F = Function::Create(
80-
FunctionType::get(B.getVoidTy(), {B.getInt8PtrTy()}, false),
81-
GlobalValue::ExternalLinkage, "F", &M);
79+
F = Function::Create(FunctionType::get(B.getVoidTy(), {B.getPtrTy()}, false),
80+
GlobalValue::ExternalLinkage, "F", &M);
8281
BasicBlock *Entry(BasicBlock::Create(C, "", F));
8382
BasicBlock *Left(BasicBlock::Create(C, "", F));
8483
BasicBlock *Right(BasicBlock::Create(C, "", F));
@@ -114,9 +113,8 @@ TEST_F(MemorySSATest, CreateLoadsAndStoreUpdater) {
114113
// incrementally update it by inserting a store in the, entry, a load in the
115114
// merge point, then a store in the branch, another load in the merge point,
116115
// and then a store in the entry.
117-
F = Function::Create(
118-
FunctionType::get(B.getVoidTy(), {B.getInt8PtrTy()}, false),
119-
GlobalValue::ExternalLinkage, "F", &M);
116+
F = Function::Create(FunctionType::get(B.getVoidTy(), {B.getPtrTy()}, false),
117+
GlobalValue::ExternalLinkage, "F", &M);
120118
BasicBlock *Entry(BasicBlock::Create(C, "", F));
121119
BasicBlock *Left(BasicBlock::Create(C, "", F));
122120
BasicBlock *Right(BasicBlock::Create(C, "", F));
@@ -204,9 +202,8 @@ TEST_F(MemorySSATest, CreateALoadUpdater) {
204202
// We create a diamond, then build memoryssa with no memory accesses, and
205203
// incrementally update it by inserting a store in one of the branches, and a
206204
// load in the merge point
207-
F = Function::Create(
208-
FunctionType::get(B.getVoidTy(), {B.getInt8PtrTy()}, false),
209-
GlobalValue::ExternalLinkage, "F", &M);
205+
F = Function::Create(FunctionType::get(B.getVoidTy(), {B.getPtrTy()}, false),
206+
GlobalValue::ExternalLinkage, "F", &M);
210207
BasicBlock *Entry(BasicBlock::Create(C, "", F));
211208
BasicBlock *Left(BasicBlock::Create(C, "", F));
212209
BasicBlock *Right(BasicBlock::Create(C, "", F));
@@ -248,9 +245,8 @@ TEST_F(MemorySSATest, CreateALoadUpdater) {
248245
}
249246

250247
TEST_F(MemorySSATest, SinkLoad) {
251-
F = Function::Create(
252-
FunctionType::get(B.getVoidTy(), {B.getInt8PtrTy()}, false),
253-
GlobalValue::ExternalLinkage, "F", &M);
248+
F = Function::Create(FunctionType::get(B.getVoidTy(), {B.getPtrTy()}, false),
249+
GlobalValue::ExternalLinkage, "F", &M);
254250
BasicBlock *Entry(BasicBlock::Create(C, "", F));
255251
BasicBlock *Left(BasicBlock::Create(C, "", F));
256252
BasicBlock *Right(BasicBlock::Create(C, "", F));
@@ -298,9 +294,8 @@ TEST_F(MemorySSATest, MoveAStore) {
298294
// a load at the end. After building MemorySSA, we test updating by moving
299295
// the store from the side block to the entry block. This destroys the old
300296
// access.
301-
F = Function::Create(
302-
FunctionType::get(B.getVoidTy(), {B.getInt8PtrTy()}, false),
303-
GlobalValue::ExternalLinkage, "F", &M);
297+
F = Function::Create(FunctionType::get(B.getVoidTy(), {B.getPtrTy()}, false),
298+
GlobalValue::ExternalLinkage, "F", &M);
304299
BasicBlock *Entry(BasicBlock::Create(C, "", F));
305300
BasicBlock *Left(BasicBlock::Create(C, "", F));
306301
BasicBlock *Right(BasicBlock::Create(C, "", F));
@@ -334,9 +329,8 @@ TEST_F(MemorySSATest, MoveAStoreUpdater) {
334329
// a load at the end. After building MemorySSA, we test updating by moving
335330
// the store from the side block to the entry block. This destroys the old
336331
// access.
337-
F = Function::Create(
338-
FunctionType::get(B.getVoidTy(), {B.getInt8PtrTy()}, false),
339-
GlobalValue::ExternalLinkage, "F", &M);
332+
F = Function::Create(FunctionType::get(B.getVoidTy(), {B.getPtrTy()}, false),
333+
GlobalValue::ExternalLinkage, "F", &M);
340334
BasicBlock *Entry(BasicBlock::Create(C, "", F));
341335
BasicBlock *Left(BasicBlock::Create(C, "", F));
342336
BasicBlock *Right(BasicBlock::Create(C, "", F));
@@ -380,9 +374,8 @@ TEST_F(MemorySSATest, MoveAStoreUpdaterMove) {
380374
// a load at the end. After building MemorySSA, we test updating by moving
381375
// the store from the side block to the entry block. This does not destroy
382376
// the old access.
383-
F = Function::Create(
384-
FunctionType::get(B.getVoidTy(), {B.getInt8PtrTy()}, false),
385-
GlobalValue::ExternalLinkage, "F", &M);
377+
F = Function::Create(FunctionType::get(B.getVoidTy(), {B.getPtrTy()}, false),
378+
GlobalValue::ExternalLinkage, "F", &M);
386379
BasicBlock *Entry(BasicBlock::Create(C, "", F));
387380
BasicBlock *Left(BasicBlock::Create(C, "", F));
388381
BasicBlock *Right(BasicBlock::Create(C, "", F));
@@ -424,9 +417,8 @@ TEST_F(MemorySSATest, MoveAStoreAllAround) {
424417
// a load at the end. After building MemorySSA, we test updating by moving
425418
// the store from the side block to the entry block, then to the other side
426419
// block, then to before the load. This does not destroy the old access.
427-
F = Function::Create(
428-
FunctionType::get(B.getVoidTy(), {B.getInt8PtrTy()}, false),
429-
GlobalValue::ExternalLinkage, "F", &M);
420+
F = Function::Create(FunctionType::get(B.getVoidTy(), {B.getPtrTy()}, false),
421+
GlobalValue::ExternalLinkage, "F", &M);
430422
BasicBlock *Entry(BasicBlock::Create(C, "", F));
431423
BasicBlock *Left(BasicBlock::Create(C, "", F));
432424
BasicBlock *Right(BasicBlock::Create(C, "", F));
@@ -479,9 +471,8 @@ TEST_F(MemorySSATest, RemoveAPhi) {
479471
// We create a diamond where there is a store on one side, and then a load
480472
// after the merge point. This enables us to test a bunch of different
481473
// removal cases.
482-
F = Function::Create(
483-
FunctionType::get(B.getVoidTy(), {B.getInt8PtrTy()}, false),
484-
GlobalValue::ExternalLinkage, "F", &M);
474+
F = Function::Create(FunctionType::get(B.getVoidTy(), {B.getPtrTy()}, false),
475+
GlobalValue::ExternalLinkage, "F", &M);
485476
BasicBlock *Entry(BasicBlock::Create(C, "", F));
486477
BasicBlock *Left(BasicBlock::Create(C, "", F));
487478
BasicBlock *Right(BasicBlock::Create(C, "", F));
@@ -524,9 +515,8 @@ TEST_F(MemorySSATest, RemoveMemoryAccess) {
524515
// We create a diamond where there is a store on one side, and then a load
525516
// after the merge point. This enables us to test a bunch of different
526517
// removal cases.
527-
F = Function::Create(
528-
FunctionType::get(B.getVoidTy(), {B.getInt8PtrTy()}, false),
529-
GlobalValue::ExternalLinkage, "F", &M);
518+
F = Function::Create(FunctionType::get(B.getVoidTy(), {B.getPtrTy()}, false),
519+
GlobalValue::ExternalLinkage, "F", &M);
530520
BasicBlock *Entry(BasicBlock::Create(C, "", F));
531521
BasicBlock *Left(BasicBlock::Create(C, "", F));
532522
BasicBlock *Right(BasicBlock::Create(C, "", F));
@@ -885,9 +875,8 @@ TEST_F(MemorySSATest, Irreducible) {
885875

886876
SmallVector<PHINode *, 8> Inserted;
887877
IRBuilder<> B(C);
888-
F = Function::Create(
889-
FunctionType::get(B.getVoidTy(), {B.getInt8PtrTy()}, false),
890-
GlobalValue::ExternalLinkage, "F", &M);
878+
F = Function::Create(FunctionType::get(B.getVoidTy(), {B.getPtrTy()}, false),
879+
GlobalValue::ExternalLinkage, "F", &M);
891880

892881
// Make blocks
893882
BasicBlock *IfBB = BasicBlock::Create(C, "if", F);
@@ -924,9 +913,8 @@ TEST_F(MemorySSATest, MoveToBeforeLiveOnEntryInvalidatesCache) {
924913
// ...And be sure that MSSA's caching doesn't give us `1` for the clobber of
925914
// `2` after `1` is removed.
926915
IRBuilder<> B(C);
927-
F = Function::Create(
928-
FunctionType::get(B.getVoidTy(), {B.getInt8PtrTy()}, false),
929-
GlobalValue::ExternalLinkage, "F", &M);
916+
F = Function::Create(FunctionType::get(B.getVoidTy(), {B.getPtrTy()}, false),
917+
GlobalValue::ExternalLinkage, "F", &M);
930918

931919
BasicBlock *Entry = BasicBlock::Create(C, "if", F);
932920
B.SetInsertPoint(Entry);
@@ -969,9 +957,8 @@ TEST_F(MemorySSATest, RemovingDefInvalidatesCache) {
969957
// And be sure that MSSA's caching handles the removal of def `1`
970958
// appropriately.
971959
IRBuilder<> B(C);
972-
F = Function::Create(
973-
FunctionType::get(B.getVoidTy(), {B.getInt8PtrTy()}, false),
974-
GlobalValue::ExternalLinkage, "F", &M);
960+
F = Function::Create(FunctionType::get(B.getVoidTy(), {B.getPtrTy()}, false),
961+
GlobalValue::ExternalLinkage, "F", &M);
975962

976963
BasicBlock *Entry = BasicBlock::Create(C, "if", F);
977964
B.SetInsertPoint(Entry);
@@ -1045,10 +1032,9 @@ TEST_F(MemorySSATest, TestStoreMustAlias) {
10451032

10461033
// Test May alias for optimized defs.
10471034
TEST_F(MemorySSATest, TestStoreMayAlias) {
1048-
F = Function::Create(FunctionType::get(B.getVoidTy(),
1049-
{B.getInt8PtrTy(), B.getInt8PtrTy()},
1050-
false),
1051-
GlobalValue::ExternalLinkage, "F", &M);
1035+
F = Function::Create(
1036+
FunctionType::get(B.getVoidTy(), {B.getPtrTy(), B.getPtrTy()}, false),
1037+
GlobalValue::ExternalLinkage, "F", &M);
10521038
B.SetInsertPoint(BasicBlock::Create(C, "", F));
10531039
Type *Int8 = Type::getInt8Ty(C);
10541040
auto *ArgIt = F->arg_begin();
@@ -1117,9 +1103,8 @@ TEST_F(MemorySSATest, LifetimeMarkersAreClobbers) {
11171103
// it.
11181104

11191105
IRBuilder<> B(C);
1120-
F = Function::Create(
1121-
FunctionType::get(B.getVoidTy(), {B.getInt8PtrTy()}, false),
1122-
GlobalValue::ExternalLinkage, "F", &M);
1106+
F = Function::Create(FunctionType::get(B.getVoidTy(), {B.getPtrTy()}, false),
1107+
GlobalValue::ExternalLinkage, "F", &M);
11231108

11241109
// Make blocks
11251110
BasicBlock *Entry = BasicBlock::Create(C, "entry", F);
@@ -1244,10 +1229,9 @@ TEST_F(MemorySSATest, DefOptimizationsAreInvalidatedOnMoving) {
12441229
}
12451230

12461231
TEST_F(MemorySSATest, TestOptimizedDefsAreProperUses) {
1247-
F = Function::Create(FunctionType::get(B.getVoidTy(),
1248-
{B.getInt8PtrTy(), B.getInt8PtrTy()},
1249-
false),
1250-
GlobalValue::ExternalLinkage, "F", &M);
1232+
F = Function::Create(
1233+
FunctionType::get(B.getVoidTy(), {B.getPtrTy(), B.getPtrTy()}, false),
1234+
GlobalValue::ExternalLinkage, "F", &M);
12511235
B.SetInsertPoint(BasicBlock::Create(C, "", F));
12521236
Type *Int8 = Type::getInt8Ty(C);
12531237
Value *AllocA = B.CreateAlloca(Int8, ConstantInt::get(Int8, 1), "A");
@@ -1322,9 +1306,8 @@ TEST_F(MemorySSATest, TestOptimizedDefsAreProperUses) {
13221306
// ; 4 = MemoryDef(3); optimized to 3, cannot optimize thorugh phi.
13231307
// Insert edge: entry -> exit, check mssa Update is correct.
13241308
TEST_F(MemorySSATest, TestAddedEdgeToBlockWithPhiNotOpt) {
1325-
F = Function::Create(
1326-
FunctionType::get(B.getVoidTy(), {B.getInt8PtrTy()}, false),
1327-
GlobalValue::ExternalLinkage, "F", &M);
1309+
F = Function::Create(FunctionType::get(B.getVoidTy(), {B.getPtrTy()}, false),
1310+
GlobalValue::ExternalLinkage, "F", &M);
13281311
Argument *PointerArg = &*F->arg_begin();
13291312
BasicBlock *Entry(BasicBlock::Create(C, "entry", F));
13301313
BasicBlock *Header(BasicBlock::Create(C, "header", F));
@@ -1378,9 +1361,8 @@ TEST_F(MemorySSATest, TestAddedEdgeToBlockWithPhiNotOpt) {
13781361
// the optimized access.
13791362
// Insert edge: entry -> exit, check mssa Update is correct.
13801363
TEST_F(MemorySSATest, TestAddedEdgeToBlockWithPhiOpt) {
1381-
F = Function::Create(
1382-
FunctionType::get(B.getVoidTy(), {B.getInt8PtrTy()}, false),
1383-
GlobalValue::ExternalLinkage, "F", &M);
1364+
F = Function::Create(FunctionType::get(B.getVoidTy(), {B.getPtrTy()}, false),
1365+
GlobalValue::ExternalLinkage, "F", &M);
13841366
Argument *PointerArg = &*F->arg_begin();
13851367
Type *Int8 = Type::getInt8Ty(C);
13861368
BasicBlock *Entry(BasicBlock::Create(C, "entry", F));
@@ -1450,9 +1432,8 @@ TEST_F(MemorySSATest, TestAddedEdgeToBlockWithPhiOpt) {
14501432
// e:
14511433
// ; 2 = MemoryPhi({d, 4}, {f, 1})
14521434
TEST_F(MemorySSATest, TestAddedEdgeToBlockWithNoPhiAddNewPhis) {
1453-
F = Function::Create(
1454-
FunctionType::get(B.getVoidTy(), {B.getInt8PtrTy()}, false),
1455-
GlobalValue::ExternalLinkage, "F", &M);
1435+
F = Function::Create(FunctionType::get(B.getVoidTy(), {B.getPtrTy()}, false),
1436+
GlobalValue::ExternalLinkage, "F", &M);
14561437
Argument *PointerArg = &*F->arg_begin();
14571438
BasicBlock *Entry(BasicBlock::Create(C, "entry", F));
14581439
BasicBlock *ABlock(BasicBlock::Create(C, "a", F));
@@ -1499,9 +1480,8 @@ TEST_F(MemorySSATest, TestAddedEdgeToBlockWithNoPhiAddNewPhis) {
14991480
}
15001481

15011482
TEST_F(MemorySSATest, TestCallClobber) {
1502-
F = Function::Create(
1503-
FunctionType::get(B.getVoidTy(), {B.getInt8PtrTy()}, false),
1504-
GlobalValue::ExternalLinkage, "F", &M);
1483+
F = Function::Create(FunctionType::get(B.getVoidTy(), {B.getPtrTy()}, false),
1484+
GlobalValue::ExternalLinkage, "F", &M);
15051485

15061486
Value *Pointer1 = &*F->arg_begin();
15071487
BasicBlock *Entry(BasicBlock::Create(C, "", F));
@@ -1532,9 +1512,8 @@ TEST_F(MemorySSATest, TestCallClobber) {
15321512
}
15331513

15341514
TEST_F(MemorySSATest, TestLoadClobber) {
1535-
F = Function::Create(
1536-
FunctionType::get(B.getVoidTy(), {B.getInt8PtrTy()}, false),
1537-
GlobalValue::ExternalLinkage, "F", &M);
1515+
F = Function::Create(FunctionType::get(B.getVoidTy(), {B.getPtrTy()}, false),
1516+
GlobalValue::ExternalLinkage, "F", &M);
15381517

15391518
Value *Pointer1 = &*F->arg_begin();
15401519
BasicBlock *Entry(BasicBlock::Create(C, "", F));

llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1899,7 +1899,7 @@ TEST_F(OpenMPIRBuilderTest, ApplySimdCustomAligned) {
18991899
IRBuilder<> Builder(BB);
19001900
const int AlignmentValue = 32;
19011901
AllocaInst *Alloc1 =
1902-
Builder.CreateAlloca(Builder.getInt8PtrTy(), Builder.getInt64(1));
1902+
Builder.CreateAlloca(Builder.getPtrTy(), Builder.getInt64(1));
19031903
LoadInst *Load1 = Builder.CreateLoad(Alloc1->getAllocatedType(), Alloc1);
19041904
MapVector<Value *, Value *> AlignedVars;
19051905
AlignedVars.insert({Load1, Builder.getInt64(AlignmentValue)});

llvm/unittests/IR/InstructionsTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ TEST_F(ModuleWithFunctionTest, DropPoisonGeneratingFlags) {
855855
}
856856

857857
{
858-
Value *GEPBase = Constant::getNullValue(B.getInt8PtrTy());
858+
Value *GEPBase = Constant::getNullValue(B.getPtrTy());
859859
auto *GI = cast<GetElementPtrInst>(
860860
B.CreateInBoundsGEP(B.getInt8Ty(), GEPBase, Arg0));
861861
ASSERT_TRUE(GI->isInBounds());

0 commit comments

Comments
 (0)