Skip to content

Commit a76d2a7

Browse files
authored
[Opaque Pointer] Revert some reverts and API usage removal (#11175)
- Revert "Revert "[SROA] Break typed pointer support"" - Revert "Revert "[LTO] Remove OpaquePointers option from config (NFC)"" - Revert "Revert "[LLVMContext] Remove hasSetOpaquePointersValue() API (NFC)"" - Revert "Make opaque pointer mode the default for 'llvm-c-test --echo'." - Revert "Fix commit 4f7e5d2 for typed pointers" - API usage removal
1 parent d0a1974 commit a76d2a7

File tree

11 files changed

+15
-289
lines changed

11 files changed

+15
-289
lines changed

clang/lib/CodeGen/CGExprScalar.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,9 +1661,7 @@ ScalarExprEmitter::VisitSYCLUniqueStableIdExpr(SYCLUniqueStableIdExpr *E) {
16611661
if (GlobalConstStr->getType()->getPointerAddressSpace() == ExprAS)
16621662
return GlobalConstStr;
16631663

1664-
llvm::PointerType *PtrTy = cast<llvm::PointerType>(GlobalConstStr->getType());
1665-
llvm::PointerType *NewPtrTy =
1666-
llvm::PointerType::getWithSamePointeeType(PtrTy, ExprAS);
1664+
llvm::PointerType *NewPtrTy = llvm::PointerType::get(VMContext, ExprAS);
16671665
return Builder.CreateAddrSpaceCast(GlobalConstStr, NewPtrTy,
16681666
"usid_addr_cast");
16691667
}
@@ -2111,8 +2109,7 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
21112109
SrcTy->getPointerAddressSpace() != DstTy->getPointerAddressSpace())
21122110
Src = Builder.CreateAddrSpaceCast(
21132111
Src,
2114-
llvm::PointerType::getWithSamePointeeType(
2115-
cast<llvm::PointerType>(SrcTy), DstTy->getPointerAddressSpace()));
2112+
llvm::PointerType::get(VMContext, DstTy->getPointerAddressSpace()));
21162113
else if (SrcTy->isPtrOrPtrVectorTy() && DstTy->isPtrOrPtrVectorTy() &&
21172114
SrcTy->getPointerAddressSpace() != DstTy->getPointerAddressSpace())
21182115
llvm_unreachable("wrong cast for pointers in different address spaces"

llvm/include/llvm-c/Core.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -578,13 +578,6 @@ LLVMBool LLVMContextShouldDiscardValueNames(LLVMContextRef C);
578578
*/
579579
void LLVMContextSetDiscardValueNames(LLVMContextRef C, LLVMBool Discard);
580580

581-
/**
582-
* Set whether the given context is in opaque pointer mode.
583-
*
584-
* @see LLVMContext::setOpaquePointers()
585-
*/
586-
void LLVMContextSetOpaquePointers(LLVMContextRef C, LLVMBool OpaquePointers);
587-
588581
/**
589582
* Destroy a context instance.
590583
*

llvm/include/llvm/IR/DerivedTypes.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -643,8 +643,6 @@ inline ElementCount VectorType::getElementCount() const {
643643
class PointerType : public Type {
644644
explicit PointerType(LLVMContext &C, unsigned AddrSpace);
645645

646-
Type *PointeeTy;
647-
648646
public:
649647
PointerType(const PointerType &) = delete;
650648
PointerType &operator=(const PointerType &) = delete;
@@ -679,13 +677,6 @@ class PointerType : public Type {
679677
return get(PT->getContext(), AddressSpace);
680678
}
681679

682-
[[deprecated("Pointer element types are deprecated. You can *temporarily* "
683-
"use Type::getPointerElementType() instead")]]
684-
Type *getElementType() const {
685-
assert(!isOpaque() && "Attempting to get element type of opaque pointer");
686-
return PointeeTy;
687-
}
688-
689680
[[deprecated("Always returns true")]] bool isOpaque() const { return true; }
690681

691682
/// Return true if the specified type is valid as a element type.

llvm/include/llvm/IR/LLVMContext.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,6 @@ class LLVMContext {
312312
/// LLVMContext is used by compilation.
313313
void setOptPassGate(OptPassGate&);
314314

315-
/// Whether we've decided on using opaque pointers or typed pointers yet.
316-
bool hasSetOpaquePointersValue() const;
317-
318315
/// Set whether opaque pointers are enabled. The method may be called multiple
319316
/// times, but only with the same value. Note that creating a pointer type or
320317
/// otherwise querying the opaque pointer mode performs an implicit set to

llvm/include/llvm/LTO/Config.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,6 @@ struct Config {
180180
/// Add FSAFDO discriminators.
181181
bool AddFSDiscriminator = false;
182182

183-
/// Use opaque pointer types. Used to call LLVMContext::setOpaquePointers
184-
/// unless already set by the `-opaque-pointers` commandline option.
185-
bool OpaquePointers = true;
186-
187183
/// If this field is set, LTO will write input file paths and symbol
188184
/// resolutions here in llvm-lto2 command line flag format. This can be
189185
/// used for testing and for running the LTO pipeline outside of the linker
@@ -299,7 +295,6 @@ struct LTOLLVMContext : LLVMContext {
299295
enableDebugTypeODRUniquing();
300296
setDiagnosticHandler(
301297
std::make_unique<LTOLLVMDiagnosticHandler>(&DiagHandler), true);
302-
setOpaquePointers(C.OpaquePointers);
303298
}
304299
DiagnosticHandlerFunction DiagHandler;
305300
};

llvm/lib/IR/Core.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,6 @@ void LLVMContextSetDiscardValueNames(LLVMContextRef C, LLVMBool Discard) {
125125
unwrap(C)->setDiscardValueNames(Discard);
126126
}
127127

128-
void LLVMContextSetOpaquePointers(LLVMContextRef C, LLVMBool OpaquePointers) {
129-
unwrap(C)->setOpaquePointers(OpaquePointers);
130-
}
131-
132128
void LLVMContextDispose(LLVMContextRef C) {
133129
delete unwrap(C);
134130
}

llvm/lib/IR/Function.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,19 +1495,6 @@ static bool matchIntrinsicType(
14951495
PointerType *PT = dyn_cast<PointerType>(Ty);
14961496
if (!PT || PT->getAddressSpace() != D.Pointer_AddressSpace)
14971497
return true;
1498-
if (!PT->isOpaque()) {
1499-
/* Manually consume a pointer to empty struct descriptor, which is
1500-
* used for externref. We don't want to enforce that the struct is
1501-
* anonymous in this case. (This renders externref intrinsics
1502-
* non-unique, but this will go away with opaque pointers anyway.) */
1503-
if (Infos.front().Kind == IITDescriptor::Struct &&
1504-
Infos.front().Struct_NumElements == 0) {
1505-
Infos = Infos.slice(1);
1506-
return false;
1507-
}
1508-
return matchIntrinsicType(PT->getNonOpaquePointerElementType(), Infos,
1509-
ArgTys, DeferredChecks, IsDeferredCheck);
1510-
}
15111498
// Consume IIT descriptors relating to the pointer element type.
15121499
// FIXME: Intrinsic type matching of nested single value types or even
15131500
// aggregates doesn't work properly with opaque pointers but hopefully

llvm/lib/SYCLLowerIR/CompileTimePropertiesPass.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ parseSYCLPropertiesString(Module &M, IntrinsicInst *IntrInst) {
307307

308308
auto AnnotValsIntrOpd = IntrInst->getArgOperand(4);
309309
const GlobalVariable *AnnotValsGV = nullptr;
310-
if (AnnotValsIntrOpd->getType()->isOpaquePointerTy())
310+
if (AnnotValsIntrOpd->getType()->isPointerTy())
311311
AnnotValsGV = dyn_cast<GlobalVariable>(AnnotValsIntrOpd);
312312
else if (const auto *Cast = dyn_cast<BitCastOperator>(AnnotValsIntrOpd))
313313
AnnotValsGV = dyn_cast<GlobalVariable>(Cast->getOperand(0));
@@ -525,7 +525,7 @@ void CompileTimePropertiesPass::parseAlignmentAndApply(
525525
// Get the global variable with the annotation string.
526526
const GlobalVariable *AnnotStrArgGV = nullptr;
527527
const Value *IntrAnnotStringArg = IntrInst->getArgOperand(1);
528-
if (IntrAnnotStringArg->getType()->isOpaquePointerTy())
528+
if (IntrAnnotStringArg->getType()->isPointerTy())
529529
AnnotStrArgGV = dyn_cast<GlobalVariable>(IntrAnnotStringArg);
530530
else if (auto *GEP = dyn_cast<GEPOperator>(IntrAnnotStringArg))
531531
AnnotStrArgGV = dyn_cast<GlobalVariable>(GEP->getOperand(0));
@@ -594,7 +594,7 @@ bool CompileTimePropertiesPass::transformSYCLPropertiesAnnotation(
594594
// Get the global variable with the annotation string.
595595
const GlobalVariable *AnnotStrArgGV = nullptr;
596596
const Value *IntrAnnotStringArg = IntrInst->getArgOperand(1);
597-
if (IntrAnnotStringArg->getType()->isOpaquePointerTy())
597+
if (IntrAnnotStringArg->getType()->isPointerTy())
598598
AnnotStrArgGV = dyn_cast<GlobalVariable>(IntrAnnotStringArg);
599599
else if (auto *GEP = dyn_cast<GEPOperator>(IntrAnnotStringArg))
600600
AnnotStrArgGV = dyn_cast<GlobalVariable>(GEP->getOperand(0));

llvm/lib/SYCLLowerIR/ESIMD/LowerESIMDVLoadVStore.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,17 @@ PreservedAnalyses ESIMDLowerLoadStorePass::run(Function &F,
102102
if (AS0 != AS1) {
103103
IRBuilder<> Builder(&Inst);
104104
if (GenXIntrinsic::isVStore(&Inst)) {
105-
auto PtrTy = cast<PointerType>(Inst.getOperand(1)->getType());
106-
PtrTy = PointerType::getWithSamePointeeType(PtrTy, AS1);
105+
auto PtrTy = PointerType::get(
106+
Inst.getOperand(1)->getType()->getContext(), AS1);
107107
auto PtrCast = Builder.CreateAddrSpaceCast(Inst.getOperand(1), PtrTy);
108108
Type *Tys[] = {Inst.getOperand(0)->getType(), PtrCast->getType()};
109109
Value *Args[] = {Inst.getOperand(0), PtrCast};
110110
Function *Fn = GenXIntrinsic::getGenXDeclaration(
111111
F.getParent(), GenXIntrinsic::genx_vstore, Tys);
112112
Builder.CreateCall(Fn, Args, Inst.getName());
113113
} else {
114-
auto PtrTy = cast<PointerType>(Inst.getOperand(0)->getType());
115-
PtrTy = PointerType::getWithSamePointeeType(PtrTy, AS1);
114+
auto PtrTy = PointerType::get(
115+
Inst.getOperand(0)->getType()->getContext(), AS1);
116116
auto PtrCast = Builder.CreateAddrSpaceCast(Inst.getOperand(0), PtrTy);
117117
Type *Tys[] = {Inst.getType(), PtrCast->getType()};
118118
Function *Fn = GenXIntrinsic::getGenXDeclaration(

0 commit comments

Comments
 (0)