r365436 - Revert "[BPF] Preserve debuginfo array/union/struct type/access index"
Yonghong Song via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 8 21:15:12 PDT 2019
Author: yhs
Date: Mon Jul 8 21:15:12 2019
New Revision: 365436
URL: http://llvm.org/viewvc/llvm-project?rev=365436&view=rev
Log:
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.
Removed:
cfe/trunk/test/CodeGen/bpf-preserve-access-index-2.c
cfe/trunk/test/CodeGen/bpf-preserve-access-index.c
Modified:
cfe/trunk/docs/LanguageExtensions.rst
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/lib/CodeGen/CGBuilder.h
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/Sema/SemaChecking.cpp
Modified: cfe/trunk/docs/LanguageExtensions.rst
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=365436&r1=365435&r2=365436&view=diff
==============================================================================
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Mon Jul 8 21:15:12 2019
@@ -1950,35 +1950,6 @@ form of ``__builtin_operator_delete`` is
These builtins are intended for use in the implementation of ``std::allocator``
and other similar allocation libraries, and are only available in C++.
-``__builtin_preserve_access_index``
------------------------------------
-
-``__builtin_preserve_access_index`` specifies a code section where
-array subscript access and structure/union member access are relocatable
-under bpf compile-once run-everywhere framework. Debuginfo (typically
-with ``-g``) is needed, otherwise, the compiler will exit with an error.
-
-**Syntax**:
-
-.. code-block:: c
-
- const void * __builtin_preserve_access_index(const void * ptr)
-
-**Example of Use**:
-
-.. code-block:: c
-
- struct t {
- int i;
- int j;
- union {
- int a;
- int b;
- } c[4];
- };
- struct t *v = ...;
- const void *pb =__builtin_preserve_access_index(&v->c[3].b);
-
Multiprecision Arithmetic Builtins
----------------------------------
Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=365436&r1=365435&r2=365436&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Mon Jul 8 21:15:12 2019
@@ -1449,7 +1449,6 @@ BUILTIN(__builtin_operator_new, "v*z", "
BUILTIN(__builtin_operator_delete, "vv*", "tn")
BUILTIN(__builtin_char_memchr, "c*cC*iz", "n")
BUILTIN(__builtin_dump_struct, "ivC*v*", "tn")
-BUILTIN(__builtin_preserve_access_index, "vC*vC*", "nU")
// Safestack builtins
BUILTIN(__builtin___get_unsafe_stack_start, "v*", "Fn")
Modified: cfe/trunk/lib/CodeGen/CGBuilder.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuilder.h?rev=365436&r1=365435&r2=365436&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuilder.h (original)
+++ cfe/trunk/lib/CodeGen/CGBuilder.h Mon Jul 8 21:15:12 2019
@@ -298,21 +298,6 @@ public:
return CreateMemSet(Dest.getPointer(), Value, Size,
Dest.getAlignment().getQuantity(), IsVolatile);
}
-
- using CGBuilderBaseTy::CreatePreserveStructAccessIndex;
- Address CreatePreserveStructAccessIndex(Address Addr,
- unsigned Index,
- unsigned FieldIndex,
- llvm::MDNode *DbgInfo) {
- llvm::StructType *ElTy = cast<llvm::StructType>(Addr.getElementType());
- const llvm::DataLayout &DL = BB->getParent()->getParent()->getDataLayout();
- const llvm::StructLayout *Layout = DL.getStructLayout(ElTy);
- auto Offset = CharUnits::fromQuantity(Layout->getElementOffset(Index));
-
- return Address(CreatePreserveStructAccessIndex(Addr.getPointer(),
- Index, FieldIndex, DbgInfo),
- Addr.getAlignment().alignmentAtOffset(Offset));
- }
};
} // end namespace CodeGen
Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=365436&r1=365435&r2=365436&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Jul 8 21:15:12 2019
@@ -1840,27 +1840,6 @@ RValue CodeGenFunction::EmitBuiltinExpr(
return RValue::get(Res);
}
- case Builtin::BI__builtin_preserve_access_index: {
- // Only enabled preserved access index region when debuginfo
- // is available as debuginfo is needed to preserve user-level
- // access pattern.
- if (!getDebugInfo()) {
- CGM.Error(E->getExprLoc(), "using builtin_preserve_access_index() without -g");
- return RValue::get(EmitScalarExpr(E->getArg(0)));
- }
-
- // Nested builtin_preserve_access_index() not supported
- if (IsInPreservedAIRegion) {
- CGM.Error(E->getExprLoc(), "nested builtin_preserve_access_index() not supported");
- return RValue::get(EmitScalarExpr(E->getArg(0)));
- }
-
- IsInPreservedAIRegion = true;
- Value *Res = EmitScalarExpr(E->getArg(0));
- IsInPreservedAIRegion = false;
- return RValue::get(Res);
- }
-
case Builtin::BI__builtin_cimag:
case Builtin::BI__builtin_cimagf:
case Builtin::BI__builtin_cimagl:
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=365436&r1=365435&r2=365436&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Jul 8 21:15:12 2019
@@ -25,7 +25,6 @@
#include "clang/AST/Attr.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/NSAPI.h"
-#include "clang/Basic/Builtins.h"
#include "clang/Basic/CodeGenOptions.h"
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/StringExtras.h"
@@ -3419,20 +3418,8 @@ static Address emitArraySubscriptGEP(Cod
CharUnits eltAlign =
getArrayElementAlign(addr.getAlignment(), indices.back(), eltSize);
- llvm::Value *eltPtr;
- auto LastIndex = dyn_cast<llvm::ConstantInt>(indices.back());
- if (!CGF.IsInPreservedAIRegion || !LastIndex) {
- eltPtr = emitArraySubscriptGEP(
- CGF, addr.getPointer(), indices, inbounds, signedIndices,
- loc, name);
- } else {
- // Remember the original array subscript for bpf target
- unsigned idx = LastIndex->getZExtValue();
- eltPtr = CGF.Builder.CreatePreserveArrayAccessIndex(addr.getPointer(),
- indices.size() - 1,
- idx);
- }
-
+ llvm::Value *eltPtr = emitArraySubscriptGEP(
+ CGF, addr.getPointer(), indices, inbounds, signedIndices, loc, name);
return Address(eltPtr, eltAlign);
}
@@ -3921,19 +3908,6 @@ static Address emitAddrOfFieldStorage(Co
return CGF.Builder.CreateStructGEP(base, idx, field->getName());
}
-static Address emitPreserveStructAccess(CodeGenFunction &CGF, Address base,
- const FieldDecl *field) {
- const RecordDecl *rec = field->getParent();
- llvm::DIType *DbgInfo = CGF.getDebugInfo()->getOrCreateRecordType(
- CGF.getContext().getRecordType(rec), rec->getLocation());
-
- unsigned idx =
- CGF.CGM.getTypes().getCGRecordLayout(rec).getLLVMFieldNo(field);
-
- return CGF.Builder.CreatePreserveStructAccessIndex(
- base, idx, field->getFieldIndex(), DbgInfo);
-}
-
static bool hasAnyVptr(const QualType Type, const ASTContext &Context) {
const auto *RD = Type.getTypePtr()->getAsCXXRecordDecl();
if (!RD)
@@ -4041,24 +4015,9 @@ LValue CodeGenFunction::EmitLValueForFie
// a barrier every time CXXRecord field with vptr is referenced.
addr = Address(Builder.CreateLaunderInvariantGroup(addr.getPointer()),
addr.getAlignment());
-
- if (IsInPreservedAIRegion) {
- // Remember the original union field index
- llvm::DIType *DbgInfo = getDebugInfo()->getOrCreateRecordType(
- getContext().getRecordType(rec), rec->getLocation());
- addr = Address(
- Builder.CreatePreserveUnionAccessIndex(
- addr.getPointer(), field->getFieldIndex(), DbgInfo),
- addr.getAlignment());
- }
} else {
-
- if (!IsInPreservedAIRegion)
- // For structs, we GEP to the field that the record layout suggests.
- addr = emitAddrOfFieldStorage(*this, addr, field);
- else
- // Remember the original struct field index
- addr = emitPreserveStructAccess(*this, addr, field);
+ // For structs, we GEP to the field that the record layout suggests.
+ addr = emitAddrOfFieldStorage(*this, addr, field);
// If this is a reference field, load the reference right now.
if (FieldType->isReferenceType()) {
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=365436&r1=365435&r2=365436&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Mon Jul 8 21:15:12 2019
@@ -480,10 +480,6 @@ public:
/// finally block or filter expression.
bool IsOutlinedSEHHelper = false;
- /// True if CodeGen currently emits code inside presereved access index
- /// region.
- bool IsInPreservedAIRegion = false;
-
const CodeGen::CGBlockInfo *BlockInfo = nullptr;
llvm::Value *BlockPointer = nullptr;
Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=365436&r1=365435&r2=365436&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Jul 8 21:15:12 2019
@@ -191,16 +191,6 @@ static bool SemaBuiltinAddressof(Sema &S
return false;
}
-/// Check the number of arguments, and set the result type to
-/// the argument type.
-static bool SemaBuiltinPreserveAI(Sema &S, CallExpr *TheCall) {
- if (checkArgCount(S, TheCall, 1))
- return true;
-
- TheCall->setType(TheCall->getArg(0)->getType());
- return false;
-}
-
static bool SemaBuiltinOverflow(Sema &S, CallExpr *TheCall) {
if (checkArgCount(S, TheCall, 3))
return true;
@@ -1419,10 +1409,6 @@ Sema::CheckBuiltinFunctionCall(FunctionD
TheCall->setType(Context.IntTy);
break;
}
- case Builtin::BI__builtin_preserve_access_index:
- if (SemaBuiltinPreserveAI(*this, TheCall))
- return ExprError();
- break;
case Builtin::BI__builtin_call_with_static_chain:
if (SemaBuiltinCallWithStaticChain(*this, TheCall))
return ExprError();
Removed: cfe/trunk/test/CodeGen/bpf-preserve-access-index-2.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/bpf-preserve-access-index-2.c?rev=365435&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/bpf-preserve-access-index-2.c (original)
+++ cfe/trunk/test/CodeGen/bpf-preserve-access-index-2.c (removed)
@@ -1,22 +0,0 @@
-// RUN: %clang %s -target bpfeb -x c -emit-llvm -S -g -O2 -o - | FileCheck %s
-// RUN: %clang %s -target bpfel -x c -emit-llvm -S -g -O2 -o - | FileCheck %s
-
-struct t {
- int i:1;
- int j:2;
- union {
- int a;
- int b;
- } c[4];
-};
-
-#define _(x) (x)
-
-const void *test(struct t *arg) {
- return _(&arg->c[3].b);
-}
-
-// CHECK-NOT: llvm.preserve.struct.access.index
-// CHECK-NOT: llvm.preserve.array.access.index
-// CHECK-NOT: llvm.preserve.union.access.index
-// CHECK-NOT: __builtin_preserve_access_index
Removed: cfe/trunk/test/CodeGen/bpf-preserve-access-index.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/bpf-preserve-access-index.c?rev=365435&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/bpf-preserve-access-index.c (original)
+++ cfe/trunk/test/CodeGen/bpf-preserve-access-index.c (removed)
@@ -1,22 +0,0 @@
-// RUN: %clang %s -target bpfeb -x c -emit-llvm -S -g -O2 -o - | FileCheck --check-prefix=CHECK %s
-// RUN: %clang %s -target bpfel -x c -emit-llvm -S -g -O2 -o - | FileCheck --check-prefix=CHECK %s
-
-struct t {
- int i:1;
- int j:2;
- union {
- int a;
- int b;
- } c[4];
-};
-
-#define _(x) (__builtin_preserve_access_index(x))
-
-const void *test(struct t *arg) {
- return _(&arg->c[3].b);
-}
-
-// CHECK: llvm.preserve.struct.access.index
-// CHECK: llvm.preserve.array.access.index
-// CHECK: llvm.preserve.union.access.index
-// CHECK-NOT: __builtin_preserve_access_index
More information about the cfe-commits
mailing list