Skip to content

Commit

Permalink
Address comments from ellishg
Browse files Browse the repository at this point in the history
  • Loading branch information
kyulee-com committed Sep 13, 2024
1 parent dc90e82 commit 3ec4dbc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
4 changes: 2 additions & 2 deletions lld/MachO/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1349,10 +1349,10 @@ static void codegenDataGenerate() {
assert(!fileName.empty());
raw_fd_ostream Output(fileName, EC, sys::fs::OF_None);
if (EC)
error("fail to create raw_fd_ostream");
error("fail to create " + fileName + ": " + EC.message());

if (auto E = Writer.write(Output))
error("fail to write CGData");
error("fail to write CGData: " + toString(std::move(E)));
}

static void foldIdenticalLiterals() {
Expand Down
6 changes: 4 additions & 2 deletions lld/MachO/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,10 @@ def no_objc_category_merging : Flag<["-"], "no_objc_category_merging">,
Group<grp_lld>;
def lto_debug_pass_manager: Flag<["--"], "lto-debug-pass-manager">,
HelpText<"Debug new pass manager">, Group<grp_lld>;
def codegen_data_generate_path : Joined<["--"], "codegen-data-generate-path=">,
HelpText<"Codegen data file path">, Group<grp_lld>;
def codegen_data_generate_path : Separate<["--"], "codegen-data-generate-path">, Group<grp_lld>;
def codegen_data_generate_path_eq : Joined<["--"], "codegen-data-generate-path=">,
Alias<!cast<Separate>(codegen_data_generate_path)>, MetaVarName<"<cgdata>">,
HelpText<"Write the CG data to the specified path <cgdata>.">, Group<grp_lld>;
def cs_profile_generate: Flag<["--"], "cs-profile-generate">,
HelpText<"Perform context sensitive PGO instrumentation">, Group<grp_lld>;
def cs_profile_path: Joined<["--"], "cs-profile-path=">,
Expand Down
17 changes: 6 additions & 11 deletions lld/test/MachO/cgdata-generate.s
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
# Synthesize raw cgdata without the header (24 byte) from the indexed cgdata.
# RUN: llvm-cgdata --convert --format binary %t/raw-1.cgtext -o %t/raw-1.cgdata
# RUN: od -t x1 -j 24 -An %t/raw-1.cgdata | tr -d '\n\r\t' | sed 's/ \+/ /g; s/^ *//; s/ *$//; s/ /,0x/g; s/^/0x/' > %t/raw-1-bytes.txt
# RUN: sed "s/<RAW_1_BYTES>/$(cat %t/raw-1-bytes.txt)/g" %t/merge-1-template.s > %t/merge-1.s
# RUN: sed "s/<RAW_BYTES>/$(cat %t/raw-1-bytes.txt)/g" %t/merge-template.s > %t/merge-1.s
# RUN: llvm-cgdata --convert --format binary %t/raw-2.cgtext -o %t/raw-2.cgdata
# RUN: od -t x1 -j 24 -An %t/raw-2.cgdata | tr -d '\n\r\t' | sed 's/ \+/ /g; s/^ *//; s/ *$//; s/ /,0x/g; s/^/0x/' > %t/raw-2-bytes.txt
# RUN: sed "s/<RAW_2_BYTES>/$(cat %t/raw-2-bytes.txt)/g" %t/merge-2-template.s > %t/merge-2.s
# RUN: sed "s/<RAW_BYTES>/$(cat %t/raw-2-bytes.txt)/g" %t/merge-template.s > %t/merge-2.s

# RUN: llvm-mc -filetype obj -triple arm64-apple-darwin %t/merge-1.s -o %t/merge-1.o
# RUN: llvm-mc -filetype obj -triple arm64-apple-darwin %t/merge-2.s -o %t/merge-2.o
Expand All @@ -28,7 +28,7 @@

# We can also generate the merged codegen data from the executable that is not dead-stripped.
# RUN: llvm-objdump -h %t/out| FileCheck %s
CHECK: __llvm_outline
# CHECK: __llvm_outline
# RUN: llvm-cgdata --merge %t/out -o %t/merge-cgdata-exe
# RUN: diff %t/merge-cgdata-exe %t/merge-cgdata

Expand All @@ -42,7 +42,7 @@ CHECK: __llvm_outline

# Ensure no __llvm_outline section remains in the executable.
# RUN: llvm-objdump -h %t/out-strip | FileCheck %s --check-prefix=STRIP
STRIP-NOT: __llvm_outline
# STRIP-NOT: __llvm_outline

#--- raw-1.cgtext
:outlined_hash_tree
Expand All @@ -60,11 +60,6 @@ STRIP-NOT: __llvm_outline
SuccessorIds: [ ]
...

#--- merge-1-template.s
.section __DATA,__llvm_outline
_data:
.byte <RAW_1_BYTES>

#--- raw-2.cgtext
:outlined_hash_tree
0:
Expand All @@ -81,10 +76,10 @@ _data:
SuccessorIds: [ ]
...

#--- merge-2-template.s
#--- merge-template.s
.section __DATA,__llvm_outline
_data:
.byte <RAW_2_BYTES>
.byte <RAW_BYTES>

#--- main.s
.globl _main
Expand Down

0 comments on commit 3ec4dbc

Please sign in to comment.