Reid Kleckner
2014-Sep-19 17:42 UTC
[LLVMdev] [RFC] Exhaustive bitcode compatibility tests for IR features
This sounds like a good plan. Initially, the tests will be very repetitious, but over time as we make changes they will diverge. For example, before swapping the order of 'alias' and linkage in the IL, we would've had: @a = alias weak i8* @target ; CHECK: @a = alias weak i8* @target This would've been copied to compatibility-3.N.ll for the previous release before the change, and the change would have to update to the new llvm-dis syntax: @a = alias weak i8* @target ; CHECK: @a = weak alias i8* @target So we need the duplication because we expect llvm-dis to slowly diverge from the input that we would have fed to llvm-as-3.N. On Fri, Sep 19, 2014 at 9:57 AM, Rafael Espíndola < rafael.espindola at gmail.com> wrote:> So the proposal is that during development new features are added to > test/Features/compatibility.ll (or some other name). When 3.6 is > released, we will > > * assemble the file with llvm-as-3.6. > * Check in the .bc file as test/Features/Input/compatibility-3.6.bc > * Copy test/Features/compatibility.ll to > test/Features/compatibility-3.6.ll and change it to run llvm-dis > directly on the 3.6 bitcode. > > And then when 4.1 is released we have a discussion on what we want to > drop from the old .bc files. > > Correct? If so, sounds reasonable to me. > > > On 18 September 2014 22:01, Steven Wu <stevenwu at apple.com> wrote: > > From the discussion of bitcode backward compatibility on the list, it > seems we lack systematic way to test every existing IR features. It is > useful to keep a test that exercises all the IR features for the current > trunk and we can freeze that test in the form of bitcode for backward > compatibility test in the future. I am proposing to implement such a test, > which should try to accomplish following features: > > 1. Try to keep it in one file so it is easy to freeze and move to the > next version. > > 2. Try to exercise and verify as much features as possible, which should > includes all the globals, instructions, metadata and intrinsics (and more). > > 3. The test should be easily maintainable. It should be easy to fix when > broken or get updated when assembly gets updated. > > I am going to implement such test with a lengthy LLVM assembly, in the > form of the attachment (which I only tests for global variable). It is > going to be long, but someone must do it first. Future updates should be > much simper. In the test, I started with a default global variable and > enumerate all the possible attributes by changing them one by one. I try to > keep the variable declaration as simple as possible so that it won’t be > affected by some simple assembly level changes (like changing the parsing > order of some attributes, since this is supposed to be a bitcode > compatibility test, not assembly test). I try to make the tests as thorough > as possible but avoid large duplications. For example, I will tests Linkage > attribute in both GlobalVariable as well as Function, but probably not > enumerate all the types I want to test. I will keep the tests for Types in > a different section since it is going to be huge and it is orthogonal to > the tests of globals. > > When making a release or some big changes in IR, we can freeze the test > by generating bitcode, change the RUN line so it runs llvm-dis directly, > and modified the CHECKs that corresponding to the change. Then we can move > on with a new version of bitcode tests. This will add some more works for > people who would like to make changes to IR (which might be one more reason > to discourage them from breaking the compatibility). I will make sure to > update the docs for changing IRs after I add this test. > > > > Currently, there are individual bitcode tests in the llvm which are > created when IR or intrinsics get changed. This exhaustive test shouldn’t > overlap with the existing ones since this tests is focusing on keeping a > working up-to-date version of IR tests. Both approaches of bitcode tests > can co-exists. For example, for small updates, we can add specific test > cases like the ones currently to test auto-upgrade, while updating the > exhaustive bitcode test to incorporate the new changes. When making huge > upgrades and major releases, we can freeze the exhaustive test for future > checks. > > > > For the actual test cases, I think it should be trivial for globals, > instructions, types (Correct me if I am wrong), but intrinsics can be very > tricky. I am not sure how much compatibility is guaranteed for intrinsics, > but they can’t not be checked through llvm-as then llvm-dis. Intrinsics, as > far as I know, are coded like normal functions, globals or metadata. My > current plan is to write a separate tool to check the intrinsics actually > supported in the IR or backend. Intrinsic function might be the easiest > since the supported ones should all be declared in Intrinsics*.td and can > be check by calling getIntrinsicID() after reading the bitcode. Intrinsics > coded as globals (llvm.used) or metadata (llvm.loop) can be more tricky. > Maybe another .td file with hardcoded intrinsics for these cases should be > added just for the testing purpose (we can add a new API to it later so > that we don’t need to do string compares to figure out these intrinsics). > After we have another tool to test intrinsics (which can be merged with > llvm-dis to save a RUN command and execution time), the attached test will > just need to be updated like following (checking llvm.global_ctors for > example): > > ; RUN: verify-intrinsics %s.bc | FileCheck -check-prefix=CHECK-INT %s > > > > %0 = type { i32, void ()*, i8* } > > @llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, void ()* > @ctor, i8* @data }] > > ; CHECK: @llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, > void ()* @ctor, i8* @data }] > > ; CHECK-INT: @llvm.global_ctors int_global_ctors > > > > Let me know if there is better proposal. > > > > Steven > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140919/724e9404/attachment.html>
Steven Wu
2014-Sep-19 18:33 UTC
[LLVMdev] [RFC] Exhaustive bitcode compatibility tests for IR features
Well, this essentially means when someone need to change assembly syntax in llvm-3.9, he has to go back and edit all the compatibility tests for 3.N? Sounds like a little bit extra work, though I am not totally against it. Another option, since this is a bitcode test and the assembly really doesn’t matter, we can do the tests for changes like alias in one single file like following: ; Check for 3.5 compatibility ; RUN: llvm-dis %s.3.5.bc | FileCheck %s ; Check for current IR ; RUN: llvm-as < %s | llvm-dis | FileCheck %s @a = weak alias i8* @target ; llvm-3.5: @a = alias weak i8* @target ; CHECK: @a = weak alias i8* @target We can avoid duplicating the entire file for some small changes that really doesn’t affect bitcode. Steven> On Sep 19, 2014, at 10:42 AM, Reid Kleckner <rnk at google.com> wrote: > > This sounds like a good plan. Initially, the tests will be very repetitious, but over time as we make changes they will diverge. For example, before swapping the order of 'alias' and linkage in the IL, we would've had: > > @a = alias weak i8* @target > ; CHECK: @a = alias weak i8* @target > > This would've been copied to compatibility-3.N.ll for the previous release before the change, and the change would have to update to the new llvm-dis syntax: > > @a = alias weak i8* @target > ; CHECK: @a = weak alias i8* @target > > So we need the duplication because we expect llvm-dis to slowly diverge from the input that we would have fed to llvm-as-3.N. > > On Fri, Sep 19, 2014 at 9:57 AM, Rafael Espíndola <rafael.espindola at gmail.com <mailto:rafael.espindola at gmail.com>> wrote: > So the proposal is that during development new features are added to > test/Features/compatibility.ll (or some other name). When 3.6 is > released, we will > > * assemble the file with llvm-as-3.6. > * Check in the .bc file as test/Features/Input/compatibility-3.6.bc > * Copy test/Features/compatibility.ll to > test/Features/compatibility-3.6.ll and change it to run llvm-dis > directly on the 3.6 bitcode. > > And then when 4.1 is released we have a discussion on what we want to > drop from the old .bc files. > > Correct? If so, sounds reasonable to me. > > > On 18 September 2014 22:01, Steven Wu <stevenwu at apple.com <mailto:stevenwu at apple.com>> wrote: > > From the discussion of bitcode backward compatibility on the list, it seems we lack systematic way to test every existing IR features. It is useful to keep a test that exercises all the IR features for the current trunk and we can freeze that test in the form of bitcode for backward compatibility test in the future. I am proposing to implement such a test, which should try to accomplish following features: > > 1. Try to keep it in one file so it is easy to freeze and move to the next version. > > 2. Try to exercise and verify as much features as possible, which should includes all the globals, instructions, metadata and intrinsics (and more). > > 3. The test should be easily maintainable. It should be easy to fix when broken or get updated when assembly gets updated. > > I am going to implement such test with a lengthy LLVM assembly, in the form of the attachment (which I only tests for global variable). It is going to be long, but someone must do it first. Future updates should be much simper. In the test, I started with a default global variable and enumerate all the possible attributes by changing them one by one. I try to keep the variable declaration as simple as possible so that it won’t be affected by some simple assembly level changes (like changing the parsing order of some attributes, since this is supposed to be a bitcode compatibility test, not assembly test). I try to make the tests as thorough as possible but avoid large duplications. For example, I will tests Linkage attribute in both GlobalVariable as well as Function, but probably not enumerate all the types I want to test. I will keep the tests for Types in a different section since it is going to be huge and it is orthogonal to the tests of globals. > > When making a release or some big changes in IR, we can freeze the test by generating bitcode, change the RUN line so it runs llvm-dis directly, and modified the CHECKs that corresponding to the change. Then we can move on with a new version of bitcode tests. This will add some more works for people who would like to make changes to IR (which might be one more reason to discourage them from breaking the compatibility). I will make sure to update the docs for changing IRs after I add this test. > > > > Currently, there are individual bitcode tests in the llvm which are created when IR or intrinsics get changed. This exhaustive test shouldn’t overlap with the existing ones since this tests is focusing on keeping a working up-to-date version of IR tests. Both approaches of bitcode tests can co-exists. For example, for small updates, we can add specific test cases like the ones currently to test auto-upgrade, while updating the exhaustive bitcode test to incorporate the new changes. When making huge upgrades and major releases, we can freeze the exhaustive test for future checks. > > > > For the actual test cases, I think it should be trivial for globals, instructions, types (Correct me if I am wrong), but intrinsics can be very tricky. I am not sure how much compatibility is guaranteed for intrinsics, but they can’t not be checked through llvm-as then llvm-dis. Intrinsics, as far as I know, are coded like normal functions, globals or metadata. My current plan is to write a separate tool to check the intrinsics actually supported in the IR or backend. Intrinsic function might be the easiest since the supported ones should all be declared in Intrinsics*.td and can be check by calling getIntrinsicID() after reading the bitcode. Intrinsics coded as globals (llvm.used) or metadata (llvm.loop) can be more tricky. Maybe another .td file with hardcoded intrinsics for these cases should be added just for the testing purpose (we can add a new API to it later so that we don’t need to do string compares to figure out these intrinsics). After we have another tool to test intrinsics (which can be merged with llvm-dis to save a RUN command and execution time), the attached test will just need to be updated like following (checking llvm.global_ctors for example): > > ; RUN: verify-intrinsics %s.bc | FileCheck -check-prefix=CHECK-INT %s > > > > %0 = type { i32, void ()*, i8* } > > @llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, void ()* @ctor, i8* @data }] > > ; CHECK: @llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, void ()* @ctor, i8* @data }] > > ; CHECK-INT: @llvm.global_ctors int_global_ctors > > > > Let me know if there is better proposal. > > > > Steven > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140919/c3292e09/attachment.html>
Rafael Espíndola
2014-Sep-19 19:44 UTC
[LLVMdev] [RFC] Exhaustive bitcode compatibility tests for IR features
On 19 September 2014 14:33, Steven Wu <stevenwu at apple.com> wrote:> Well, this essentially means when someone need to change assembly syntax in > llvm-3.9, he has to go back and edit all the compatibility tests for 3.N? > Sounds like a little bit extra work, though I am not totally against it.No, the idea is that in test/Features/compatibility-3.6.ll we will have ; The file test/Features/Inputs/compatibility-3.6.bc was created by passing this file to llvm-as-3.6. and the test itself would just use llvm-dis and FileCheck, not llvm-as. In other words, the file compatibilty-X.Y.ll contains text that can be assembled by llvm-as from the X.Y release, not current trunk. We would keep the text mostly for documentation and if someone ever wants to verify that Inputs/compatibility-X.Y.bc is correct. Cheers, Rafael