On Tue, Jul 20, 2021 at 8:27 PM David Blaikie <dblai...@gmail.com> wrote:
> Any chance some of this series of patches could have test coverage > included? (like small clang test cases that exercise only a narrow part of > the codegen & works with force-opaque-pointers due to these changes?) > I think we're still pretty far away from any meaningful opaque pointer testing with clang. We need at least https://reviews.llvm.org/D103465 to land to support even basic cases. I just ran a quick test, and while an empty main() works under -mllvm -force-opaque-pointers, you get an assertion as soon as you try to dereference a pointer. Nikita > On Sat, Jul 17, 2021 at 9:48 AM Nikita Popov via cfe-commits < > cfe-commits@lists.llvm.org> wrote: > >> >> Author: Nikita Popov >> Date: 2021-07-17T18:48:21+02:00 >> New Revision: 4ace6008f2fde781c1bedc7515e6380e449cb56a >> >> URL: >> https://github.com/llvm/llvm-project/commit/4ace6008f2fde781c1bedc7515e6380e449cb56a >> DIFF: >> https://github.com/llvm/llvm-project/commit/4ace6008f2fde781c1bedc7515e6380e449cb56a.diff >> >> LOG: [OpaquePtr] Remove uses of CreateStructGEP() without element type >> >> Remove uses of to-be-deprecated API. >> >> Added: >> >> >> Modified: >> clang/lib/CodeGen/CGBlocks.cpp >> clang/lib/CodeGen/CGObjCGNU.cpp >> >> Removed: >> >> >> >> >> ################################################################################ >> diff --git a/clang/lib/CodeGen/CGBlocks.cpp >> b/clang/lib/CodeGen/CGBlocks.cpp >> index 769501a036e6..f39a56f81d41 100644 >> --- a/clang/lib/CodeGen/CGBlocks.cpp >> +++ b/clang/lib/CodeGen/CGBlocks.cpp >> @@ -1375,7 +1375,7 @@ static llvm::Constant >> *buildGlobalBlock(CodeGenModule &CGM, >> llvm::IRBuilder<> b(llvm::BasicBlock::Create(CGM.getLLVMContext(), >> "entry", >> Init)); >> b.CreateAlignedStore(CGM.getNSConcreteGlobalBlock(), >> - b.CreateStructGEP(literal, 0), >> + b.CreateStructGEP(literal->getValueType(), >> literal, 0), >> CGM.getPointerAlign().getAsAlign()); >> b.CreateRetVoid(); >> // We can't use the normal LLVM global initialisation array, because >> we >> >> diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp >> b/clang/lib/CodeGen/CGObjCGNU.cpp >> index 9e47dbf7bdf1..3f361f4e7931 100644 >> --- a/clang/lib/CodeGen/CGObjCGNU.cpp >> +++ b/clang/lib/CodeGen/CGObjCGNU.cpp >> @@ -945,7 +945,8 @@ class CGObjCGNUstep2 : public CGObjCGNUstep { >> /// Generate the name of a symbol for a reference to a class. >> Accesses to >> /// classes should be indirected via this. >> >> - typedef std::pair<std::string, std::pair<llvm::Constant*, int>> >> EarlyInitPair; >> + typedef std::pair<std::string, std::pair<llvm::GlobalVariable*, int>> >> + EarlyInitPair; >> std::vector<EarlyInitPair> EarlyInitList; >> >> std::string SymbolForClassRef(StringRef Name, bool isWeak) { >> @@ -1096,7 +1097,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep { >> } >> } >> } >> - auto *ObjCStrGV = >> + llvm::GlobalVariable *ObjCStrGV = >> Fields.finishAndCreateGlobal( >> isNamed ? StringRef(StringName) : ".objc_string", >> Align, false, isNamed ? llvm::GlobalValue::LinkOnceODRLinkage >> @@ -1107,7 +1108,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep { >> ObjCStrGV->setVisibility(llvm::GlobalValue::HiddenVisibility); >> } >> if (CGM.getTriple().isOSBinFormatCOFF()) { >> - std::pair<llvm::Constant*, int> v{ObjCStrGV, 0}; >> + std::pair<llvm::GlobalVariable*, int> v{ObjCStrGV, 0}; >> EarlyInitList.emplace_back(Sym, v); >> } >> llvm::Constant *ObjCStr = llvm::ConstantExpr::getBitCast(ObjCStrGV, >> IdTy); >> @@ -1654,9 +1655,10 @@ class CGObjCGNUstep2 : public CGObjCGNUstep { >> for (const auto &lateInit : EarlyInitList) { >> auto *global = TheModule.getGlobalVariable(lateInit.first); >> if (global) { >> + llvm::GlobalVariable *GV = lateInit.second.first; >> b.CreateAlignedStore( >> global, >> - b.CreateStructGEP(lateInit.second.first, >> lateInit.second.second), >> + b.CreateStructGEP(GV->getValueType(), GV, >> lateInit.second.second), >> CGM.getPointerAlign().getAsAlign()); >> } >> } >> @@ -1938,7 +1940,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep { >> // struct objc_property_list *properties >> classFields.add(GeneratePropertyList(OID, classDecl)); >> >> - auto *classStruct = >> + llvm::GlobalVariable *classStruct = >> classFields.finishAndCreateGlobal(SymbolForClass(className), >> CGM.getPointerAlign(), false, >> llvm::GlobalValue::ExternalLinkage); >> >> @@ -1949,12 +1951,12 @@ class CGObjCGNUstep2 : public CGObjCGNUstep { >> if (IsCOFF) { >> // we can't import a class struct. >> if (OID->getClassInterface()->hasAttr<DLLExportAttr>()) { >> - >> cast<llvm::GlobalValue>(classStruct)->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass); >> + >> classStruct->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass); >> >> >> cast<llvm::GlobalValue>(classRefSymbol)->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass); >> } >> >> if (SuperClass) { >> - std::pair<llvm::Constant*, int> v{classStruct, 1}; >> + std::pair<llvm::GlobalVariable*, int> v{classStruct, 1}; >> EarlyInitList.emplace_back(std::string(SuperClass->getName()), >> std::move(v)); >> } >> >> >> >> _______________________________________________ >> cfe-commits mailing list >> cfe-commits@lists.llvm.org >> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >> >
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits