Skip to content

Commit e085b40

Browse files
committed
Revert "[BPF] Preserve debuginfo array/union/struct type/access index"
This reverts commit r365435. Forgot adding the Differential Revision link. Will add to the commit message and resubmit. llvm-svn: 365436
1 parent f21eeaf commit e085b40

File tree

9 files changed

+4
-173
lines changed

9 files changed

+4
-173
lines changed

clang/docs/LanguageExtensions.rst

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1950,35 +1950,6 @@ form of ``__builtin_operator_delete`` is currently available.
19501950
These builtins are intended for use in the implementation of ``std::allocator``
19511951
and other similar allocation libraries, and are only available in C++.
19521952
1953-
``__builtin_preserve_access_index``
1954-
-----------------------------------
1955-
1956-
``__builtin_preserve_access_index`` specifies a code section where
1957-
array subscript access and structure/union member access are relocatable
1958-
under bpf compile-once run-everywhere framework. Debuginfo (typically
1959-
with ``-g``) is needed, otherwise, the compiler will exit with an error.
1960-
1961-
**Syntax**:
1962-
1963-
.. code-block:: c
1964-
1965-
const void * __builtin_preserve_access_index(const void * ptr)
1966-
1967-
**Example of Use**:
1968-
1969-
.. code-block:: c
1970-
1971-
struct t {
1972-
int i;
1973-
int j;
1974-
union {
1975-
int a;
1976-
int b;
1977-
} c[4];
1978-
};
1979-
struct t *v = ...;
1980-
const void *pb =__builtin_preserve_access_index(&v->c[3].b);
1981-
19821953
Multiprecision Arithmetic Builtins
19831954
----------------------------------
19841955

clang/include/clang/Basic/Builtins.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1449,7 +1449,6 @@ BUILTIN(__builtin_operator_new, "v*z", "tc")
14491449
BUILTIN(__builtin_operator_delete, "vv*", "tn")
14501450
BUILTIN(__builtin_char_memchr, "c*cC*iz", "n")
14511451
BUILTIN(__builtin_dump_struct, "ivC*v*", "tn")
1452-
BUILTIN(__builtin_preserve_access_index, "vC*vC*", "nU")
14531452

14541453
// Safestack builtins
14551454
BUILTIN(__builtin___get_unsafe_stack_start, "v*", "Fn")

clang/lib/CodeGen/CGBuilder.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -298,21 +298,6 @@ class CGBuilderTy : public CGBuilderBaseTy {
298298
return CreateMemSet(Dest.getPointer(), Value, Size,
299299
Dest.getAlignment().getQuantity(), IsVolatile);
300300
}
301-
302-
using CGBuilderBaseTy::CreatePreserveStructAccessIndex;
303-
Address CreatePreserveStructAccessIndex(Address Addr,
304-
unsigned Index,
305-
unsigned FieldIndex,
306-
llvm::MDNode *DbgInfo) {
307-
llvm::StructType *ElTy = cast<llvm::StructType>(Addr.getElementType());
308-
const llvm::DataLayout &DL = BB->getParent()->getParent()->getDataLayout();
309-
const llvm::StructLayout *Layout = DL.getStructLayout(ElTy);
310-
auto Offset = CharUnits::fromQuantity(Layout->getElementOffset(Index));
311-
312-
return Address(CreatePreserveStructAccessIndex(Addr.getPointer(),
313-
Index, FieldIndex, DbgInfo),
314-
Addr.getAlignment().alignmentAtOffset(Offset));
315-
}
316301
};
317302

318303
} // end namespace CodeGen

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1840,27 +1840,6 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
18401840
return RValue::get(Res);
18411841
}
18421842

1843-
case Builtin::BI__builtin_preserve_access_index: {
1844-
// Only enabled preserved access index region when debuginfo
1845-
// is available as debuginfo is needed to preserve user-level
1846-
// access pattern.
1847-
if (!getDebugInfo()) {
1848-
CGM.Error(E->getExprLoc(), "using builtin_preserve_access_index() without -g");
1849-
return RValue::get(EmitScalarExpr(E->getArg(0)));
1850-
}
1851-
1852-
// Nested builtin_preserve_access_index() not supported
1853-
if (IsInPreservedAIRegion) {
1854-
CGM.Error(E->getExprLoc(), "nested builtin_preserve_access_index() not supported");
1855-
return RValue::get(EmitScalarExpr(E->getArg(0)));
1856-
}
1857-
1858-
IsInPreservedAIRegion = true;
1859-
Value *Res = EmitScalarExpr(E->getArg(0));
1860-
IsInPreservedAIRegion = false;
1861-
return RValue::get(Res);
1862-
}
1863-
18641843
case Builtin::BI__builtin_cimag:
18651844
case Builtin::BI__builtin_cimagf:
18661845
case Builtin::BI__builtin_cimagl:

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 4 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "clang/AST/Attr.h"
2626
#include "clang/AST/DeclObjC.h"
2727
#include "clang/AST/NSAPI.h"
28-
#include "clang/Basic/Builtins.h"
2928
#include "clang/Basic/CodeGenOptions.h"
3029
#include "llvm/ADT/Hashing.h"
3130
#include "llvm/ADT/StringExtras.h"
@@ -3419,20 +3418,8 @@ static Address emitArraySubscriptGEP(CodeGenFunction &CGF, Address addr,
34193418
CharUnits eltAlign =
34203419
getArrayElementAlign(addr.getAlignment(), indices.back(), eltSize);
34213420

3422-
llvm::Value *eltPtr;
3423-
auto LastIndex = dyn_cast<llvm::ConstantInt>(indices.back());
3424-
if (!CGF.IsInPreservedAIRegion || !LastIndex) {
3425-
eltPtr = emitArraySubscriptGEP(
3426-
CGF, addr.getPointer(), indices, inbounds, signedIndices,
3427-
loc, name);
3428-
} else {
3429-
// Remember the original array subscript for bpf target
3430-
unsigned idx = LastIndex->getZExtValue();
3431-
eltPtr = CGF.Builder.CreatePreserveArrayAccessIndex(addr.getPointer(),
3432-
indices.size() - 1,
3433-
idx);
3434-
}
3435-
3421+
llvm::Value *eltPtr = emitArraySubscriptGEP(
3422+
CGF, addr.getPointer(), indices, inbounds, signedIndices, loc, name);
34363423
return Address(eltPtr, eltAlign);
34373424
}
34383425

@@ -3921,19 +3908,6 @@ static Address emitAddrOfFieldStorage(CodeGenFunction &CGF, Address base,
39213908
return CGF.Builder.CreateStructGEP(base, idx, field->getName());
39223909
}
39233910

3924-
static Address emitPreserveStructAccess(CodeGenFunction &CGF, Address base,
3925-
const FieldDecl *field) {
3926-
const RecordDecl *rec = field->getParent();
3927-
llvm::DIType *DbgInfo = CGF.getDebugInfo()->getOrCreateRecordType(
3928-
CGF.getContext().getRecordType(rec), rec->getLocation());
3929-
3930-
unsigned idx =
3931-
CGF.CGM.getTypes().getCGRecordLayout(rec).getLLVMFieldNo(field);
3932-
3933-
return CGF.Builder.CreatePreserveStructAccessIndex(
3934-
base, idx, field->getFieldIndex(), DbgInfo);
3935-
}
3936-
39373911
static bool hasAnyVptr(const QualType Type, const ASTContext &Context) {
39383912
const auto *RD = Type.getTypePtr()->getAsCXXRecordDecl();
39393913
if (!RD)
@@ -4041,24 +4015,9 @@ LValue CodeGenFunction::EmitLValueForField(LValue base,
40414015
// a barrier every time CXXRecord field with vptr is referenced.
40424016
addr = Address(Builder.CreateLaunderInvariantGroup(addr.getPointer()),
40434017
addr.getAlignment());
4044-
4045-
if (IsInPreservedAIRegion) {
4046-
// Remember the original union field index
4047-
llvm::DIType *DbgInfo = getDebugInfo()->getOrCreateRecordType(
4048-
getContext().getRecordType(rec), rec->getLocation());
4049-
addr = Address(
4050-
Builder.CreatePreserveUnionAccessIndex(
4051-
addr.getPointer(), field->getFieldIndex(), DbgInfo),
4052-
addr.getAlignment());
4053-
}
40544018
} else {
4055-
4056-
if (!IsInPreservedAIRegion)
4057-
// For structs, we GEP to the field that the record layout suggests.
4058-
addr = emitAddrOfFieldStorage(*this, addr, field);
4059-
else
4060-
// Remember the original struct field index
4061-
addr = emitPreserveStructAccess(*this, addr, field);
4019+
// For structs, we GEP to the field that the record layout suggests.
4020+
addr = emitAddrOfFieldStorage(*this, addr, field);
40624021

40634022
// If this is a reference field, load the reference right now.
40644023
if (FieldType->isReferenceType()) {

clang/lib/CodeGen/CodeGenFunction.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -480,10 +480,6 @@ class CodeGenFunction : public CodeGenTypeCache {
480480
/// finally block or filter expression.
481481
bool IsOutlinedSEHHelper = false;
482482

483-
/// True if CodeGen currently emits code inside presereved access index
484-
/// region.
485-
bool IsInPreservedAIRegion = false;
486-
487483
const CodeGen::CGBlockInfo *BlockInfo = nullptr;
488484
llvm::Value *BlockPointer = nullptr;
489485

clang/lib/Sema/SemaChecking.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -191,16 +191,6 @@ static bool SemaBuiltinAddressof(Sema &S, CallExpr *TheCall) {
191191
return false;
192192
}
193193

194-
/// Check the number of arguments, and set the result type to
195-
/// the argument type.
196-
static bool SemaBuiltinPreserveAI(Sema &S, CallExpr *TheCall) {
197-
if (checkArgCount(S, TheCall, 1))
198-
return true;
199-
200-
TheCall->setType(TheCall->getArg(0)->getType());
201-
return false;
202-
}
203-
204194
static bool SemaBuiltinOverflow(Sema &S, CallExpr *TheCall) {
205195
if (checkArgCount(S, TheCall, 3))
206196
return true;
@@ -1419,10 +1409,6 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
14191409
TheCall->setType(Context.IntTy);
14201410
break;
14211411
}
1422-
case Builtin::BI__builtin_preserve_access_index:
1423-
if (SemaBuiltinPreserveAI(*this, TheCall))
1424-
return ExprError();
1425-
break;
14261412
case Builtin::BI__builtin_call_with_static_chain:
14271413
if (SemaBuiltinCallWithStaticChain(*this, TheCall))
14281414
return ExprError();

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

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

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

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

0 commit comments

Comments
 (0)