-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[DirectX] Add split-section
to llvm-objcopy
and implement it for DXContainer
#153265
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
inbelic
wants to merge
9
commits into
llvm:users/inbelic/pr-153246
Choose a base branch
from
inbelic:inbelic/dx-objcopy-split
base: users/inbelic/pr-153246
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.
+459
−9
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
12fe63d
add an unimplemented common option `split-section` to `objcopy`
inbelic 6933175
add support for `split-section` for `dxcontainer`
inbelic 8bc9785
add basic test cases
inbelic 1714a6f
remove the split sections from orig dxcontainer
inbelic 5a6c11c
self-review: removed unused param
inbelic e27256f
review: fix up comments and filecheck
inbelic d34866c
review: rename test files
inbelic 1a6f132
review: improve check
inbelic 38ba2f6
review: add failure testcase
inbelic 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,8 +42,6 @@ struct Object { | |
} | ||
|
||
Error removeParts(PartPred ToRemove); | ||
|
||
private: | ||
void recomputeHeader(); | ||
}; | ||
|
||
|
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,21 @@ | ||
## Check that llvm-objcopy reports a suitable error when it | ||
## can't find the section to split | ||
|
||
## We can't have multiple DXIL parts. | ||
# RUN: yaml2obj %s --docnum=1 -o %t1 | ||
# RUN: not llvm-objcopy %t1 --split-section=UNKNOWN=%t.unknown.out 2>&1 | FileCheck %s -DFILE=%t1 --check-prefix=ERROR1 | ||
|
||
# ERROR1: error: '[[FILE]]': part 'UNKNOWN' not found | ||
|
||
--- !dxcontainer | ||
Header: | ||
Hash: [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, | ||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ] | ||
Version: | ||
Major: 1 | ||
Minor: 0 | ||
PartCount: 1 | ||
Parts: | ||
- Name: FKE0 | ||
Size: 8 | ||
... |
58 changes: 58 additions & 0 deletions
58
llvm/test/tools/llvm-objcopy/DXContainer/split-headers.test
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,58 @@ | ||
## Tests that a separate DXContainer is created with only the specified section | ||
## for each --split-section specified. Also ensure that the part is removed | ||
## from the original object. | ||
|
||
# RUN: yaml2obj %s -o %t | ||
# RUN: llvm-objcopy %t --split-section=FKE1=%t.fke1.out --split-section=FKE4=%t.fke4.out | ||
# RUN: obj2yaml %t | FileCheck %s --check-prefix=ORIG | ||
# RUN: obj2yaml %t.fke1.out | FileCheck %s --check-prefixes=CHECK,FKE1 | ||
# RUN: obj2yaml %t.fke4.out | FileCheck %s --check-prefixes=CHECK,FKE4 | ||
|
||
--- !dxcontainer | ||
Header: | ||
Hash: [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, | ||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ] | ||
Version: | ||
Major: 1 | ||
Minor: 0 | ||
# ORIG: FileSize: 276 | ||
# FKE1: FileSize: 52 | ||
# FKE4: FileSize: 1732 | ||
FileSize: 1996 | ||
# CHECK: PartCount: 1 | ||
# CHECK: PartOffsets: [ 36 ] | ||
PartCount: 7 | ||
PartOffsets: [ 60, 76, 92, 108, 236, 1932, 1960 ] | ||
Parts: | ||
# FKE1: Name: FKE1 | ||
# FKE4: Name: FKE4 | ||
# ORIG-NOT: FKE1 | ||
# ORIG-NOT: FKE4 | ||
# CHECK-NOT: FKE0 | ||
# CHECK-NOT: FKE2 | ||
# CHECK-NOT: FKE3 | ||
# CHECK-NOT: FKE5 | ||
- Name: FKE0 | ||
Size: 8 | ||
- Name: FKE1 | ||
Size: 8 | ||
- Name: FKE2 | ||
Size: 8 | ||
- Name: FKE3 | ||
Size: 120 | ||
- Name: FKE4 | ||
Size: 1688 | ||
- Name: FKE5 | ||
Size: 20 | ||
- Name: DXIL | ||
Size: 28 | ||
Program: | ||
MajorVersion: 6 | ||
MinorVersion: 5 | ||
ShaderKind: 5 | ||
Size: 8 | ||
DXILMajorVersion: 1 | ||
DXILMinorVersion: 5 | ||
DXILSize: 4 | ||
DXIL: [ 0x42, 0x43, 0xC0, 0xDE, ] | ||
... |
Oops, something went wrong.
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.
Perhaps there is a better way to do this check? Would appreciate suggestions.
I tried to instantiate a
NameMatcher
here but it is a bit awkward. I also considered adding the section names directly toToRemove
inObjcopyOptions.cpp
but I thought that would be rather confusing.