Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement -frecord-command-line (-frecord-gcc-switches)
Implement options in clang to enable recording the driver command-line in an ELF section. Implement a new special named metadata, llvm.commandline, to support frontends embedding their command-line options in IR/ASM/ELF. This differs from the GCC implementation in some key ways: * In GCC there is only one command-line possible per compilation-unit, in LLVM it mirrors llvm.ident and multiple are allowed. * In GCC individual options are separated by NULL bytes, in LLVM entire command-lines are separated by NULL bytes. The advantage of the GCC approach is to clearly delineate options in the face of embedded spaces. The advantage of the LLVM approach is to support merging multiple command-lines unambiguously, while handling embedded spaces with escaping. Differential Revision: https://reviews.llvm.org/D54487 Clang Differential Revision: https://reviews.llvm.org/D54489 llvm-svn: 349155
- Loading branch information
1 parent
eed7b2e
commit de6beb0
Showing
24 changed files
with
222 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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,13 @@ | ||
; RUN: llc -mtriple=x86_64-linux < %s | FileCheck %s | ||
; Verify that llvm.commandline metadata is emitted to a section named | ||
; .GCC.command.line with each line separated with null bytes. | ||
|
||
; CHECK: .section .GCC.command.line,"MS",@progbits,1 | ||
; CHECK-NEXT: .zero 1 | ||
; CHECK-NEXT: .ascii "clang -command -line" | ||
; CHECK-NEXT: .zero 1 | ||
; CHECK-NEXT: .ascii "something else" | ||
; CHECK-NEXT: .zero 1 | ||
!llvm.commandline = !{!0, !1} | ||
!0 = !{!"clang -command -line"} | ||
!1 = !{!"something else"} |
This file contains 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,3 @@ | ||
!llvm.commandline = !{!0, !1} | ||
!0 = !{!"compiler -v1"} | ||
!1 = !{!"compiler -v2"} |
This file contains 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,2 @@ | ||
!llvm.commandline = !{!0} | ||
!0 = !{!"compiler -v3"} |
This file contains 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,8 @@ | ||
; RUN: llvm-link %S/Inputs/commandline.a.ll %S/Inputs/commandline.b.ll -S | FileCheck %s | ||
|
||
; Verify that multiple input llvm.commandline metadata are linked together. | ||
|
||
; CHECK-DAG: !llvm.commandline = !{!0, !1, !2} | ||
; CHECK-DAG: !{{[0-2]}} = !{!"compiler -v1"} | ||
; CHECK-DAG: !{{[0-2]}} = !{!"compiler -v2"} | ||
; CHECK-DAG: !{{[0-2]}} = !{!"compiler -v3"} |
This file contains 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,10 @@ | ||
; RUN: not llvm-as < %s -o /dev/null 2>&1 | FileCheck %s | ||
; Verify that llvm.commandline is properly structured. | ||
; llvm.commandline takes a list of metadata entries. | ||
; Each metadata entry can have only one string. | ||
|
||
!llvm.commandline = !{!0} | ||
!0 = !{!"string1", !"string2"} | ||
; CHECK: assembly parsed, but does not verify as correct! | ||
; CHECK-NEXT: incorrect number of operands in llvm.commandline metadata | ||
; CHECK-NEXT: !0 |
This file contains 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,10 @@ | ||
; RUN: not llvm-as < %s -o /dev/null 2>&1 | FileCheck %s | ||
; Verify that llvm.commandline is properly structured. | ||
; llvm.commandline takes a list of metadata entries. | ||
; Each metadata entry can contain one string only. | ||
|
||
!llvm.commandline = !{!0} | ||
!0 = !{i32 1} | ||
; CHECK: assembly parsed, but does not verify as correct! | ||
; CHECK-NEXT: invalid value for llvm.commandline metadata entry operand(the operand should be a string) | ||
; CHECK-NEXT: i32 1 |
This file contains 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,10 @@ | ||
; RUN: not llvm-as < %s -o /dev/null 2>&1 | FileCheck %s | ||
; Verify that llvm.commandline is properly structured. | ||
; llvm.commandline takes a list of metadata entries. | ||
; Each metadata entry can contain one string only. | ||
|
||
!llvm.commandline = !{!0} | ||
!0 = !{!{!"nested metadata"}} | ||
; CHECK: assembly parsed, but does not verify as correct! | ||
; CHECK-NEXT: invalid value for llvm.commandline metadata entry operand(the operand should be a string) | ||
; CHECK-NEXT: !1 |
Oops, something went wrong.