This diff adds functionality to the llvm-bitcode-strip tool for
stripping of LLVM bitcode sections.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Please split this patch in two, one patch for each option. I'll then review the two independently.
llvm/test/tools/llvm-objcopy/MachO/bitcode-strip-basic.test | ||
---|---|---|
1–2 | This comment doesn't line up with what the test is doing. |
llvm/test/tools/llvm-objcopy/MachO/bitcode-strip-basic.test | ||
---|---|---|
1–2 | Whoops, should have removed |
llvm/test/tools/llvm-objcopy/MachO/bitcode-strip-basic.test | ||
---|---|---|
4–7 | Usually, we'd have one test file per option, i.e. in one test, you'd test -o, and another test, you'd test what the -r operation does. | |
12 | I don't think you need to dump the entire section data. Sufficient should be to check the Name: and possibly Segment: fields (and then only the actual names, not the raw values you're currently checking too). Example: # RUN: ... | FileCheck %s --implicit-check-not=Name # CHECK: Name: __text # CHECK-NEXT: Segment: __TEXT # CHECK: Name: __data # CHECK-NEXT: Segment: __DATA | |
llvm/tools/llvm-objcopy/BitcodeStripOpts.td | ||
27 | Please normalise the help text to be consistent with ending with a period or not. I prefer not for help text. | |
llvm/tools/llvm-objcopy/ObjcopyOptions.cpp | ||
1219–1222 | No braces for single-line if statements. I take it in the future, other options will provide different actions, and you just have to request one (or more) actions from the available set? | |
1224–1228 | Period at end of sentences. Also, no braces for single-line if statements. I think you need additional sections in your test case with a section in the __LLVM segment with a different name, and a __bundle section in a non-LLVM segment, to show that it's only the combination of the two that is removed. It may also be a good idea to show what happens (in a test case) when the error callback is triggered in this code path. |
llvm/tools/llvm-objcopy/ObjcopyOptions.cpp | ||
---|---|---|
1219–1222 | Yes, there are 2 other output options that I have not yet added: -m Remove the bitcode from the __LLVM segment, leaving behind a marker. -l Remove all of the native executable code, leaving the LLVM bitcode behind. In this case, bitcode_strip will take care to preserve the (__TEXT,__info_plist) section while removing the rest of the __TEXT segment. |
llvm/test/tools/llvm-objcopy/MachO/bitcode-strip-basic.test | ||
---|---|---|
4–7 | The reason for using a single test is that you cannot use -o without -r, so all the -o test could do would be to test you get an error without -r. |
- add test case for LLVM section with not bundle name
- add test case for __bundle section in other segment
- address formatting comments
llvm/tools/llvm-objcopy/ObjcopyOptions.cpp | ||
---|---|---|
1224–1228 | I don't believe you can trigger the error callback on this code path as we are using a MatchStyle::Literal. |
llvm/test/tools/llvm-objcopy/MachO/bitcode-strip-basic.test | ||
---|---|---|
4–7 | Thanks. When I made this and related comments, I didn't realise that you wanted to make -r a cumpolsory argument. Given that other commands are planned, I'd suggest the following test file breakdown between this and D120731: | |
10 | Nit: comments should end with a period. Also, you can delete "output flag and" from this comment: the previous test case covers this point, so no need for this test case to explicitly mention that too. I'd also suggest deleting the blank line between comment and run command, since the two are tied together, rather than the comment being a general comment about the whole test file. | |
llvm/tools/llvm-objcopy/ObjcopyOptions.cpp | ||
1224–1228 | Thanks. Can the if statement ever fail though? (I'm not sure if the ErrorCallback and returned Error are tied together or not). If not, I'd change it to cantFail. |
- split test into basic and remove
- cantFail instead of checking error that cannot occur
llvm/tools/llvm-objcopy/ObjcopyOptions.cpp | ||
---|---|---|
1224–1228 | The if statement can only fail if the Matcher fails to create, which for a literal matcher cannot happen. Updated to cantFail. |
llvm/test/tools/llvm-objcopy/MachO/bitcode-strip-remove.test | ||
---|---|---|
4 | Actually, you should add a colon to the end of the --implicit-check-not command. Otherwise, this might accidentally match a part of someone's local directory tree. |
This comment doesn't line up with what the test is doing.