Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class UnusedUsingDeclsCheck : public ClangTidyCheck {
std::vector<UsingDeclContext> Contexts;
llvm::SmallPtrSet<const Decl *, 32> UsingTargetDeclsCache;

StringRef RawStringHeaderFileExtensions;
FileExtensionsSet HeaderFileExtensions;
};

Expand Down
105 changes: 56 additions & 49 deletions clang/lib/AST/ByteCode/Compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6194,60 +6194,67 @@ bool Compiler<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) {
return revisit(VD);
}

if (D != InitializingDecl) {
// Try to lazily visit (or emit dummy pointers for) declarations
// we haven't seen yet.
if (Ctx.getLangOpts().CPlusPlus) {
if (const auto *VD = dyn_cast<VarDecl>(D)) {
const auto typeShouldBeVisited = [&](QualType T) -> bool {
if (T.isConstant(Ctx.getASTContext()))
return true;
return T->isReferenceType();
};
// Avoid infinite recursion.
if (D == InitializingDecl)
return this->emitDummyPtr(D, E);

// Try to lazily visit (or emit dummy pointers for) declarations
// we haven't seen yet.
// For C.
if (!Ctx.getLangOpts().CPlusPlus) {
if (const auto *VD = dyn_cast<VarDecl>(D);
VD && VD->getAnyInitializer() &&
VD->getType().isConstant(Ctx.getASTContext()) && !VD->isWeak())
return revisit(VD);
return this->emitDummyPtr(D, E);
}

// DecompositionDecls are just proxies for us.
if (isa<DecompositionDecl>(VD))
return revisit(VD);

if ((VD->hasGlobalStorage() || VD->isStaticDataMember()) &&
typeShouldBeVisited(VD->getType())) {
if (const Expr *Init = VD->getAnyInitializer();
Init && !Init->isValueDependent()) {
// Whether or not the evaluation is successul doesn't really matter
// here -- we will create a global variable in any case, and that
// will have the state of initializer evaluation attached.
APValue V;
SmallVector<PartialDiagnosticAt> Notes;
(void)Init->EvaluateAsInitializer(V, Ctx.getASTContext(), VD, Notes,
true);
return this->visitDeclRef(D, E);
}
return revisit(VD);
}
// ... and C++.
const auto *VD = dyn_cast<VarDecl>(D);
if (!VD)
return this->emitDummyPtr(D, E);

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

if (VD->evaluateValue())
return revisit(VD);
// DecompositionDecls are just proxies for us.
if (isa<DecompositionDecl>(VD))
return revisit(VD);

if ((VD->hasGlobalStorage() || VD->isStaticDataMember()) &&
typeShouldBeVisited(VD->getType())) {
if (const Expr *Init = VD->getAnyInitializer();
Init && !Init->isValueDependent()) {
// Whether or not the evaluation is successul doesn't really matter
// here -- we will create a global variable in any case, and that
// will have the state of initializer evaluation attached.
APValue V;
SmallVector<PartialDiagnosticAt> Notes;
(void)Init->EvaluateAsInitializer(V, Ctx.getASTContext(), VD, Notes,
true);
return this->visitDeclRef(D, E);
}
return revisit(VD);
}

// FIXME: The evaluateValue() check here is a little ridiculous, since
// it will ultimately call into Context::evaluateAsInitializer(). In
// other words, we're evaluating the initializer, just to know if we can
// evaluate the initializer.
if (VD->isLocalVarDecl() && typeShouldBeVisited(VD->getType()) &&
VD->getInit() && !VD->getInit()->isValueDependent()) {

if (VD->evaluateValue())
return revisit(VD);

if (!D->getType()->isReferenceType())
return this->emitDummyPtr(D, E);
if (!D->getType()->isReferenceType())
return this->emitDummyPtr(D, E);

return this->emitInvalidDeclRef(cast<DeclRefExpr>(E),
/*InitializerFailed=*/true, E);
}
}
} else {
if (const auto *VD = dyn_cast<VarDecl>(D);
VD && VD->getAnyInitializer() &&
VD->getType().isConstant(Ctx.getASTContext()) && !VD->isWeak())
return revisit(VD);
}
return this->emitInvalidDeclRef(cast<DeclRefExpr>(E),
/*InitializerFailed=*/true, E);
}

return this->emitDummyPtr(D, E);
Expand Down
21 changes: 6 additions & 15 deletions clang/lib/CodeGen/CGDebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2016,29 +2016,20 @@ llvm::DISubroutineType *CGDebugInfo::getOrCreateInstanceMethodType(
// First element is always return type. For 'void' functions it is NULL.
Elts.push_back(Args[0]);

const bool HasExplicitObjectParameter = ThisPtr.isNull();

// "this" pointer is always first argument. For explicit "this"
// parameters, it will already be in Args[1].
if (!HasExplicitObjectParameter) {
// "this" pointer is always first argument.
// ThisPtr may be null if the member function has an explicit 'this'
// parameter.
if (!ThisPtr.isNull()) {
llvm::DIType *ThisPtrType = getOrCreateType(ThisPtr, Unit);
TypeCache[ThisPtr.getAsOpaquePtr()].reset(ThisPtrType);
ThisPtrType =
DBuilder.createObjectPointerType(ThisPtrType, /*Implicit=*/true);
ThisPtrType = DBuilder.createObjectPointerType(ThisPtrType);
Elts.push_back(ThisPtrType);
}

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

// Attach FlagObjectPointer to the explicit "this" parameter.
if (HasExplicitObjectParameter) {
assert(Elts.size() >= 2 && Args.size() >= 2 &&
"Expected at least return type and object parameter.");
Elts[1] = DBuilder.createObjectPointerType(Args[1], /*Implicit=*/false);
}

llvm::DITypeRefArray EltTypeArray = DBuilder.getOrCreateTypeArray(Elts);

return DBuilder.createSubroutineType(EltTypeArray, OriginalFunc->getFlags(),
Expand Down Expand Up @@ -5127,7 +5118,7 @@ llvm::DIType *CGDebugInfo::CreateSelfType(const QualType &QualTy,
llvm::DIType *CachedTy = getTypeOrNull(QualTy);
if (CachedTy)
Ty = CachedTy;
return DBuilder.createObjectPointerType(Ty, /*Implicit=*/true);
return DBuilder.createObjectPointerType(Ty);
}

void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(
Expand Down
7 changes: 4 additions & 3 deletions clang/test/CodeGenCXX/debug-info-object-pointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
// CHECK: !DIDerivedType(tag: DW_TAG_pointer_type
// CHECK-SAME: flags: DIFlagArtificial | DIFlagObjectPointer
//
// // FIXME: DIFlagObjectPointer not attached to the explicit object
// // argument in the subprogram declaration.
// CHECK: !DISubprogram(name: "explicit_this",
// flags: DIFlagPrototyped
//
// CHECK: !DIDerivedType(tag: DW_TAG_rvalue_reference_type
// CHECK-SAME: flags: DIFlagObjectPointer)
// CHECK-NOT: DIFlagObjectPointer
// CHECK-NOT: DIFlagArtificial
//
// CHECK: !DILocalVariable(name: "this", arg: 1
// CHECK-SAME: flags: DIFlagArtificial | DIFlagObjectPointer
Expand Down
12 changes: 12 additions & 0 deletions compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,17 @@ INTERCEPTOR(int, getnameinfo, const struct sockaddr *sa, socklen_t salen,
return REAL(getnameinfo)(sa, salen, host, hostlen, serv, servlen, flags);
}

#if SANITIZER_INTERCEPT_GETSOCKNAME
INTERCEPTOR(int, getsockname, int socket, struct sockaddr *sa,
socklen_t *salen) {
__rtsan_notify_intercepted_call("getsockname");
return REAL(getsockname)(socket, sa, salen);
}
#define RTSAN_MAYBE_INTERCEPT_GETSOCKNAME INTERCEPT_FUNCTION(getsockname)
#else
#define RTSAN_MAYBE_INTERCEPT_GETSOCKNAME
#endif

INTERCEPTOR(int, bind, int socket, const struct sockaddr *address,
socklen_t address_len) {
__rtsan_notify_intercepted_call("bind");
Expand Down Expand Up @@ -1189,6 +1200,7 @@ void __rtsan::InitializeInterceptors() {
INTERCEPT_FUNCTION(shutdown);
INTERCEPT_FUNCTION(socket);
RTSAN_MAYBE_INTERCEPT_ACCEPT4;
RTSAN_MAYBE_INTERCEPT_GETSOCKNAME;

RTSAN_MAYBE_INTERCEPT_SELECT;
INTERCEPT_FUNCTION(pselect);
Expand Down
10 changes: 10 additions & 0 deletions compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,16 @@ TEST(TestRtsanInterceptors, ShutdownOnASocketDiesWhenRealtime) {
ExpectNonRealtimeSurvival(Func);
}

#if SANITIZER_INTERCEPT_GETSOCKNAME
TEST(TestRtsanInterceptors, GetsocknameOnASocketDiesWhenRealtime) {
sockaddr addr{};
socklen_t len{};
auto Func = [&]() { getsockname(0, &addr, &len); };
ExpectRealtimeDeath(Func, "getsockname");
ExpectNonRealtimeSurvival(Func);
}
#endif

/*
I/O Multiplexing
*/
Expand Down
11 changes: 4 additions & 7 deletions llvm/include/llvm-c/DebugInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -870,16 +870,13 @@ LLVMDIBuilderCreateObjCProperty(LLVMDIBuilderRef Builder,
LLVMMetadataRef Ty);

/**
* Create a uniqued DIType* clone with FlagObjectPointer. If \c Implicit
* is true, then also set FlagArtificial.
* Create a uniqued DIType* clone with FlagObjectPointer and FlagArtificial set.
* \param Builder The DIBuilder.
* \param Type The underlying type to which this pointer points.
* \param Implicit Indicates whether this pointer was implicitly generated
* (i.e., not spelled out in source).
*/
LLVMMetadataRef LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
LLVMMetadataRef Type,
LLVMBool Implicit);
LLVMMetadataRef
LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
LLVMMetadataRef Type);

/**
* Create debugging information entry for a qualified
Expand Down
6 changes: 3 additions & 3 deletions llvm/include/llvm/IR/DIBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -662,9 +662,9 @@ namespace llvm {
/// Create a uniqued clone of \p Ty with FlagArtificial set.
static DIType *createArtificialType(DIType *Ty);

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

/// Create a permanent forward-declared type.
DICompositeType *createForwardDecl(unsigned Tag, StringRef Name,
Expand Down
8 changes: 2 additions & 6 deletions llvm/lib/IR/DIBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,15 +644,11 @@ DIType *DIBuilder::createArtificialType(DIType *Ty) {
return createTypeWithFlags(Ty, DINode::FlagArtificial);
}

DIType *DIBuilder::createObjectPointerType(DIType *Ty, bool Implicit) {
DIType *DIBuilder::createObjectPointerType(DIType *Ty) {
// FIXME: Restrict this to the nodes where it's valid.
if (Ty->isObjectPointer())
return Ty;
DINode::DIFlags Flags = DINode::FlagObjectPointer;

if (Implicit)
Flags |= DINode::FlagArtificial;

DINode::DIFlags Flags = DINode::FlagObjectPointer | DINode::FlagArtificial;
return createTypeWithFlags(Ty, Flags);
}

Expand Down
9 changes: 4 additions & 5 deletions llvm/lib/IR/DebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1432,11 +1432,10 @@ LLVMDIBuilderCreateObjCProperty(LLVMDIBuilderRef Builder,
PropertyAttributes, unwrapDI<DIType>(Ty)));
}

LLVMMetadataRef LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
LLVMMetadataRef Type,
LLVMBool Implicit) {
return wrap(unwrap(Builder)->createObjectPointerType(unwrapDI<DIType>(Type),
Implicit));
LLVMMetadataRef
LLVMDIBuilderCreateObjectPointerType(LLVMDIBuilderRef Builder,
LLVMMetadataRef Type) {
return wrap(unwrap(Builder)->createObjectPointerType(unwrapDI<DIType>(Type)));
}

LLVMMetadataRef
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/AArch64/AArch64InstrInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -2030,6 +2030,8 @@ let Predicates = [HasPAuthLR] in {
// opcode2, opcode, asm
def AUTIASPPCr : SignAuthOneReg<0b00001, 0b100100, "autiasppcr">;
def AUTIBSPPCr : SignAuthOneReg<0b00001, 0b100101, "autibsppcr">;
}
let Defs = [X17], Uses = [X15, X16, X17] in {
// opcode2, opcode, asm
def PACIA171615 : SignAuthFixedRegs<0b00001, 0b100010, "pacia171615">;
def PACIB171615 : SignAuthFixedRegs<0b00001, 0b100011, "pacib171615">;
Expand Down
11 changes: 10 additions & 1 deletion llvm/lib/Target/X86/X86ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2812,7 +2812,16 @@ bool X86::mayFoldLoadIntoBroadcastFromMem(SDValue Op, MVT EltVT,
}

bool X86::mayFoldIntoStore(SDValue Op) {
return Op.hasOneUse() && ISD::isNormalStore(*Op.getNode()->user_begin());
if (!Op.hasOneUse())
return false;
// Peek through (oneuse) bitcast users
SDNode *User = *Op->user_begin();
while (User->getOpcode() == ISD::BITCAST) {
if (!User->hasOneUse())
return false;
User = *User->user_begin();
}
return ISD::isNormalStore(User);
}

bool X86::mayFoldIntoZeroExtend(SDValue Op) {
Expand Down
3 changes: 1 addition & 2 deletions llvm/test/CodeGen/X86/canonicalize-vars-f16-type.ll
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ define void @v_test_canonicalize__half(half addrspace(1)* %out) nounwind {
; AVX512-NEXT: vxorps %xmm1, %xmm1, %xmm1
; AVX512-NEXT: vblendps {{.*#+}} xmm0 = xmm0[0],xmm1[1,2,3]
; AVX512-NEXT: vcvtps2ph $4, %xmm0, %xmm0
; AVX512-NEXT: vmovd %xmm0, %eax
; AVX512-NEXT: movw %ax, (%rdi)
; AVX512-NEXT: vpextrw $0, %xmm0, (%rdi)
; AVX512-NEXT: retq
entry:
%val = load half, half addrspace(1)* %out
Expand Down
3 changes: 1 addition & 2 deletions llvm/test/CodeGen/X86/cvt16.ll
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ define void @test1(float %src, ptr %dest) nounwind {
; F16C-LABEL: test1:
; F16C: # %bb.0:
; F16C-NEXT: vcvtps2ph $4, %xmm0, %xmm0
; F16C-NEXT: vmovd %xmm0, %eax
; F16C-NEXT: movw %ax, (%rdi)
; F16C-NEXT: vpextrw $0, %xmm0, (%rdi)
; F16C-NEXT: retq
;
; SOFTFLOAT-LABEL: test1:
Expand Down
6 changes: 2 additions & 4 deletions llvm/test/CodeGen/X86/fp-strict-scalar-fp16.ll
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,7 @@ define void @fptrunc_float_to_f16(ptr %val, ptr%ret) nounwind strictfp {
; AVX: # %bb.0:
; AVX-NEXT: vmovss {{.*#+}} xmm0 = mem[0],zero,zero,zero
; AVX-NEXT: vcvtps2ph $4, %xmm0, %xmm0
; AVX-NEXT: vmovd %xmm0, %eax
; AVX-NEXT: movw %ax, (%rsi)
; AVX-NEXT: vpextrw $0, %xmm0, (%rsi)
; AVX-NEXT: retq
;
; X86-LABEL: fptrunc_float_to_f16:
Expand Down Expand Up @@ -411,8 +410,7 @@ define void @fsqrt_f16(ptr %a) nounwind strictfp {
; AVX-NEXT: vxorps %xmm1, %xmm1, %xmm1
; AVX-NEXT: vblendps {{.*#+}} xmm0 = xmm0[0],xmm1[1,2,3]
; AVX-NEXT: vcvtps2ph $4, %xmm0, %xmm0
; AVX-NEXT: vmovd %xmm0, %eax
; AVX-NEXT: movw %ax, (%rdi)
; AVX-NEXT: vpextrw $0, %xmm0, (%rdi)
; AVX-NEXT: retq
;
; X86-LABEL: fsqrt_f16:
Expand Down
Loading
Loading