Skip to content

[BoundsSafety] Cherrypick opt remark fix #9877

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 24, 2025
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// XFAIL: *


// RUN: %clang_cc1 -triple x86_64-apple-macos -Wno-bounds-safety-init-list -fbounds-safety -O0 %s -emit-llvm -o %t-O0.s -opt-record-file %t-O0.opt.yaml -opt-record-format yaml
// RUN: FileCheck --input-file %t-O0.s --check-prefixes IR %s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,28 +102,6 @@ int main(int argc, char **argv) {
// OPT-REM-NEXT: - type: bounds-safety-total-summary
// OPT-REM-NEXT: ...

// OPT-REM-NEXT: --- !Analysis
// // OPT-REM-NEXT: Pass: annotation-remarks
// // OPT-REM-NEXT: Name: BoundsSafetyCheck
// // OPT-REM-NEXT: DebugLoc: { File: '{{.*}}bounds-safety-ptr-conversion-O2.c',
// // OPT-REM-NEXT: Line: 0, Column: 0 }
// // OPT-REM-NEXT: Function: main
// // OPT-REM-NEXT: Args:
// // OPT-REM-NEXT: - String: 'Inserted '
// // OPT-REM-NEXT: - count: '2'
// // OPT-REM-NEXT: - String: ' LLVM IR instruction'
// // OPT-REM-NEXT: - String: s
// // OPT-REM-NEXT: - String: "\n"
// // OPT-REM-NEXT: - String: "used for:\n"
// // OPT-REM-NEXT: - String: bounds-safety-generic, bounds-safety-check-ptr-lt-upper-bound, bounds-safety-check-ptr-ge-lower-bound
// // OPT-REM-NEXT: - String: |
// // OPT-REM-NEXT: {{^[ ]+$}}
// // OPT-REM-NEXT: {{^[ ]+$}}
// // OPT-REM-NEXT: instructions:
// // OPT-REM-EMPTY:
// // OPT-REM-NEXT: - String: "trap (LLVM IR 'call')\nother (LLVM IR 'unreachable')"
// // OPT-REM-NEXT: ...
//
// OPT-REM-NEXT: --- !Analysis
// OPT-REM-NEXT: Pass: annotation-remarks
// OPT-REM-NEXT: Name: BoundsSafetyCheck
Expand All @@ -146,4 +124,26 @@ int main(int argc, char **argv) {
// OPT-REM-NEXT: - String: "cmp eq (LLVM IR 'icmp')\ncond branch (LLVM IR 'br')"
// OPT-REM-NEXT: ...

// OPT-REM-NEXT: --- !Analysis
// OPT-REM-NEXT: Pass: annotation-remarks
// OPT-REM-NEXT: Name: BoundsSafetyCheck
// OPT-REM-NEXT: DebugLoc: { File: '{{.*}}bounds-safety-ptr-conversion-O2.c',
// OPT-REM-NEXT: Line: 0, Column: 0 }
// OPT-REM-NEXT: Function: main
// OPT-REM-NEXT: Args:
// OPT-REM-NEXT: - String: 'Inserted '
// OPT-REM-NEXT: - count: '2'
// OPT-REM-NEXT: - String: ' LLVM IR instruction'
// OPT-REM-NEXT: - String: s
// OPT-REM-NEXT: - String: "\n"
// OPT-REM-NEXT: - String: "used for:\n"
// OPT-REM-NEXT: - String: bounds-safety-generic, bounds-safety-check-ptr-lt-upper-bound, bounds-safety-check-ptr-ge-lower-bound
// OPT-REM-NEXT: - String: |
// OPT-REM-NEXT: {{^[ ]+$}}
// OPT-REM-NEXT: {{^[ ]+$}}
// OPT-REM-NEXT: instructions:
// OPT-REM-EMPTY:
// OPT-REM-NEXT: - String: "trap (LLVM IR 'call')\nother (LLVM IR 'unreachable')"
// OPT-REM-NEXT: ...

// OPT-REM-NOT: --- !Analysis
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// XFAIL: *


// RUN: %clang_cc1 -fbounds-safety -O0 %s -emit-llvm -o %t-O0.s -opt-record-file %t-O0.opt.yaml -opt-record-format yaml
// RUN: FileCheck --input-file %t-O0.s --check-prefixes IR %s
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// XFAIL: *


// RUN: %clang_cc1 -fbounds-safety -O0 %s -emit-llvm -o %t-O0.s -opt-record-file %t-O0.opt.yaml -opt-record-format yaml
// RUN: FileCheck --input-file %t-O0.s --check-prefixes IR %s
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// XFAIL: *


// RUN: %clang_cc1 -triple x86_64-apple-macos -fbounds-safety -O0 %s -emit-llvm -o %t-O0.s -opt-record-file %t-O0.opt.yaml -opt-record-format yaml
// RUN: FileCheck --input-file %t-O0.s --check-prefixes IR %s
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// XFAIL: *


// RUN: %clang_cc1 -triple x86_64-apple-macos -fbounds-safety -O0 %s -emit-llvm -o %t-O0.s -opt-record-file %t-O0.opt.yaml -opt-record-format yaml
// RUN: FileCheck --input-file %t-O0.s --check-prefixes IR %s
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Scalar/AnnotationRemarks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ static void runImpl(Function &F, const TargetLibraryInfo &TLI) {
return;

// Track all annotated instructions aggregated based on their debug location.
DenseMap<MDNode *, SmallVector<Instruction *, 4>> DebugLoc2Annotated;
MapVector<MDNode *, SmallVector<Instruction *, 4>> DebugLoc2Annotated;

OptimizationRemarkEmitter ORE(&F);
// First, generate a summary of the annotated instructions.
Expand Down
8 changes: 4 additions & 4 deletions llvm/test/Transforms/Util/auto-init-annotation-remarks.ll
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memo
!llvm.module.flags = !{!4}

!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
!1 = !DIFile(filename: "/Users/zainjaffal/Repos/internal/llvm-project2/llvm/test/Transforms/Util/bounds-safety-annotation-remarks.ll", directory: "/")
!1 = !DIFile(filename: "/llvm-project/llvm/test/Transforms/Util/bounds-safety-annotation-remarks.ll", directory: "/")
!2 = !{i32 4}
!3 = !{i32 1}
!4 = !{i32 2, !"Debug Info Version", i32 3}
Expand Down Expand Up @@ -54,7 +54,7 @@ attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memo
; CHECK-NEXT: Pass: annotation-remarks
; CHECK-NEXT: Name: AutoInitStore
; CHECK-NEXT: DebugLoc: { File:
; CHECK-NEXT: Line: 3, Column: 1 }
; CHECK-NEXT: Line: 2, Column: 1 }
; CHECK-NEXT: Function: test1
; CHECK-NEXT: Args:
; CHECK-NEXT: - String: Store inserted by -ftrivial-auto-var-init.
Expand All @@ -78,7 +78,7 @@ attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memo
; CHECK-NEXT: Pass: annotation-remarks
; CHECK-NEXT: Name: AutoInitStore
; CHECK-NEXT: DebugLoc: { File:
; CHECK-NEXT: Line: 2, Column: 1 }
; CHECK-NEXT: Line: 3, Column: 1 }
; CHECK-NEXT: Function: test1
; CHECK-NEXT: Args:
; CHECK-NEXT: - String: Store inserted by -ftrivial-auto-var-init.
Expand All @@ -97,4 +97,4 @@ attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memo
; CHECK-NEXT: - String: ' Atomic: '
; CHECK-NEXT: - StoreAtomic: 'false'
; CHECK-NEXT: - String: .
; CHECK-NEXT: ...
; CHECK-NEXT: ...