Skip to content

Commit

Permalink
Roll-back Global generation to use defaults now that llvm#88455 went in.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexVlx committed Apr 16, 2024
1 parent 4131889 commit c18febe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 27 deletions.
17 changes: 7 additions & 10 deletions clang/lib/CodeGen/CodeGenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,8 @@ CodeGenModule::CodeGenModule(ASTContext &C,
const llvm::DataLayout &DL = M.getDataLayout();
AllocaInt8PtrTy =
llvm::PointerType::get(LLVMContext, DL.getAllocaAddrSpace());
GlobalsInt8PtrTy = llvm::PointerType::get(
LLVMContext, C.getTargetAddressSpace(GetGlobalVarAddressSpace(nullptr)));
GlobalsInt8PtrTy =
llvm::PointerType::get(LLVMContext, DL.getDefaultGlobalsAddressSpace());
ConstGlobalsPtrTy = llvm::PointerType::get(
LLVMContext, C.getTargetAddressSpace(GetGlobalConstantAddressSpace()));
ASTAllocaAddressSpace = getTargetCodeGenInfo().getASTAllocaAddressSpace();
Expand Down Expand Up @@ -3590,10 +3590,8 @@ ConstantAddress CodeGenModule::GetAddrOfTemplateParamObject(
isExternallyVisible(TPO->getLinkageAndVisibility().getLinkage())
? llvm::GlobalValue::LinkOnceODRLinkage
: llvm::GlobalValue::InternalLinkage;
auto *GV = new llvm::GlobalVariable(
getModule(), Init->getType(),
/*isConstant=*/true, Linkage, Init, Name, nullptr,
llvm::GlobalValue::NotThreadLocal, GlobalsInt8PtrTy->getAddressSpace());
auto *GV = new llvm::GlobalVariable(getModule(), Init->getType(),
/*isConstant=*/true, Linkage, Init, Name);
setGVProperties(GV, TPO);
if (supportsCOMDAT())
GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));
Expand Down Expand Up @@ -5044,9 +5042,8 @@ llvm::GlobalVariable *CodeGenModule::CreateOrReplaceCXXRuntimeVariable(
}

// Create a new variable.
GV = new llvm::GlobalVariable(
getModule(), Ty, /*isConstant=*/true, Linkage, nullptr, Name, nullptr,
llvm::GlobalValue::NotThreadLocal, GlobalsInt8PtrTy->getAddressSpace());
GV = new llvm::GlobalVariable(getModule(), Ty, /*isConstant=*/true,
Linkage, nullptr, Name);

if (OldGV) {
// Replace occurrences of the old variable if needed.
Expand Down Expand Up @@ -5161,7 +5158,7 @@ LangAS CodeGenModule::GetGlobalVarAddressSpace(const VarDecl *D) {
return LangAS::cuda_device;
}

if (LangOpts.OpenMP && OpenMPRuntime) {
if (LangOpts.OpenMP) {
LangAS AS;
if (OpenMPRuntime->hasAllocateAttributeForGlobalVar(D, AS))
return AS;
Expand Down
21 changes: 4 additions & 17 deletions clang/lib/CodeGen/ItaniumCXXABI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3279,9 +3279,7 @@ ItaniumRTTIBuilder::GetAddrOfExternalRTTIDescriptor(QualType Ty) {

GV = new llvm::GlobalVariable(
CGM.getModule(), CGM.GlobalsInt8PtrTy,
/*isConstant=*/true, llvm::GlobalValue::ExternalLinkage, nullptr, Name,
nullptr, llvm::GlobalValue::NotThreadLocal,
CGM.GlobalsInt8PtrTy->getAddressSpace());
/*isConstant=*/true, llvm::GlobalValue::ExternalLinkage, nullptr, Name);
const CXXRecordDecl *RD = Ty->getAsCXXRecordDecl();
CGM.setGVProperties(GV, RD);
// Import the typeinfo symbol when all non-inline virtual methods are
Expand Down Expand Up @@ -3675,17 +3673,8 @@ void ItaniumRTTIBuilder::BuildVTablePointer(const Type *Ty) {
if (CGM.getItaniumVTableContext().isRelativeLayout())
VTable = CGM.getModule().getNamedAlias(VTableName);
if (!VTable) {
VTable = CGM.GetGlobalValue(VTableName);
if (!VTable) {
llvm::Type *Ty = llvm::ArrayType::get(CGM.GlobalsInt8PtrTy, 0);
// FIXME: External StdLib VTables should be constant as well, but changing
// it *might* constitute a very subtle ABI break.
VTable = new llvm::GlobalVariable(
CGM.getModule(), Ty,
/*isConstant=*/false, llvm::GlobalVariable::ExternalLinkage, nullptr,
VTableName, nullptr, llvm::GlobalValue::NotThreadLocal,
CGM.GlobalsInt8PtrTy->getAddressSpace());
}
llvm::Type *Ty = llvm::ArrayType::get(CGM.GlobalsInt8PtrTy, 0);
VTable = CGM.getModule().getOrInsertGlobal(VTableName, Ty);
}

CGM.setDSOLocal(cast<llvm::GlobalValue>(VTable->stripPointerCasts()));
Expand Down Expand Up @@ -3945,9 +3934,7 @@ llvm::Constant *ItaniumRTTIBuilder::BuildTypeInfo(
llvm::GlobalVariable *OldGV = M.getNamedGlobal(Name);
llvm::GlobalVariable *GV =
new llvm::GlobalVariable(M, Init->getType(),
/*isConstant=*/true, Linkage, Init, Name,
nullptr, llvm::GlobalValue::NotThreadLocal,
CGM.GlobalsInt8PtrTy->getAddressSpace());
/*isConstant=*/true, Linkage, Init, Name);

// Export the typeinfo in the same circumstances as the vtable is exported.
auto GVDLLStorageClass = DLLStorageClass;
Expand Down

0 comments on commit c18febe

Please sign in to comment.