https://github.com/fmayer updated https://github.com/llvm/llvm-project/pull/128977
>From 0fe2ba3242026457d8afc46c4a3338efd941c42f Mon Sep 17 00:00:00 2001 From: Florian Mayer <fma...@google.com> Date: Wed, 26 Feb 2025 17:12:43 -0800 Subject: [PATCH 1/2] fmt Created using spr 1.3.4 --- clang/lib/CodeGen/CGExpr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index dbd24547b2304..dc3b253237e51 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -3623,7 +3623,6 @@ void CodeGenFunction::EmitCheck( llvm::Value *RecoverableCond = nullptr; llvm::Value *TrapCond = nullptr; bool NoMerge = false; - // Expand checks into: // (Check1 || !allow_ubsan_check) && (Check2 || !allow_ubsan_check) ... // We need separate allow_ubsan_check intrinsics because they have separately @@ -3933,6 +3932,7 @@ void CodeGenFunction::EmitTrapCheck(llvm::Value *Checked, TrapBBs.resize(CheckHandlerID + 1); llvm::BasicBlock *&TrapBB = TrapBBs[CheckHandlerID]; + NoMerge = NoMerge || !CGM.getCodeGenOpts().OptimizationLevel || (CurCodeDecl && CurCodeDecl->hasAttr<OptimizeNoneAttr>()); >From a16b7a8c48353226fe1323a45f59cd4167ddc3d4 Mon Sep 17 00:00:00 2001 From: Florian Mayer <fma...@google.com> Date: Wed, 26 Feb 2025 17:15:20 -0800 Subject: [PATCH 2/2] rename & fmt Created using spr 1.3.4 --- clang/lib/CodeGen/CGDebugInfo.cpp | 7 ++++--- clang/lib/CodeGen/CGDebugInfo.h | 8 +++++--- clang/lib/CodeGen/CGExpr.cpp | 5 ++--- clang/test/CodeGen/bounds-checking-debuginfo.c | 4 ++-- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index ae19e8f724314..35fd78b15ff30 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -3598,13 +3598,14 @@ llvm::DIMacroFile *CGDebugInfo::CreateTempMacroFile(llvm::DIMacroFile *Parent, return DBuilder.createTempMacroFile(Parent, Line, FName); } -llvm::DILocation *CGDebugInfo::CreateSyntheticInline( - llvm::DebugLoc TrapLocation, StringRef FuncName) { +llvm::DILocation * +CGDebugInfo::CreateSyntheticInline(llvm::DebugLoc TrapLocation, + StringRef FuncName) { llvm::DISubprogram *TrapSP = createInlinedTrapSubprogram(FuncName, TrapLocation->getFile()); return llvm::DILocation::get(CGM.getLLVMContext(), /*Line=*/0, /*Column=*/0, /*Scope=*/TrapSP, /*InlinedAt=*/TrapLocation); - } +} llvm::DILocation *CGDebugInfo::CreateTrapFailureMessageFor( llvm::DebugLoc TrapLocation, StringRef Category, StringRef FailureMsg) { diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h index 0b06bdf78ac78..d01ad3b3d8df5 100644 --- a/clang/lib/CodeGen/CGDebugInfo.h +++ b/clang/lib/CodeGen/CGDebugInfo.h @@ -638,9 +638,11 @@ class CGDebugInfo { /// Create a debug location from `TrapLocation` that adds an artificial inline /// frame where the frame name is FuncName /// - /// This is used to indiciate instructions that come from compiler instrumentation. - llvm::DILocation *CreateSyntheticInline( - llvm::DebugLoc TrapLocation, StringRef FuncName); + /// This is used to indiciate instructions that come from compiler + /// instrumentation. + llvm::DILocation *CreateSyntheticInline(llvm::DebugLoc TrapLocation, + StringRef FuncName); + private: /// Emit call to llvm.dbg.declare for a variable declaration. /// Returns a pointer to the DILocalVariable associated with the diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index dc3b253237e51..d5cc2cc69c921 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -1219,10 +1219,9 @@ void CodeGenFunction::EmitBoundsCheckImpl(const Expr *E, llvm::Value *Bound, llvm::DILocation *TrapSP = Builder.getCurrentDebugLocation(); if (TrapSP) { TrapSP = getDebugInfo()->CreateSyntheticInline( - Builder.getCurrentDebugLocation(), - "check_array_bounds"); + Builder.getCurrentDebugLocation(), "__ubsan_check_array_bounds"); } - ApplyDebugLocation ApplyTrapDI(*this, TrapSP); + ApplyDebugLocation ApplyTrapDI(*this, TrapSP); bool IndexSigned = IndexType->isSignedIntegerOrEnumerationType(); llvm::Value *IndexVal = Builder.CreateIntCast(Index, SizeTy, IndexSigned); diff --git a/clang/test/CodeGen/bounds-checking-debuginfo.c b/clang/test/CodeGen/bounds-checking-debuginfo.c index e2a604bc962ba..58fcc89058d72 100644 --- a/clang/test/CodeGen/bounds-checking-debuginfo.c +++ b/clang/test/CodeGen/bounds-checking-debuginfo.c @@ -89,7 +89,7 @@ double f1(int b, int i) { // CHECK-TRAP: [[DBG22]] = !DILocation(line: 65, column: 3, scope: [[DBG5]]) // CHECK-TRAP: [[DBG23]] = !DILocation(line: 66, column: 12, scope: [[DBG5]]) // CHECK-TRAP: [[DBG24]] = !DILocation(line: 0, scope: [[META25:![0-9]+]], inlinedAt: [[DBG27]]) -// CHECK-TRAP: [[META25]] = distinct !DISubprogram(name: "check_array_bounds", scope: [[META6]], file: [[META6]], type: [[META26:![0-9]+]], flags: DIFlagArtificial, spFlags: DISPFlagDefinition, unit: [[META0]]) +// CHECK-TRAP: [[META25]] = distinct !DISubprogram(name: "__ubsan_check_array_bounds", scope: [[META6]], file: [[META6]], type: [[META26:![0-9]+]], flags: DIFlagArtificial, spFlags: DISPFlagDefinition, unit: [[META0]]) // CHECK-TRAP: [[META26]] = !DISubroutineType(types: null) // CHECK-TRAP: [[DBG27]] = !DILocation(line: 66, column: 10, scope: [[DBG5]]) // CHECK-TRAP: [[DBG28]] = !DILocation(line: 66, column: 3, scope: [[DBG5]]) @@ -116,7 +116,7 @@ double f1(int b, int i) { // CHECK-NOTRAP: [[DBG22]] = !DILocation(line: 65, column: 3, scope: [[DBG5]]) // CHECK-NOTRAP: [[DBG23]] = !DILocation(line: 66, column: 12, scope: [[DBG5]]) // CHECK-NOTRAP: [[DBG24]] = !DILocation(line: 0, scope: [[META25:![0-9]+]], inlinedAt: [[DBG27]]) -// CHECK-NOTRAP: [[META25]] = distinct !DISubprogram(name: "check_array_bounds", scope: [[META6]], file: [[META6]], type: [[META26:![0-9]+]], flags: DIFlagArtificial, spFlags: DISPFlagDefinition, unit: [[META0]]) +// CHECK-NOTRAP: [[META25]] = distinct !DISubprogram(name: "__ubsan_check_array_bounds", scope: [[META6]], file: [[META6]], type: [[META26:![0-9]+]], flags: DIFlagArtificial, spFlags: DISPFlagDefinition, unit: [[META0]]) // CHECK-NOTRAP: [[META26]] = !DISubroutineType(types: null) // CHECK-NOTRAP: [[DBG27]] = !DILocation(line: 66, column: 10, scope: [[DBG5]]) // CHECK-NOTRAP: [[PROF28]] = !{!"branch_weights", i32 1048575, i32 1} _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits