- Linker::LinkOnlyNeeded should always import globals with AppendingLinkage when used in Full-LTO / non-performing-import mode.
- This the patch against the release_40 branch; 4.0.1-rc2 / revision 304242 to be exact. There's also a review for a fix in trunk. See: https://reviews.llvm.org/D34448
This extra checks at line 357 and 586 are the fix. Without it, the tests below are failing.
The rest of the changes around is only to make the code more readable, allowing me to better document the intent,