Skip to content

Commit 1598445

Browse files
committed
Revert Tag CFI-generated data structures with "#pragma clang section" attributes.
This reverts r375022 (git commit e2692b3) llvm-svn: 375069
1 parent eb1bbce commit 1598445

File tree

5 files changed

+5
-81
lines changed

5 files changed

+5
-81
lines changed

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2821,7 +2821,6 @@ llvm::Constant *CodeGenFunction::EmitCheckTypeDescriptor(QualType T) {
28212821
CGM.getModule(), Descriptor->getType(),
28222822
/*isConstant=*/true, llvm::GlobalVariable::PrivateLinkage, Descriptor);
28232823
GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
2824-
CGM.setPragmaSectionAttributes(CurFuncDecl, GV);
28252824
CGM.getSanitizerMetadata()->disableSanitizerForGlobal(GV);
28262825

28272826
// Remember the descriptor for this type.
@@ -2901,7 +2900,6 @@ llvm::Constant *CodeGenFunction::EmitCheckSourceLocation(SourceLocation Loc) {
29012900
}
29022901

29032902
auto FilenameGV = CGM.GetAddrOfConstantCString(FilenameString, ".src");
2904-
CGM.setPragmaSectionAttributes(CurFuncDecl, cast<llvm::GlobalVariable>(FilenameGV.getPointer()));
29052903
CGM.getSanitizerMetadata()->disableSanitizerForGlobal(
29062904
cast<llvm::GlobalVariable>(FilenameGV.getPointer()));
29072905
Filename = FilenameGV.getPointer();
@@ -3075,7 +3073,6 @@ void CodeGenFunction::EmitCheck(
30753073
new llvm::GlobalVariable(CGM.getModule(), Info->getType(), false,
30763074
llvm::GlobalVariable::PrivateLinkage, Info);
30773075
InfoPtr->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
3078-
CGM.setPragmaSectionAttributes(CurFuncDecl, InfoPtr);
30793076
CGM.getSanitizerMetadata()->disableSanitizerForGlobal(InfoPtr);
30803077
Args.push_back(Builder.CreateBitCast(InfoPtr, Int8PtrTy));
30813078
ArgTypes.push_back(Int8PtrTy);

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,8 +1699,11 @@ bool CodeGenModule::GetCPUAndFeaturesAttributes(GlobalDecl GD,
16991699
return AddedAttr;
17001700
}
17011701

1702-
void CodeGenModule::setPragmaSectionAttributes(const Decl *D,
1703-
llvm::GlobalObject *GO) {
1702+
void CodeGenModule::setNonAliasAttributes(GlobalDecl GD,
1703+
llvm::GlobalObject *GO) {
1704+
const Decl *D = GD.getDecl();
1705+
SetCommonAttributes(GD, GO);
1706+
17041707
if (D) {
17051708
if (auto *GV = dyn_cast<llvm::GlobalVariable>(GO)) {
17061709
if (auto *SA = D->getAttr<PragmaClangBSSSectionAttr>())
@@ -1718,26 +1721,6 @@ void CodeGenModule::setPragmaSectionAttributes(const Decl *D,
17181721
if (!D->getAttr<SectionAttr>())
17191722
F->addFnAttr("implicit-section-name", SA->getName());
17201723

1721-
if (auto *SA = D->getAttr<PragmaClangBSSSectionAttr>())
1722-
F->addFnAttr("bss-section", SA->getName());
1723-
if (auto *SA = D->getAttr<PragmaClangDataSectionAttr>())
1724-
F->addFnAttr("data-section", SA->getName());
1725-
if (auto *SA = D->getAttr<PragmaClangRodataSectionAttr>())
1726-
F->addFnAttr("rodata-section", SA->getName());
1727-
if (auto *SA = D->getAttr<PragmaClangRelroSectionAttr>())
1728-
F->addFnAttr("relro-section", SA->getName());
1729-
}
1730-
}
1731-
}
1732-
1733-
void CodeGenModule::setNonAliasAttributes(GlobalDecl GD,
1734-
llvm::GlobalObject *GO) {
1735-
const Decl *D = GD.getDecl();
1736-
SetCommonAttributes(GD, GO);
1737-
setPragmaSectionAttributes(D, GO);
1738-
1739-
if (D) {
1740-
if (auto *F = dyn_cast<llvm::Function>(GO)) {
17411724
llvm::AttrBuilder Attrs;
17421725
if (GetCPUAndFeaturesAttributes(GD, Attrs)) {
17431726
// We know that GetCPUAndFeaturesAttributes will always have the

clang/lib/CodeGen/CodeGenModule.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,11 +1347,6 @@ class CodeGenModule : public CodeGenTypeCache {
13471347
/// \param QT is the clang QualType of the null pointer.
13481348
llvm::Constant *getNullPointer(llvm::PointerType *T, QualType QT);
13491349

1350-
/// Set section attributes requested by "#pragma clang section"
1351-
/// \param D is the declaration to read semantic attributes from.
1352-
/// \param GO is the global object to set section attributes.
1353-
void setPragmaSectionAttributes(const Decl *D, llvm::GlobalObject *GO);
1354-
13551350
private:
13561351
llvm::Constant *GetOrCreateLLVMFunction(
13571352
StringRef MangledName, llvm::Type *Ty, GlobalDecl D, bool ForVTable,

clang/lib/Sema/SemaDecl.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9062,25 +9062,6 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
90629062
Context, PragmaClangTextSection.SectionName,
90639063
PragmaClangTextSection.PragmaLocation, AttributeCommonInfo::AS_Pragma));
90649064

9065-
if (D.isFunctionDefinition()) {
9066-
if (PragmaClangBSSSection.Valid)
9067-
NewFD->addAttr(PragmaClangBSSSectionAttr::CreateImplicit(
9068-
Context, PragmaClangBSSSection.SectionName,
9069-
PragmaClangBSSSection.PragmaLocation));
9070-
if (PragmaClangDataSection.Valid)
9071-
NewFD->addAttr(PragmaClangDataSectionAttr::CreateImplicit(
9072-
Context, PragmaClangDataSection.SectionName,
9073-
PragmaClangDataSection.PragmaLocation));
9074-
if (PragmaClangRodataSection.Valid)
9075-
NewFD->addAttr(PragmaClangRodataSectionAttr::CreateImplicit(
9076-
Context, PragmaClangRodataSection.SectionName,
9077-
PragmaClangRodataSection.PragmaLocation));
9078-
if (PragmaClangRelroSection.Valid)
9079-
NewFD->addAttr(PragmaClangRelroSectionAttr::CreateImplicit(
9080-
Context, PragmaClangRelroSection.SectionName,
9081-
PragmaClangRelroSection.PragmaLocation));
9082-
}
9083-
90849065
// Apply an implicit SectionAttr if #pragma code_seg is active.
90859066
if (CodeSegStack.CurrentValue && D.isFunctionDefinition() &&
90869067
!NewFD->hasAttr<SectionAttr>()) {

clang/test/CodeGen/cfi-pragma-section.c

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)