Skip to content

Commit f051cbd

Browse files
committed
Merge from 'master' to 'sycl-web' (#1)
CONFLICT (content): Merge conflict in clang/lib/CodeGen/CGExpr.cpp
2 parents fc7a1c3 + 9434360 commit f051cbd

14 files changed

+8
-448
lines changed

clang/include/clang/Basic/Attr.td

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,6 @@ class TargetArch<list<string> arches> : TargetSpec {
334334
}
335335
def TargetARM : TargetArch<["arm", "thumb", "armeb", "thumbeb"]>;
336336
def TargetAVR : TargetArch<["avr"]>;
337-
def TargetBPF : TargetArch<["bpfel", "bpfeb"]>;
338337
def TargetMips32 : TargetArch<["mips", "mipsel"]>;
339338
def TargetAnyMips : TargetArch<["mips", "mipsel", "mips64", "mips64el"]>;
340339
def TargetMSP430 : TargetArch<["msp430"]>;
@@ -1886,12 +1885,6 @@ def AMDGPUNumVGPR : InheritableAttr {
18861885
let Subjects = SubjectList<[Function], ErrorDiag, "kernel functions">;
18871886
}
18881887

1889-
def BPFPreserveAccessIndex : InheritableAttr,
1890-
TargetSpecificAttr<TargetBPF> {
1891-
let Spellings = [Clang<"preserve_access_index">];
1892-
let Documentation = [BPFPreserveAccessIndexDocs];
1893-
}
1894-
18951888
def WebAssemblyImportModule : InheritableAttr,
18961889
TargetSpecificAttr<TargetWebAssembly> {
18971890
let Spellings = [Clang<"import_module">];

clang/include/clang/Basic/AttrDocs.td

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,17 +1634,6 @@ The semantics are as follows:
16341634
}];
16351635
}
16361636

1637-
def BPFPreserveAccessIndexDocs : Documentation {
1638-
let Category = DocCatFunction;
1639-
let Content = [{
1640-
Clang supports the ``__attribute__((preserve_access_index))``
1641-
attribute for the BPF target. This attribute may be attached to a
1642-
struct or union declaration, where if -g is specified, it enables
1643-
preserving struct or union member access debuginfo indicies of this
1644-
struct or union, similar to clang ``__builtin_preserve_acceess_index()``.
1645-
}];
1646-
}
1647-
16481637
def MipsInterruptDocs : Documentation {
16491638
let Category = DocCatFunction;
16501639
let Heading = "interrupt (MIPS)";

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10139,7 +10139,6 @@ def err_preserve_field_info_not_field : Error<
1013910139
"__builtin_preserve_field_info argument %0 not a field access">;
1014010140
def err_preserve_field_info_not_const: Error<
1014110141
"__builtin_preserve_field_info argument %0 not a constant">;
10142-
def err_preserve_access_index_wrong_type: Error<"%0 attribute only applies to %1">;
1014310142

1014410143
def err_bit_cast_non_trivially_copyable : Error<
1014510144
"__builtin_bit_cast %select{source|destination}0 type must be trivially copyable">;

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 7 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -3412,61 +3412,6 @@ static QualType getFixedSizeElementType(const ASTContext &ctx,
34123412
return eltType;
34133413
}
34143414

3415-
/// Given an array base, check whether its member access belongs to a record
3416-
/// with preserve_access_index attribute or not.
3417-
static bool IsPreserveAIArrayBase(CodeGenFunction &CGF, const Expr *ArrayBase) {
3418-
if (!ArrayBase || !CGF.getDebugInfo())
3419-
return false;
3420-
3421-
const auto *ImplicitCast = dyn_cast<ImplicitCastExpr>(ArrayBase);
3422-
if (!ImplicitCast)
3423-
return false;
3424-
3425-
// Only support base as either a MemberExpr or DeclRefExpr.
3426-
// DeclRefExpr to cover cases like:
3427-
// struct s { int a; int b[10]; };
3428-
// struct s *p;
3429-
// p[1].a
3430-
// p[1] will generate a DeclRefExpr and p[1].a is a MemberExpr.
3431-
// p->b[5] is a MemberExpr example.
3432-
const Expr *E = ImplicitCast->getSubExpr();
3433-
const auto *MemberCast = dyn_cast<MemberExpr>(E);
3434-
if (MemberCast)
3435-
return MemberCast->getMemberDecl()->hasAttr<BPFPreserveAccessIndexAttr>();
3436-
3437-
const auto *DeclRefCast = dyn_cast<DeclRefExpr>(E);
3438-
if (DeclRefCast) {
3439-
const VarDecl *VarDef = dyn_cast<VarDecl>(DeclRefCast->getDecl());
3440-
if (!VarDef)
3441-
return false;
3442-
3443-
const auto *PtrT = dyn_cast<PointerType>(VarDef->getType().getTypePtr());
3444-
if (!PtrT)
3445-
return false;
3446-
const auto *PointeeT = PtrT->getPointeeType().getTypePtr();
3447-
3448-
// Peel off typedef's
3449-
const auto *TypedefT = dyn_cast<TypedefType>(PointeeT);
3450-
while (TypedefT) {
3451-
PointeeT = TypedefT->desugar().getTypePtr();
3452-
TypedefT = dyn_cast<TypedefType>(PointeeT);
3453-
}
3454-
3455-
// Not a typedef any more, it should be an elaborated type.
3456-
const auto ElaborateT = dyn_cast<ElaboratedType>(PointeeT);
3457-
if (!ElaborateT)
3458-
return false;
3459-
3460-
const auto *RecT = dyn_cast<RecordType>(ElaborateT->desugar().getTypePtr());
3461-
if (!RecT)
3462-
return false;
3463-
3464-
return RecT->getDecl()->hasAttr<BPFPreserveAccessIndexAttr>();
3465-
}
3466-
3467-
return false;
3468-
}
3469-
34703415
static void AddIVDepMetadata(CodeGenFunction &CGF, const ValueDecl *ArrayDecl,
34713416
llvm::Value *EltPtr) {
34723417
if (!ArrayDecl)
@@ -3482,7 +3427,6 @@ static Address emitArraySubscriptGEP(CodeGenFunction &CGF, Address addr,
34823427
QualType eltType, bool inbounds,
34833428
bool signedIndices, SourceLocation loc,
34843429
QualType *arrayType = nullptr,
3485-
const Expr *Base = nullptr,
34863430
const llvm::Twine &name = "arrayidx",
34873431
const ValueDecl *arrayDecl = nullptr) {
34883432
// All the indices except that last must be zero.
@@ -3505,8 +3449,7 @@ static Address emitArraySubscriptGEP(CodeGenFunction &CGF, Address addr,
35053449

35063450
llvm::Value *eltPtr;
35073451
auto LastIndex = dyn_cast<llvm::ConstantInt>(indices.back());
3508-
if (!LastIndex ||
3509-
(!CGF.IsInPreservedAIRegion && !IsPreserveAIArrayBase(CGF, Base))) {
3452+
if (!CGF.IsInPreservedAIRegion || !LastIndex) {
35103453
eltPtr = emitArraySubscriptGEP(
35113454
CGF, addr.getPointer(), indices, inbounds, signedIndices,
35123455
loc, name);
@@ -3667,7 +3610,7 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E,
36673610
Addr = emitArraySubscriptGEP(
36683611
*this, ArrayLV.getAddress(), {CGM.getSize(CharUnits::Zero()), Idx},
36693612
E->getType(), !getLangOpts().isSignedOverflowDefined(), SignedIndices,
3670-
E->getExprLoc(), &arrayType, E->getBase(), "arrayidx", ArrayDecl);
3613+
E->getExprLoc(), &arrayType, "arrayidx", ArrayDecl);
36713614
EltBaseInfo = ArrayLV.getBaseInfo();
36723615
EltTBAAInfo = CGM.getTBAAInfoForSubobject(ArrayLV, E->getType());
36733616
} else {
@@ -3677,8 +3620,7 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E,
36773620
QualType ptrType = E->getBase()->getType();
36783621
Addr = emitArraySubscriptGEP(*this, Addr, Idx, E->getType(),
36793622
!getLangOpts().isSignedOverflowDefined(),
3680-
SignedIndices, E->getExprLoc(), &ptrType,
3681-
E->getBase());
3623+
SignedIndices, E->getExprLoc(), &ptrType);
36823624
}
36833625

36843626
LValue LV = MakeAddrLValue(Addr, E->getType(), EltBaseInfo, EltTBAAInfo);
@@ -4079,13 +4021,12 @@ LValue CodeGenFunction::EmitLValueForField(LValue base,
40794021
const CGBitFieldInfo &Info = RL.getBitFieldInfo(field);
40804022
Address Addr = base.getAddress();
40814023
unsigned Idx = RL.getLLVMFieldNo(field);
4082-
const RecordDecl *rec = field->getParent();
4083-
if (!IsInPreservedAIRegion &&
4084-
(!getDebugInfo() || !rec->hasAttr<BPFPreserveAccessIndexAttr>())) {
4024+
if (!IsInPreservedAIRegion) {
40854025
if (Idx != 0)
40864026
// For structs, we GEP to the field that the record layout suggests.
40874027
Addr = Builder.CreateStructGEP(Addr, Idx, field->getName());
40884028
} else {
4029+
const RecordDecl *rec = field->getParent();
40894030
llvm::DIType *DbgInfo = getDebugInfo()->getOrCreateRecordType(
40904031
getContext().getRecordType(rec), rec->getLocation());
40914032
Addr = Builder.CreatePreserveStructAccessIndex(Addr, Idx,
@@ -4168,8 +4109,7 @@ LValue CodeGenFunction::EmitLValueForField(LValue base,
41684109
addr = Address(Builder.CreateLaunderInvariantGroup(addr.getPointer()),
41694110
addr.getAlignment());
41704111

4171-
if (IsInPreservedAIRegion ||
4172-
(getDebugInfo() && rec->hasAttr<BPFPreserveAccessIndexAttr>())) {
4112+
if (IsInPreservedAIRegion) {
41734113
// Remember the original union field index
41744114
llvm::DIType *DbgInfo = getDebugInfo()->getOrCreateRecordType(
41754115
getContext().getRecordType(rec), rec->getLocation());
@@ -4183,8 +4123,7 @@ LValue CodeGenFunction::EmitLValueForField(LValue base,
41834123
addr = Builder.CreateElementBitCast(
41844124
addr, CGM.getTypes().ConvertTypeForMem(FieldType), field->getName());
41854125
} else {
4186-
if (!IsInPreservedAIRegion &&
4187-
(!getDebugInfo() || !rec->hasAttr<BPFPreserveAccessIndexAttr>()))
4126+
if (!IsInPreservedAIRegion)
41884127
// For structs, we GEP to the field that the record layout suggests.
41894128
addr = emitAddrOfFieldStorage(*this, addr, field);
41904129
else

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 1 addition & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -6042,59 +6042,6 @@ static void handleAVRSignalAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
60426042
handleSimpleAttribute<AVRSignalAttr>(S, D, AL);
60436043
}
60446044

6045-
static void handleBPFPreserveAIRecord(Sema &S, RecordDecl *RD,
6046-
const BPFPreserveAccessIndexAttr &AL) {
6047-
// Add preserve_access_index attribute to all fields and inner records.
6048-
for (DeclContext::decl_iterator D = RD->decls_begin(), DEnd = RD->decls_end();
6049-
D != DEnd; ++D) {
6050-
// Any member or inner struct having attribute means done.
6051-
if (D->hasAttr<BPFPreserveAccessIndexAttr>())
6052-
return;
6053-
6054-
RecordDecl *Rec = dyn_cast<RecordDecl>(*D);
6055-
if (Rec) {
6056-
Rec->addAttr(::new (S.Context) BPFPreserveAccessIndexAttr(S.Context, AL));
6057-
handleBPFPreserveAIRecord(S, Rec, AL);
6058-
} else {
6059-
D->addAttr(::new (S.Context) BPFPreserveAccessIndexAttr(S.Context, AL));
6060-
}
6061-
}
6062-
}
6063-
6064-
static void handleBPFPreserveAIRecord(Sema &S, RecordDecl *RD,
6065-
const ParsedAttr &AL) {
6066-
// Add preserve_access_index attribute to all fields and inner records.
6067-
for (DeclContext::decl_iterator D = RD->decls_begin(), DEnd = RD->decls_end();
6068-
D != DEnd; ++D) {
6069-
RecordDecl *Rec = dyn_cast<RecordDecl>(*D);
6070-
if (Rec) {
6071-
// Inner record may have been processed.
6072-
if (!Rec->hasAttr<BPFPreserveAccessIndexAttr>()) {
6073-
Rec->addAttr(::new (S.Context) BPFPreserveAccessIndexAttr(S.Context, AL));
6074-
handleBPFPreserveAIRecord(S, Rec, AL);
6075-
}
6076-
} else {
6077-
D->addAttr(::new (S.Context) BPFPreserveAccessIndexAttr(S.Context, AL));
6078-
}
6079-
}
6080-
}
6081-
6082-
static void handleBPFPreserveAccessIndexAttr(Sema &S, Decl *D,
6083-
const ParsedAttr &AL) {
6084-
RecordDecl *Rec = dyn_cast<RecordDecl>(D);
6085-
if (!Rec) {
6086-
S.Diag(D->getLocation(), diag::err_preserve_access_index_wrong_type)
6087-
<< "preserve_addess_index" << "struct or union type";
6088-
return;
6089-
}
6090-
6091-
if (!checkAttributeNumArgs(S, AL, 0))
6092-
return;
6093-
6094-
handleBPFPreserveAIRecord(S, Rec, AL);
6095-
Rec->addAttr(::new (S.Context) BPFPreserveAccessIndexAttr(S.Context, AL));
6096-
}
6097-
60986045
static void handleWebAssemblyImportModuleAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
60996046
if (!isFunctionOrMethod(D)) {
61006047
S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type)
@@ -6982,9 +6929,6 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D,
69826929
case ParsedAttr::AT_AVRSignal:
69836930
handleAVRSignalAttr(S, D, AL);
69846931
break;
6985-
case ParsedAttr::AT_BPFPreserveAccessIndex:
6986-
handleBPFPreserveAccessIndexAttr(S, D, AL);
6987-
break;
69886932
case ParsedAttr::AT_WebAssemblyImportModule:
69896933
handleWebAssemblyImportModuleAttr(S, D, AL);
69906934
break;
@@ -7784,22 +7728,14 @@ void Sema::ProcessDeclAttributeList(Scope *S, Decl *D,
77847728
}
77857729
}
77867730

7787-
// Helper for delayed processing TransparentUnion or BPFPreserveAccessIndexAttr
7788-
// attribute.
7731+
// Helper for delayed processing TransparentUnion attribute.
77897732
void Sema::ProcessDeclAttributeDelayed(Decl *D,
77907733
const ParsedAttributesView &AttrList) {
77917734
for (const ParsedAttr &AL : AttrList)
77927735
if (AL.getKind() == ParsedAttr::AT_TransparentUnion) {
77937736
handleTransparentUnionAttr(*this, D, AL);
77947737
break;
77957738
}
7796-
7797-
// For BPFPreserveAccessIndexAttr, we want to populate the attributes
7798-
// to fields and inner records as well.
7799-
if (D->hasAttr<BPFPreserveAccessIndexAttr>()) {
7800-
handleBPFPreserveAIRecord(*this, cast<RecordDecl>(D),
7801-
*D->getAttr<BPFPreserveAccessIndexAttr>());
7802-
}
78037739
}
78047740

78057741
// Annotation attributes are the only attributes allowed after an access

clang/test/CodeGen/bpf-attr-preserve-access-index-1.c

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

clang/test/CodeGen/bpf-attr-preserve-access-index-2.c

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

clang/test/CodeGen/bpf-attr-preserve-access-index-3.c

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

clang/test/CodeGen/bpf-attr-preserve-access-index-4.c

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

0 commit comments

Comments
 (0)