-
Notifications
You must be signed in to change notification settings - Fork 14.8k
[DirectX] Add support for remove-section
of DXContainer
for llvm-objcopy
#153246
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
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
bfea6fe
[DirectX] Add suport to remove specified sections (parts)
inbelic eaef153
Add `ToRemove` to implemented options
inbelic 21339f5
add basic test cases
inbelic 07d1d6a
review: apply suggestions from the boilerplate pr here
inbelic 57d3960
review: fix up test comments
inbelic 3626210
review: rename files
inbelic 948885f
review: move recomputeHeader to common point
inbelic 8b36450
review: make tests stricter
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//===- DXContainerObject.cpp ----------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "DXContainerObject.h" | ||
|
||
namespace llvm { | ||
namespace objcopy { | ||
namespace dxbc { | ||
|
||
Error Object::removeParts(PartPred ToRemove) { | ||
erase_if(Parts, ToRemove); | ||
return Error::success(); | ||
} | ||
|
||
void Object::recomputeHeader() { | ||
Header.FileSize = headerSize(); | ||
Header.PartCount = Parts.size(); | ||
for (const Part &P : Parts) | ||
Header.FileSize += P.size(); | ||
} | ||
|
||
} // end namespace dxbc | ||
} // end namespace objcopy | ||
} // end namespace llvm |
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
51 changes: 51 additions & 0 deletions
51
llvm/test/tools/llvm-objcopy/DXContainer/remove-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,51 @@ | ||
## Tests that the copied DXContainer correctly has the specified headers | ||
## removed. | ||
|
||
# RUN: yaml2obj %s -o %t | ||
# RUN: llvm-objcopy --remove-section=FKE1 --remove-section=FKE4 %t %t.out | ||
# RUN: obj2yaml %t.out | FileCheck %s | ||
|
||
--- !dxcontainer | ||
Header: | ||
Hash: [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, | ||
0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ] | ||
Version: | ||
Major: 1 | ||
Minor: 0 | ||
## FileSize = 1996 - 8 (FKE1 content) - 1688 (FKE4 content) | ||
## - 8 (2 part offsets) - 16 (2 part headers) | ||
## = 276 | ||
# CHECK: FileSize: 276 | ||
FileSize: 1996 | ||
# CHECK-NEXT: PartCount: 5 | ||
PartCount: 7 | ||
# CHECK-NEXT: PartOffsets: [ 52, 68, 84, 212, 240 ] | ||
PartOffsets: [ 60, 76, 92, 108, 236, 1932, 1960 ] | ||
Parts: | ||
# CHECK-NEXT: Parts | ||
# CHECK-NOT: FKE1 | ||
# CHECK-NOT: FKE4 | ||
- 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.
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.
Uh oh!
There was an error while loading. Please reload this page.