Skip to content

Commit 983aa59

Browse files
authored
Merge pull request #533 from Xilinx/bump_to_67c3f2b4
[AutoBump] Merge with 67c3f2b (Jan 18) (1)
2 parents 52e1d52 + 217e406 commit 983aa59

24 files changed

+176
-208
lines changed

clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.h

-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ class UnusedUsingDeclsCheck : public ClangTidyCheck {
5151
std::vector<UsingDeclContext> Contexts;
5252
llvm::SmallPtrSet<const Decl *, 32> UsingTargetDeclsCache;
5353

54-
StringRef RawStringHeaderFileExtensions;
5554
FileExtensionsSet HeaderFileExtensions;
5655
};
5756

clang/lib/AST/ByteCode/Compiler.cpp

+56-49
Original file line numberDiff line numberDiff line change
@@ -6194,60 +6194,67 @@ bool Compiler<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) {
61946194
return revisit(VD);
61956195
}
61966196

6197-
if (D != InitializingDecl) {
6198-
// Try to lazily visit (or emit dummy pointers for) declarations
6199-
// we haven't seen yet.
6200-
if (Ctx.getLangOpts().CPlusPlus) {
6201-
if (const auto *VD = dyn_cast<VarDecl>(D)) {
6202-
const auto typeShouldBeVisited = [&](QualType T) -> bool {
6203-
if (T.isConstant(Ctx.getASTContext()))
6204-
return true;
6205-
return T->isReferenceType();
6206-
};
6197+
// Avoid infinite recursion.
6198+
if (D == InitializingDecl)
6199+
return this->emitDummyPtr(D, E);
6200+
6201+
// Try to lazily visit (or emit dummy pointers for) declarations
6202+
// we haven't seen yet.
6203+
// For C.
6204+
if (!Ctx.getLangOpts().CPlusPlus) {
6205+
if (const auto *VD = dyn_cast<VarDecl>(D);
6206+
VD && VD->getAnyInitializer() &&
6207+
VD->getType().isConstant(Ctx.getASTContext()) && !VD->isWeak())
6208+
return revisit(VD);
6209+
return this->emitDummyPtr(D, E);
6210+
}
62076211

6208-
// DecompositionDecls are just proxies for us.
6209-
if (isa<DecompositionDecl>(VD))
6210-
return revisit(VD);
6211-
6212-
if ((VD->hasGlobalStorage() || VD->isStaticDataMember()) &&
6213-
typeShouldBeVisited(VD->getType())) {
6214-
if (const Expr *Init = VD->getAnyInitializer();
6215-
Init && !Init->isValueDependent()) {
6216-
// Whether or not the evaluation is successul doesn't really matter
6217-
// here -- we will create a global variable in any case, and that
6218-
// will have the state of initializer evaluation attached.
6219-
APValue V;
6220-
SmallVector<PartialDiagnosticAt> Notes;
6221-
(void)Init->EvaluateAsInitializer(V, Ctx.getASTContext(), VD, Notes,
6222-
true);
6223-
return this->visitDeclRef(D, E);
6224-
}
6225-
return revisit(VD);
6226-
}
6212+
// ... and C++.
6213+
const auto *VD = dyn_cast<VarDecl>(D);
6214+
if (!VD)
6215+
return this->emitDummyPtr(D, E);
62276216

6228-
// FIXME: The evaluateValue() check here is a little ridiculous, since
6229-
// it will ultimately call into Context::evaluateAsInitializer(). In
6230-
// other words, we're evaluating the initializer, just to know if we can
6231-
// evaluate the initializer.
6232-
if (VD->isLocalVarDecl() && typeShouldBeVisited(VD->getType()) &&
6233-
VD->getInit() && !VD->getInit()->isValueDependent()) {
6217+
const auto typeShouldBeVisited = [&](QualType T) -> bool {
6218+
if (T.isConstant(Ctx.getASTContext()))
6219+
return true;
6220+
return T->isReferenceType();
6221+
};
62346222

6235-
if (VD->evaluateValue())
6236-
return revisit(VD);
6223+
// DecompositionDecls are just proxies for us.
6224+
if (isa<DecompositionDecl>(VD))
6225+
return revisit(VD);
6226+
6227+
if ((VD->hasGlobalStorage() || VD->isStaticDataMember()) &&
6228+
typeShouldBeVisited(VD->getType())) {
6229+
if (const Expr *Init = VD->getAnyInitializer();
6230+
Init && !Init->isValueDependent()) {
6231+
// Whether or not the evaluation is successul doesn't really matter
6232+
// here -- we will create a global variable in any case, and that
6233+
// will have the state of initializer evaluation attached.
6234+
APValue V;
6235+
SmallVector<PartialDiagnosticAt> Notes;
6236+
(void)Init->EvaluateAsInitializer(V, Ctx.getASTContext(), VD, Notes,
6237+
true);
6238+
return this->visitDeclRef(D, E);
6239+
}
6240+
return revisit(VD);
6241+
}
6242+
6243+
// FIXME: The evaluateValue() check here is a little ridiculous, since
6244+
// it will ultimately call into Context::evaluateAsInitializer(). In
6245+
// other words, we're evaluating the initializer, just to know if we can
6246+
// evaluate the initializer.
6247+
if (VD->isLocalVarDecl() && typeShouldBeVisited(VD->getType()) &&
6248+
VD->getInit() && !VD->getInit()->isValueDependent()) {
6249+
6250+
if (VD->evaluateValue())
6251+
return revisit(VD);
62376252

6238-
if (!D->getType()->isReferenceType())
6239-
return this->emitDummyPtr(D, E);
6253+
if (!D->getType()->isReferenceType())
6254+
return this->emitDummyPtr(D, E);
62406255

6241-
return this->emitInvalidDeclRef(cast<DeclRefExpr>(E),
6242-
/*InitializerFailed=*/true, E);
6243-
}
6244-
}
6245-
} else {
6246-
if (const auto *VD = dyn_cast<VarDecl>(D);
6247-
VD && VD->getAnyInitializer() &&
6248-
VD->getType().isConstant(Ctx.getASTContext()) && !VD->isWeak())
6249-
return revisit(VD);
6250-
}
6256+
return this->emitInvalidDeclRef(cast<DeclRefExpr>(E),
6257+
/*InitializerFailed=*/true, E);
62516258
}
62526259

62536260
return this->emitDummyPtr(D, E);

clang/lib/CodeGen/CGDebugInfo.cpp

+6-15
Original file line numberDiff line numberDiff line change
@@ -2016,29 +2016,20 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType(
20162016
// First element is always return type. For 'void' functions it is NULL.
20172017
Elts.push_back(Args[0]);
20182018

2019-
const bool HasExplicitObjectParameter = ThisPtr.isNull();
2020-
2021-
// "this" pointer is always first argument. For explicit "this"
2022-
// parameters, it will already be in Args[1].
2023-
if (!HasExplicitObjectParameter) {
2019+
// "this" pointer is always first argument.
2020+
// ThisPtr may be null if the member function has an explicit 'this'
2021+
// parameter.
2022+
if (!ThisPtr.isNull()) {
20242023
llvm::DIType *ThisPtrType = getOrCreateType(ThisPtr, Unit);
20252024
TypeCache[ThisPtr.getAsOpaquePtr()].reset(ThisPtrType);
2026-
ThisPtrType =
2027-
DBuilder.createObjectPointerType(ThisPtrType, /*Implicit=*/true);
2025+
ThisPtrType = DBuilder.createObjectPointerType(ThisPtrType);
20282026
Elts.push_back(ThisPtrType);
20292027
}
20302028

20312029
// Copy rest of the arguments.
20322030
for (unsigned i = 1, e = Args.size(); i != e; ++i)
20332031
Elts.push_back(Args[i]);
20342032

2035-
// Attach FlagObjectPointer to the explicit "this" parameter.
2036-
if (HasExplicitObjectParameter) {
2037-
assert(Elts.size() >= 2 && Args.size() >= 2 &&
2038-
"Expected at least return type and object parameter.");
2039-
Elts[1] = DBuilder.createObjectPointerType(Args[1], /*Implicit=*/false);
2040-
}
2041-
20422033
llvm::DITypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray(Elts);
20432034

20442035
return DBuilder.createSubroutineType(EltTypeArray, OriginalFunc->getFlags(),
@@ -5127,7 +5118,7 @@ llvm::DIType *CGDebugInfo::CreateSelfType(const QualType &QualTy,
51275118
llvm::DIType *CachedTy = getTypeOrNull(QualTy);
51285119
if (CachedTy)
51295120
Ty = CachedTy;
5130-
return DBuilder.createObjectPointerType(Ty, /*Implicit=*/true);
5121+
return DBuilder.createObjectPointerType(Ty);
51315122
}
51325123

51335124
void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(

clang/test/CodeGenCXX/debug-info-object-pointer.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
// CHECK: !DIDerivedType(tag: DW_TAG_pointer_type
66
// CHECK-SAME: flags: DIFlagArtificial | DIFlagObjectPointer
77
//
8+
// // FIXME: DIFlagObjectPointer not attached to the explicit object
9+
// // argument in the subprogram declaration.
810
// CHECK: !DISubprogram(name: "explicit_this",
911
// flags: DIFlagPrototyped
10-
//
11-
// CHECK: !DIDerivedType(tag: DW_TAG_rvalue_reference_type
12-
// CHECK-SAME: flags: DIFlagObjectPointer)
12+
// CHECK-NOT: DIFlagObjectPointer
13+
// CHECK-NOT: DIFlagArtificial
1314
//
1415
// CHECK: !DILocalVariable(name: "this", arg: 1
1516
// CHECK-SAME: flags: DIFlagArtificial | DIFlagObjectPointer

compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,17 @@ INTERCEPTOR(int, getnameinfo, const struct sockaddr *sa, socklen_t salen,
829829
return REAL(getnameinfo)(sa, salen, host, hostlen, serv, servlen, flags);
830830
}
831831

832+
#if SANITIZER_INTERCEPT_GETSOCKNAME
833+
INTERCEPTOR(int, getsockname, int socket, struct sockaddr *sa,
834+
socklen_t *salen) {
835+
__rtsan_notify_intercepted_call("getsockname");
836+
return REAL(getsockname)(socket, sa, salen);
837+
}
838+
#define RTSAN_MAYBE_INTERCEPT_GETSOCKNAME INTERCEPT_FUNCTION(getsockname)
839+
#else
840+
#define RTSAN_MAYBE_INTERCEPT_GETSOCKNAME
841+
#endif
842+
832843
INTERCEPTOR(int, bind, int socket, const struct sockaddr *address,
833844
socklen_t address_len) {
834845
__rtsan_notify_intercepted_call("bind");
@@ -1189,6 +1200,7 @@ void __rtsan::InitializeInterceptors() {
11891200
INTERCEPT_FUNCTION(shutdown);
11901201
INTERCEPT_FUNCTION(socket);
11911202
RTSAN_MAYBE_INTERCEPT_ACCEPT4;
1203+
RTSAN_MAYBE_INTERCEPT_GETSOCKNAME;
11921204

11931205
RTSAN_MAYBE_INTERCEPT_SELECT;
11941206
INTERCEPT_FUNCTION(pselect);

compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,16 @@ TEST(TestRtsanInterceptors, ShutdownOnASocketDiesWhenRealtime) {
11531153
ExpectNonRealtimeSurvival(Func);
11541154
}
11551155

1156+
#if SANITIZER_INTERCEPT_GETSOCKNAME
1157+
TEST(TestRtsanInterceptors, GetsocknameOnASocketDiesWhenRealtime) {
1158+
sockaddr addr{};
1159+
socklen_t len{};
1160+
auto Func = [&]() { getsockname(0, &addr, &len); };
1161+
ExpectRealtimeDeath(Func, "getsockname");
1162+
ExpectNonRealtimeSurvival(Func);
1163+
}
1164+
#endif
1165+
11561166
/*
11571167
I/O Multiplexing
11581168
*/

llvm/include/llvm-c/DebugInfo.h

+4-7
Original file line numberDiff line numberDiff line change
@@ -870,16 +870,13 @@ LLVMDIBuilderCreateObjCProperty(LLVMDIBuilderRef Builder,
870870
LLVMMetadataRef Ty);
871871

872872
/**
873-
* Create a uniqued DIType* clone with FlagObjectPointer. If \c Implicit
874-
* is true, then also set FlagArtificial.
873+
* Create a uniqued DIType* clone with FlagObjectPointer and FlagArtificial set.
875874
* \param Builder The DIBuilder.
876875
* \param Type The underlying type to which this pointer points.
877-
* \param Implicit Indicates whether this pointer was implicitly generated
878-
* (i.e., not spelled out in source).
879876
*/
880-
LLVMMetadataRef LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
881-
LLVMMetadataRef Type,
882-
LLVMBool Implicit);
877+
LLVMMetadataRef
878+
LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
879+
LLVMMetadataRef Type);
883880

884881
/**
885882
* Create debugging information entry for a qualified

llvm/include/llvm/IR/DIBuilder.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -662,9 +662,9 @@ namespace llvm {
662662
/// Create a uniqued clone of \p Ty with FlagArtificial set.
663663
static DIType *createArtificialType(DIType *Ty);
664664

665-
/// Create a uniqued clone of \p Ty with FlagObjectPointer set.
666-
/// If \p Implicit is true, also set FlagArtificial.
667-
static DIType *createObjectPointerType(DIType *Ty, bool Implicit);
665+
/// Create a uniqued clone of \p Ty with FlagObjectPointer and
666+
/// FlagArtificial set.
667+
static DIType *createObjectPointerType(DIType *Ty);
668668

669669
/// Create a permanent forward-declared type.
670670
DICompositeType *createForwardDecl(unsigned Tag, StringRef Name,

llvm/lib/IR/DIBuilder.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -644,15 +644,11 @@ DIType *DIBuilder::createArtificialType(DIType *Ty) {
644644
return createTypeWithFlags(Ty, DINode::FlagArtificial);
645645
}
646646

647-
DIType *DIBuilder::createObjectPointerType(DIType *Ty, bool Implicit) {
647+
DIType *DIBuilder::createObjectPointerType(DIType *Ty) {
648648
// FIXME: Restrict this to the nodes where it's valid.
649649
if (Ty->isObjectPointer())
650650
return Ty;
651-
DINode::DIFlags Flags = DINode::FlagObjectPointer;
652-
653-
if (Implicit)
654-
Flags |= DINode::FlagArtificial;
655-
651+
DINode::DIFlags Flags = DINode::FlagObjectPointer | DINode::FlagArtificial;
656652
return createTypeWithFlags(Ty, Flags);
657653
}
658654

llvm/lib/IR/DebugInfo.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -1432,11 +1432,10 @@ LLVMDIBuilderCreateObjCProperty(LLVMDIBuilderRef Builder,
14321432
PropertyAttributes, unwrapDI<DIType>(Ty)));
14331433
}
14341434

1435-
LLVMMetadataRef LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
1436-
LLVMMetadataRef Type,
1437-
LLVMBool Implicit) {
1438-
return wrap(unwrap(Builder)->createObjectPointerType(unwrapDI<DIType>(Type),
1439-
Implicit));
1435+
LLVMMetadataRef
1436+
LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
1437+
LLVMMetadataRef Type) {
1438+
return wrap(unwrap(Builder)->createObjectPointerType(unwrapDI<DIType>(Type)));
14401439
}
14411440

14421441
LLVMMetadataRef

llvm/lib/Target/AArch64/AArch64InstrInfo.td

+2
Original file line numberDiff line numberDiff line change
@@ -2030,6 +2030,8 @@ let Predicates = [HasPAuthLR] in {
20302030
// opcode2, opcode, asm
20312031
def AUTIASPPCr : SignAuthOneReg<0b00001, 0b100100, "autiasppcr">;
20322032
def AUTIBSPPCr : SignAuthOneReg<0b00001, 0b100101, "autibsppcr">;
2033+
}
2034+
let Defs = [X17], Uses = [X15, X16, X17] in {
20332035
// opcode2, opcode, asm
20342036
def PACIA171615 : SignAuthFixedRegs<0b00001, 0b100010, "pacia171615">;
20352037
def PACIB171615 : SignAuthFixedRegs<0b00001, 0b100011, "pacib171615">;

llvm/lib/Target/X86/X86ISelLowering.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -2812,7 +2812,16 @@ bool X86::mayFoldLoadIntoBroadcastFromMem(SDValue Op, MVT EltVT,
28122812
}
28132813

28142814
bool X86::mayFoldIntoStore(SDValue Op) {
2815-
return Op.hasOneUse() && ISD::isNormalStore(*Op.getNode()->user_begin());
2815+
if (!Op.hasOneUse())
2816+
return false;
2817+
// Peek through (oneuse) bitcast users
2818+
SDNode *User = *Op->user_begin();
2819+
while (User->getOpcode() == ISD::BITCAST) {
2820+
if (!User->hasOneUse())
2821+
return false;
2822+
User = *User->user_begin();
2823+
}
2824+
return ISD::isNormalStore(User);
28162825
}
28172826

28182827
bool X86::mayFoldIntoZeroExtend(SDValue Op) {

llvm/test/CodeGen/X86/canonicalize-vars-f16-type.ll

+1-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ define void @v_test_canonicalize__half(half addrspace(1)* %out) nounwind {
5353
; AVX512-NEXT: vxorps %xmm1, %xmm1, %xmm1
5454
; AVX512-NEXT: vblendps {{.*#+}} xmm0 = xmm0[0],xmm1[1,2,3]
5555
; AVX512-NEXT: vcvtps2ph $4, %xmm0, %xmm0
56-
; AVX512-NEXT: vmovd %xmm0, %eax
57-
; AVX512-NEXT: movw %ax, (%rdi)
56+
; AVX512-NEXT: vpextrw $0, %xmm0, (%rdi)
5857
; AVX512-NEXT: retq
5958
entry:
6059
%val = load half, half addrspace(1)* %out

llvm/test/CodeGen/X86/cvt16.ll

+1-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ define void @test1(float %src, ptr %dest) nounwind {
3434
; F16C-LABEL: test1:
3535
; F16C: # %bb.0:
3636
; F16C-NEXT: vcvtps2ph $4, %xmm0, %xmm0
37-
; F16C-NEXT: vmovd %xmm0, %eax
38-
; F16C-NEXT: movw %ax, (%rdi)
37+
; F16C-NEXT: vpextrw $0, %xmm0, (%rdi)
3938
; F16C-NEXT: retq
4039
;
4140
; SOFTFLOAT-LABEL: test1:

llvm/test/CodeGen/X86/fp-strict-scalar-fp16.ll

+2-4
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,7 @@ define void @fptrunc_float_to_f16(ptr %val, ptr%ret) nounwind strictfp {
316316
; AVX: # %bb.0:
317317
; AVX-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
318318
; AVX-NEXT: vcvtps2ph $4, %xmm0, %xmm0
319-
; AVX-NEXT: vmovd %xmm0, %eax
320-
; AVX-NEXT: movw %ax, (%rsi)
319+
; AVX-NEXT: vpextrw $0, %xmm0, (%rsi)
321320
; AVX-NEXT: retq
322321
;
323322
; X86-LABEL: fptrunc_float_to_f16:
@@ -411,8 +410,7 @@ define void @fsqrt_f16(ptr %a) nounwind strictfp {
411410
; AVX-NEXT: vxorps %xmm1, %xmm1, %xmm1
412411
; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm0[0],xmm1[1,2,3]
413412
; AVX-NEXT: vcvtps2ph $4, %xmm0, %xmm0
414-
; AVX-NEXT: vmovd %xmm0, %eax
415-
; AVX-NEXT: movw %ax, (%rdi)
413+
; AVX-NEXT: vpextrw $0, %xmm0, (%rdi)
416414
; AVX-NEXT: retq
417415
;
418416
; X86-LABEL: fsqrt_f16:

0 commit comments

Comments
 (0)