diff options
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 0388c67d0100..56562002e719 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -444,8 +444,10 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) { // Reset the debug location to that of the simple 'return' expression, if any // rather than that of the end of the function's scope '}'. + uint64_t RetKeyInstructionsAtomGroup = Loc ? Loc->getAtomGroup() : 0; ApplyDebugLocation AL(*this, Loc); - EmitFunctionEpilog(*CurFnInfo, EmitRetDbgLoc, EndLoc); + EmitFunctionEpilog(*CurFnInfo, EmitRetDbgLoc, EndLoc, + RetKeyInstructionsAtomGroup); EmitEndEHSpec(CurCodeDecl); assert(EHStack.empty() && @@ -624,7 +626,7 @@ CodeGenFunction::getUBSanFunctionTypeHash(QualType Ty) const { void CodeGenFunction::EmitKernelMetadata(const FunctionDecl *FD, llvm::Function *Fn) { - if (!FD->hasAttr<OpenCLKernelAttr>() && !FD->hasAttr<CUDAGlobalAttr>()) + if (!FD->hasAttr<DeviceKernelAttr>() && !FD->hasAttr<CUDAGlobalAttr>()) return; llvm::LLVMContext &Context = getLLVMContext(); @@ -1596,7 +1598,8 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn, // Implicit copy-assignment gets the same special treatment as implicit // copy-constructors. emitImplicitAssignmentOperatorBody(Args); - } else if (FD->hasAttr<OpenCLKernelAttr>() && + } else if (DeviceKernelAttr::isOpenCLSpelling( + FD->getAttr<DeviceKernelAttr>()) && GD.getKernelReferenceKind() == KernelReferenceKind::Kernel) { CallArgList CallArgs; for (unsigned i = 0; i < Args.size(); ++i) { @@ -1633,10 +1636,11 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn, CGM.getCodeGenOpts().StrictReturn || !CGM.MayDropFunctionReturn(FD->getASTContext(), FD->getReturnType()); if (SanOpts.has(SanitizerKind::Return)) { - SanitizerScope SanScope(this); + auto CheckOrdinal = SanitizerKind::SO_Return; + auto CheckHandler = SanitizerHandler::MissingReturn; + SanitizerDebugLocation SanScope(this, {CheckOrdinal}, CheckHandler); llvm::Value *IsFalse = Builder.getFalse(); - EmitCheck(std::make_pair(IsFalse, SanitizerKind::SO_Return), - SanitizerHandler::MissingReturn, + EmitCheck(std::make_pair(IsFalse, CheckOrdinal), CheckHandler, EmitCheckSourceLocation(FD->getLocation()), {}); } else if (ShouldEmitUnreachable) { if (CGM.getCodeGenOpts().OptimizationLevel == 0) @@ -2538,7 +2542,9 @@ void CodeGenFunction::EmitVariablyModifiedType(QualType type) { // expression [...] each time it is evaluated it shall have a value // greater than zero. if (SanOpts.has(SanitizerKind::VLABound)) { - SanitizerScope SanScope(this); + auto CheckOrdinal = SanitizerKind::SO_VLABound; + auto CheckHandler = SanitizerHandler::VLABoundNotPositive; + SanitizerDebugLocation SanScope(this, {CheckOrdinal}, CheckHandler); llvm::Value *Zero = llvm::Constant::getNullValue(size->getType()); clang::QualType SEType = sizeExpr->getType(); llvm::Value *CheckCondition = @@ -2548,9 +2554,8 @@ void CodeGenFunction::EmitVariablyModifiedType(QualType type) { llvm::Constant *StaticArgs[] = { EmitCheckSourceLocation(sizeExpr->getBeginLoc()), EmitCheckTypeDescriptor(SEType)}; - EmitCheck( - std::make_pair(CheckCondition, SanitizerKind::SO_VLABound), - SanitizerHandler::VLABoundNotPositive, StaticArgs, size); + EmitCheck(std::make_pair(CheckCondition, CheckOrdinal), + CheckHandler, StaticArgs, size); } // Always zexting here would be wrong if it weren't @@ -3193,7 +3198,9 @@ void CodeGenFunction::emitAlignmentAssumptionCheck( Assumption->removeFromParent(); { - SanitizerScope SanScope(this); + auto CheckOrdinal = SanitizerKind::SO_Alignment; + auto CheckHandler = SanitizerHandler::AlignmentAssumption; + SanitizerDebugLocation SanScope(this, {CheckOrdinal}, CheckHandler); if (!OffsetValue) OffsetValue = Builder.getInt1(false); // no offset. @@ -3202,8 +3209,8 @@ void CodeGenFunction::emitAlignmentAssumptionCheck( EmitCheckSourceLocation(SecondaryLoc), EmitCheckTypeDescriptor(Ty)}; llvm::Value *DynamicData[] = {Ptr, Alignment, OffsetValue}; - EmitCheck({std::make_pair(TheCheck, SanitizerKind::SO_Alignment)}, - SanitizerHandler::AlignmentAssumption, StaticData, DynamicData); + EmitCheck({std::make_pair(TheCheck, CheckOrdinal)}, CheckHandler, + StaticData, DynamicData); } // We are now in the (new, empty) "cont" basic block. |
