References to functions are in program memory and need a pm() fixup. This should fix trait objects for Rust on AVR.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Time | Test | |
---|---|---|
8,510 ms | linux > MLIR.Examples/standalone::test.toy |
Event Timeline
As a quick review (without looking into this carefully): you need to add tests. Without tests this will not be accepted. It also gives a better idea of what it does exactly and thus makes reviewing easier.
I added tests. One makes sure that a pm() asm expr generates a R_AVR_16_PM relocation. The other is pruned LLVM IR from a simple Rust program that uses trait objects.
Good bugfix - thanks for the second patch!
llvm/lib/Target/AVR/AVRAsmPrinter.cpp | ||
---|---|---|
187 | This check is not fully sufficient for covering all cases - namely, the constant may not be a function but still might be constrained to program memory and require the new pm fixup. Motivating example: a global variable that is explicitly located in program memory via an addrspace(1) qualifier. Suggest replacing the "is a function" check with GV->getAddressSpace() == AVR::ProgramMemory which more directly captures what you're wanting to check, and will also add the new pm fixup to regular progmem vars | |
llvm/lib/Target/AVR/MCTargetDesc/AVRELFObjectWriter.cpp | ||
11 | Order the #include alphabetically | |
llvm/test/CodeGen/AVR/rust-trait-object.ll | ||
10 ↗ | (On Diff #292034) | Rename Rust identifier names in this file to something human readable. For this particular line, a more appropriate name might be EmptyType or simple TypeFoo. In general, LLVM tests are committed without the machine-readable naming conventions of the frontend used to generate them. It will also make some of the CHECK lines shorter and more obvious. |
65 ↗ | (On Diff #292034) | Remove attribute specifiers (#n) after functions - most if not all of them should be unnecessary |
72 ↗ | (On Diff #292034) | Drop the linking options and calling convention fastcc - I suspect these are not needed to reproduce |
141 ↗ | (On Diff #292034) | Delete the attributes which are not required for your test to pass |
llvm/test/CodeGen/AVR/rust-trait-object.ll | ||
---|---|---|
5 ↗ | (On Diff #292034) | Optional: It might be a good idea to post the version of the Rust compiler used if it's not too much hassle to dig that up again. |
67 ↗ | (On Diff #292034) | Drop unnecessary function attributes as I suspect they are not required to reproduce the issue |
92 ↗ | (On Diff #292034) | Avoid numeric variable names in LLVM tests as they make modfications to the test in the future more difficult as LLVM verifier requires that all numerical vars are defined in order, which makes insertion of new variables mid-function problematic. There is an existing LLVM pass which can be used to do this automatically, although there are very few numbered variable names in the test already so it might be easier to fixup manually. In the past I've been recommended and used to good success is the instnamer pass, invokable via opt -instnamer ..., although it will strip out your CHECK lines. |
I have applied the code review suggestions and committed this to master in 2ccb941740e608a9cf70a7c5840497149654b0f6.
This will fix https://github.com/rust-lang/rust/issues/79889
Thanks for the patch @amikhalev!
This check is not fully sufficient for covering all cases - namely, the constant may not be a function but still might be constrained to program memory and require the new pm fixup. Motivating example: a global variable that is explicitly located in program memory via an addrspace(1) qualifier.
Suggest replacing the "is a function" check with GV->getAddressSpace() == AVR::ProgramMemory which more directly captures what you're wanting to check, and will also add the new pm fixup to regular progmem vars