-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[Dwarf][Transforms] Add dwarf support when func signature changed #127855
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
Open
yonghong-song
wants to merge
1
commit into
llvm:main
Choose a base branch
from
yonghong-song:sig-change-stage-1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
; RUN: opt -S -passes=argpromotion < %s | FileCheck %s | ||
; | ||
; Source code: | ||
; __attribute__((noinline)) static int is_absolute_path(const char *path) | ||
; { | ||
; return path[0] == '/'; | ||
; } | ||
; | ||
; void quit(char *buf); | ||
; const char *make_nonrelative_path(char *buf, const char *path) | ||
; { | ||
; if (is_absolute_path(path)) | ||
; quit(buf); | ||
; return buf; | ||
; } | ||
|
||
define dso_local ptr @make_nonrelative_path(ptr noundef %buf, ptr noundef %path) local_unnamed_addr #0 !dbg !10 { | ||
#dbg_value(ptr %buf, !18, !DIExpression(), !20) | ||
#dbg_value(ptr %path, !19, !DIExpression(), !20) | ||
%x = call fastcc i32 @is_absolute_path(ptr noundef %path), !dbg !21 | ||
%y = icmp eq i32 %x, 0, !dbg !21 | ||
br i1 %y, label %to_ret, label %to_quit, !dbg !21 | ||
|
||
to_quit: | ||
call void @quit(ptr noundef %buf), !dbg !23 | ||
br label %to_ret, !dbg !23 | ||
|
||
to_ret: | ||
ret ptr %buf, !dbg !24 | ||
} | ||
|
||
; Function Attrs: noinline nounwind uwtable | ||
define internal fastcc range(i32 0, 2) i32 @is_absolute_path(ptr noundef %path) unnamed_addr #1 !dbg !25 { | ||
#dbg_value(ptr %path, !30, !DIExpression(), !31) | ||
%x = load i8, ptr %path, align 1, !dbg !32, !tbaa !33 | ||
%y = icmp eq i8 %x, 47, !dbg !36 | ||
%z = zext i1 %y to i32, !dbg !36 | ||
ret i32 %z, !dbg !37 | ||
} | ||
|
||
; CHECK: define internal fastcc range(i32 0, 2) i32 @is_absolute_path(i8 {{.*}}) | ||
|
||
declare !dbg !38 void @quit(ptr noundef) local_unnamed_addr | ||
|
||
attributes #0 = { nounwind } | ||
attributes #1 = { noinline nounwind } | ||
|
||
!llvm.dbg.cu = !{!0} | ||
!llvm.module.flags = !{!2, !3, !4, !5, !6, !7, !8} | ||
!llvm.ident = !{!9} | ||
|
||
!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 21.0.0git ([email protected]:yonghong-song/llvm-project.git 25cfee009e78194d1f7ca70779d63ef1936cc7b9)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None) | ||
!1 = !DIFile(filename: "test.c", directory: "/tmp/tests/sig-change/prom", checksumkind: CSK_MD5, checksum: "bcc8cf18726713f5d2ab6d82e8ff459d") | ||
!2 = !{i32 7, !"Dwarf Version", i32 5} | ||
!3 = !{i32 2, !"Debug Info Version", i32 3} | ||
!4 = !{i32 1, !"wchar_size", i32 4} | ||
!5 = !{i32 8, !"PIC Level", i32 2} | ||
!6 = !{i32 7, !"PIE Level", i32 2} | ||
!7 = !{i32 7, !"uwtable", i32 2} | ||
!8 = !{i32 7, !"debug-info-assignment-tracking", i1 true} | ||
!9 = !{!"clang version 21.0.0git ([email protected]:yonghong-song/llvm-project.git 25cfee009e78194d1f7ca70779d63ef1936cc7b9)"} | ||
!10 = distinct !DISubprogram(name: "make_nonrelative_path", scope: !1, file: !1, line: 7, type: !11, scopeLine: 8, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !17) | ||
!11 = !DISubroutineType(types: !12) | ||
!12 = !{!13, !16, !13} | ||
!13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 64) | ||
!14 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !15) | ||
!15 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) | ||
!16 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !15, size: 64) | ||
!17 = !{!18, !19} | ||
!18 = !DILocalVariable(name: "buf", arg: 1, scope: !10, file: !1, line: 7, type: !16) | ||
!19 = !DILocalVariable(name: "path", arg: 2, scope: !10, file: !1, line: 7, type: !13) | ||
!20 = !DILocation(line: 0, scope: !10) | ||
!21 = !DILocation(line: 9, column: 7, scope: !22) | ||
!22 = distinct !DILexicalBlock(scope: !10, file: !1, line: 9, column: 7) | ||
!23 = !DILocation(line: 10, column: 5, scope: !22) | ||
!24 = !DILocation(line: 11, column: 3, scope: !10) | ||
!25 = distinct !DISubprogram(name: "is_absolute_path", scope: !1, file: !1, line: 1, type: !26, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !29) | ||
|
||
; CHECK: distinct !DISubprogram(name: "is_absolute_path", scope: ![[#]], file: ![[#]], line: [[#]], type: ![[#]], scopeLine: [[#]], flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized | DISPFlagArgChanged, unit: ![[#]], retainedNodes: ![[#]]) | ||
|
||
!26 = !DISubroutineType(types: !27) | ||
!27 = !{!28, !13} | ||
!28 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) | ||
!29 = !{!30} | ||
!30 = !DILocalVariable(name: "path", arg: 1, scope: !25, file: !1, line: 1, type: !13) | ||
!31 = !DILocation(line: 0, scope: !25) | ||
!32 = !DILocation(line: 3, column: 10, scope: !25) | ||
!33 = !{!34, !34, i64 0} | ||
!34 = !{!"omnipotent char", !35, i64 0} | ||
!35 = !{!"Simple C/C++ TBAA"} | ||
!36 = !DILocation(line: 3, column: 18, scope: !25) | ||
!37 = !DILocation(line: 3, column: 3, scope: !25) | ||
!38 = !DISubprogram(name: "quit", scope: !1, file: !1, line: 6, type: !39, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized) | ||
!39 = !DISubroutineType(types: !40) | ||
!40 = !{null, !16} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
; RUN: opt -S -passes=deadargelim < %s | FileCheck %s | ||
; | ||
; Source code: | ||
; int tar(int a); | ||
; __attribute__((noinline)) static int foo(int a, int b) | ||
; { | ||
; return tar(a) + tar(a + 1); | ||
; } | ||
; int bar(int a) | ||
; { | ||
; foo(a, 1); | ||
; return 0; | ||
; } | ||
|
||
define dso_local noundef i32 @bar(i32 noundef %a) local_unnamed_addr #0 !dbg !10 { | ||
#dbg_value(i32 %a, !15, !DIExpression(), !16) | ||
%2 = tail call fastcc i32 @foo(i32 noundef %a, i32 noundef 1), !dbg !17 | ||
ret i32 0, !dbg !18 | ||
} | ||
|
||
define internal fastcc i32 @foo(i32 noundef %a, i32 noundef %b) unnamed_addr #1 !dbg !19 { | ||
#dbg_value(i32 %a, !23, !DIExpression(), !25) | ||
#dbg_value(i32 %b, !24, !DIExpression(), !25) | ||
%x = tail call i32 @tar(i32 noundef %a), !dbg !26 | ||
%t = add nsw i32 %a, 1, !dbg !27 | ||
%y = tail call i32 @tar(i32 noundef %t), !dbg !28 | ||
%z = add nsw i32 %y, %x, !dbg !29 | ||
ret i32 %z, !dbg !30 | ||
} | ||
|
||
; CHECK: define internal fastcc void @foo(i32 noundef %a) | ||
|
||
declare !dbg !31 i32 @tar(i32 noundef) local_unnamed_addr | ||
|
||
attributes #0 = { nounwind } | ||
attributes #1 = { noinline nounwind } | ||
|
||
!llvm.dbg.cu = !{!0} | ||
!llvm.module.flags = !{!2, !3, !4, !5, !6, !7, !8} | ||
!llvm.ident = !{!9} | ||
|
||
!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 21.0.0git ([email protected]:yonghong-song/llvm-project.git 25cfee009e78194d1f7ca70779d63ef1936cc7b9)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None) | ||
!1 = !DIFile(filename: "test.c", directory: "/tmp/tests/sig-change/deadret", checksumkind: CSK_MD5, checksum: "728d225e6425c104712ae21cee1db99b") | ||
!2 = !{i32 7, !"Dwarf Version", i32 5} | ||
!3 = !{i32 2, !"Debug Info Version", i32 3} | ||
!4 = !{i32 1, !"wchar_size", i32 4} | ||
!5 = !{i32 8, !"PIC Level", i32 2} | ||
!6 = !{i32 7, !"PIE Level", i32 2} | ||
!7 = !{i32 7, !"uwtable", i32 2} | ||
!8 = !{i32 7, !"debug-info-assignment-tracking", i1 true} | ||
!9 = !{!"clang version 21.0.0git ([email protected]:yonghong-song/llvm-project.git 25cfee009e78194d1f7ca70779d63ef1936cc7b9)"} | ||
!10 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 6, type: !11, scopeLine: 7, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !14) | ||
!11 = !DISubroutineType(types: !12) | ||
!12 = !{!13, !13} | ||
!13 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) | ||
!14 = !{!15} | ||
!15 = !DILocalVariable(name: "a", arg: 1, scope: !10, file: !1, line: 6, type: !13) | ||
!16 = !DILocation(line: 0, scope: !10) | ||
!17 = !DILocation(line: 8, column: 3, scope: !10) | ||
!18 = !DILocation(line: 9, column: 3, scope: !10) | ||
!19 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 2, type: !20, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !22) | ||
|
||
; CHECK: distinct !DISubprogram(name: "foo", scope: ![[#]], file: ![[#]], line: [[#]], type: ![[#]], scopeLine: [[#]], flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized | DISPFlagArgChanged | DISPFlagRetvalRemoved, unit: !0, retainedNodes: ![[#]]) | ||
|
||
!20 = !DISubroutineType(types: !21) | ||
!21 = !{!13, !13, !13} | ||
!22 = !{!23, !24} | ||
!23 = !DILocalVariable(name: "a", arg: 1, scope: !19, file: !1, line: 2, type: !13) | ||
!24 = !DILocalVariable(name: "b", arg: 2, scope: !19, file: !1, line: 2, type: !13) | ||
!25 = !DILocation(line: 0, scope: !19) | ||
!26 = !DILocation(line: 4, column: 10, scope: !19) | ||
!27 = !DILocation(line: 4, column: 25, scope: !19) | ||
!28 = !DILocation(line: 4, column: 19, scope: !19) | ||
!29 = !DILocation(line: 4, column: 17, scope: !19) | ||
!30 = !DILocation(line: 4, column: 3, scope: !19) | ||
!31 = !DISubprogram(name: "tar", scope: !1, file: !1, line: 1, type: !11, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// TODO: Add specifics about what changed.
This will clarify that you expect to add more info later, and that's why it's a tag not an attribute. (Which was my first question when reading the code. It took a more careful reading of the commit message to understand the longer-term goal.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are correct. The tag intends for future extensibility.