Skip to content

Commit 61e0822

Browse files
committed
[llvm][clang] Remove uses of isOpaquePointerTy() (NFC)
This now always returns true (for pointer types).
1 parent 8fe0449 commit 61e0822

File tree

11 files changed

+14
-66
lines changed

11 files changed

+14
-66
lines changed

clang/lib/CodeGen/CGCall.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,6 @@ class CGCallee {
109109
AbstractInfo = abstractInfo;
110110
assert(functionPtr && "configuring callee without function pointer");
111111
assert(functionPtr->getType()->isPointerTy());
112-
assert(functionPtr->getType()->isOpaquePointerTy() ||
113-
functionPtr->getType()->getNonOpaquePointerElementType()
114-
->isFunctionTy());
115112
}
116113

117114
static CGCallee forBuiltin(unsigned builtinID,

llvm/lib/Analysis/InstructionSimplify.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4888,10 +4888,8 @@ static Value *simplifyGEPInst(Type *SrcTy, Value *Ptr,
48884888
}
48894889
}
48904890

4891-
// For opaque pointers an all-zero GEP is a no-op. For typed pointers,
4892-
// it may be equivalent to a bitcast.
4893-
if (Ptr->getType()->getScalarType()->isOpaquePointerTy() &&
4894-
Ptr->getType() == GEPTy &&
4891+
// All-zero GEP is a no-op, unless it performs a vector splat.
4892+
if (Ptr->getType() == GEPTy &&
48954893
all_of(Indices, [](const auto *V) { return match(V, m_Zero()); }))
48964894
return Ptr;
48974895

llvm/lib/AsmParser/LLParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2675,7 +2675,7 @@ bool LLParser::parseType(Type *&Result, const Twine &Msg, bool AllowVoid) {
26752675
// Handle "ptr" opaque pointer type.
26762676
//
26772677
// Type ::= ptr ('addrspace' '(' uint32 ')')?
2678-
if (Result->isOpaquePointerTy()) {
2678+
if (Result->isPointerTy()) {
26792679
unsigned AddrSpace;
26802680
if (parseOptionalAddrSpace(AddrSpace))
26812681
return true;

llvm/lib/Bitcode/Reader/BitcodeReader.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,17 +1381,6 @@ unsigned BitcodeReader::getVirtualTypeID(Type *Ty,
13811381
return It->second;
13821382
}
13831383

1384-
#ifndef NDEBUG
1385-
if (!Ty->isOpaquePointerTy()) {
1386-
assert(Ty->getNumContainedTypes() == ChildTypeIDs.size() &&
1387-
"Wrong number of contained types");
1388-
for (auto Pair : zip(Ty->subtypes(), ChildTypeIDs)) {
1389-
assert(std::get<0>(Pair) == getTypeByID(std::get<1>(Pair)) &&
1390-
"Incorrect contained type ID");
1391-
}
1392-
}
1393-
#endif
1394-
13951384
unsigned TypeID = TypeList.size();
13961385
TypeList.push_back(Ty);
13971386
if (!ChildTypeIDs.empty())

llvm/lib/FuzzMutate/Operations.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,7 @@ OpDescriptor llvm::fuzzerop::gepDescriptor(unsigned Weight) {
196196
auto buildGEP = [](ArrayRef<Value *> Srcs, Instruction *Inst) {
197197
// TODO: It would be better to generate a random type here, rather than
198198
// generating a random value and picking its type.
199-
Type *Ty = Srcs[0]->getType()->isOpaquePointerTy()
200-
? Srcs[1]->getType()
201-
: Srcs[0]->getType()->getNonOpaquePointerElementType();
199+
Type *Ty = Srcs[1]->getType();
202200
auto Indices = ArrayRef(Srcs).drop_front(2);
203201
return GetElementPtrInst::Create(Ty, Srcs[0], Indices, "G", Inst);
204202
};

llvm/lib/FuzzMutate/RandomIRBuilder.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,8 @@ Value *RandomIRBuilder::newSource(BasicBlock &BB, ArrayRef<Instruction *> Insts,
211211
IP = ++I->getIterator();
212212
assert(IP != BB.end() && "guaranteed by the findPointer");
213213
}
214-
// For opaque pointers, pick the type independently.
215-
Type *AccessTy = Ptr->getType()->isOpaquePointerTy()
216-
? RS.getSelection()->getType()
217-
: Ptr->getType()->getNonOpaquePointerElementType();
214+
// Pick the type independently.
215+
Type *AccessTy = RS.getSelection()->getType();
218216
auto *NewLoad = new LoadInst(AccessTy, Ptr, "L", &*IP);
219217

220218
// Only sample this load if it really matches the descriptor

llvm/lib/IR/Core.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace) {
793793
}
794794

795795
LLVMBool LLVMPointerTypeIsOpaque(LLVMTypeRef Ty) {
796-
return unwrap(Ty)->isOpaquePointerTy();
796+
return true;
797797
}
798798

799799
LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount) {

llvm/lib/Transforms/Coroutines/Coroutines.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -596,20 +596,6 @@ static void checkAsyncFuncPointer(const Instruction *I, Value *V) {
596596
auto *AsyncFuncPtrAddr = dyn_cast<GlobalVariable>(V->stripPointerCasts());
597597
if (!AsyncFuncPtrAddr)
598598
fail(I, "llvm.coro.id.async async function pointer not a global", V);
599-
600-
if (AsyncFuncPtrAddr->getType()->isOpaquePointerTy())
601-
return;
602-
603-
auto *StructTy = cast<StructType>(
604-
AsyncFuncPtrAddr->getType()->getNonOpaquePointerElementType());
605-
if (StructTy->isOpaque() || !StructTy->isPacked() ||
606-
StructTy->getNumElements() != 2 ||
607-
!StructTy->getElementType(0)->isIntegerTy(32) ||
608-
!StructTy->getElementType(1)->isIntegerTy(32))
609-
fail(I,
610-
"llvm.coro.id.async async function pointer argument's type is not "
611-
"<{i32, i32}>",
612-
V);
613599
}
614600

615601
void CoroIdAsyncInst::checkWellFormed() const {

llvm/lib/Transforms/Scalar/GVN.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -423,10 +423,9 @@ GVNPass::Expression GVNPass::ValueTable::createGEPExpr(GetElementPtrInst *GEP) {
423423
unsigned BitWidth = DL.getIndexTypeSizeInBits(PtrTy);
424424
MapVector<Value *, APInt> VariableOffsets;
425425
APInt ConstantOffset(BitWidth, 0);
426-
if (PtrTy->isOpaquePointerTy() &&
427-
GEP->collectOffset(DL, BitWidth, VariableOffsets, ConstantOffset)) {
428-
// For opaque pointers, convert into offset representation, to recognize
429-
// equivalent address calculations that use different type encoding.
426+
if (GEP->collectOffset(DL, BitWidth, VariableOffsets, ConstantOffset)) {
427+
// Convert into offset representation, to recognize equivalent address
428+
// calculations that use different type encoding.
430429
LLVMContext &Context = GEP->getContext();
431430
E.opcode = GEP->getOpcode();
432431
E.type = nullptr;
@@ -439,8 +438,8 @@ GVNPass::Expression GVNPass::ValueTable::createGEPExpr(GetElementPtrInst *GEP) {
439438
E.varargs.push_back(
440439
lookupOrAdd(ConstantInt::get(Context, ConstantOffset)));
441440
} else {
442-
// If converting to offset representation fails (for typed pointers and
443-
// scalable vectors), fall back to type-based implementation:
441+
// If converting to offset representation fails (for scalable vectors),
442+
// fall back to type-based implementation:
444443
E.opcode = GEP->getOpcode();
445444
E.type = GEP->getSourceElementType();
446445
for (Use &Op : GEP->operands())

llvm/lib/Transforms/Scalar/SROA.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,12 +1628,6 @@ static void speculateSelectInstLoads(SelectInst &SI, LoadInst &LI,
16281628

16291629
IRB.SetInsertPoint(&LI);
16301630

1631-
if (auto *TypedPtrTy = LI.getPointerOperandType();
1632-
!TypedPtrTy->isOpaquePointerTy() && SI.getType() != TypedPtrTy) {
1633-
TV = IRB.CreateBitOrPointerCast(TV, TypedPtrTy, "");
1634-
FV = IRB.CreateBitOrPointerCast(FV, TypedPtrTy, "");
1635-
}
1636-
16371631
LoadInst *TL =
16381632
IRB.CreateAlignedLoad(LI.getType(), TV, LI.getAlign(),
16391633
LI.getName() + ".sroa.speculate.load.true");
@@ -1702,11 +1696,6 @@ static void rewriteMemOpOfSelect(SelectInst &SI, T &I,
17021696
}
17031697
CondMemOp.insertBefore(NewMemOpBB->getTerminator());
17041698
Value *Ptr = SI.getOperand(1 + SuccIdx);
1705-
if (auto *PtrTy = Ptr->getType();
1706-
!PtrTy->isOpaquePointerTy() &&
1707-
PtrTy != CondMemOp.getPointerOperandType())
1708-
Ptr = BitCastInst::CreatePointerBitCastOrAddrSpaceCast(
1709-
Ptr, CondMemOp.getPointerOperandType(), "", &CondMemOp);
17101699
CondMemOp.setOperand(I.getPointerOperandIndex(), Ptr);
17111700
if (isa<LoadInst>(I)) {
17121701
CondMemOp.setName(I.getName() + (IsThen ? ".then" : ".else") + ".val");
@@ -1769,8 +1758,6 @@ static bool rewriteSelectInstMemOps(SelectInst &SI,
17691758
static Value *getAdjustedPtr(IRBuilderTy &IRB, const DataLayout &DL, Value *Ptr,
17701759
APInt Offset, Type *PointerTy,
17711760
const Twine &NamePrefix) {
1772-
assert(Ptr->getType()->isOpaquePointerTy() &&
1773-
"Only opaque pointers supported");
17741761
if (Offset != 0)
17751762
Ptr = IRB.CreateInBoundsGEP(IRB.getInt8Ty(), Ptr, IRB.getInt(Offset),
17761763
NamePrefix + "sroa_idx");

llvm/tools/llvm-stress/llvm-stress.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,7 @@ struct LoadModifier: public Modifier {
341341
void Act() override {
342342
// Try to use predefined pointers. If non-exist, use undef pointer value;
343343
Value *Ptr = getRandomPointerValue();
344-
Type *Ty = Ptr->getType()->isOpaquePointerTy()
345-
? pickType()
346-
: Ptr->getType()->getNonOpaquePointerElementType();
344+
Type *Ty = pickType();
347345
Value *V = new LoadInst(Ty, Ptr, "L", BB->getTerminator());
348346
PT->push_back(V);
349347
}
@@ -356,9 +354,7 @@ struct StoreModifier: public Modifier {
356354
void Act() override {
357355
// Try to use predefined pointers. If non-exist, use undef pointer value;
358356
Value *Ptr = getRandomPointerValue();
359-
Type *ValTy = Ptr->getType()->isOpaquePointerTy()
360-
? pickType()
361-
: Ptr->getType()->getNonOpaquePointerElementType();
357+
Type *ValTy = pickType();
362358

363359
// Do not store vectors of i1s because they are unsupported
364360
// by the codegen.

0 commit comments

Comments
 (0)