From r303590, ModuleFlagBehavior for PIC and PIE level is changed from
Error to Max. This will cause bitcode compatibility issue when linking
against a bitcode static archive built with old compiler.
Add an auto-ugprade path to upgrade the the ModuleFlagBehavior in the
old bitcode to match the new one so IRLinker can link them.
Details
- Reviewers
tejohnson mehdi_amini dexonsmith - Commits
- rG002ca6e8fc63: Merging r311387: --------------------------------------------------------------…
rG010fc49e42f2: [IR] AutoUpgrade ModuleFlagBehavior for PIC and PIE level
rL311481: Merging r311387:
rL311387: [IR] AutoUpgrade ModuleFlagBehavior for PIC and PIE level
Diff Detail
- Repository
- rL LLVM
Event Timeline
Is this something that is affecting clang-5.0 backward compatibility with clang-4.0?
(adding @hansw for visibility)
Yes, this will affect clang-5.0 backward compatibility. Thanks for bringing this up. I was planning to nominate to merge into release branch after this gets reviewed.
Who changed the behaviour? Can we get them to review the behaviour of the upgrade?
I don't see a general test for PIE level. Can we add one of those as well?
lib/IR/AutoUpgrade.cpp | ||
---|---|---|
2269–2270 ↗ | (On Diff #110489) | This would read more nicely as auto *Behavior, since you've already been explicit about the ConstantInt. |
2273–2274 ↗ | (On Diff #110489) | It's not generally sound to call MDNode::replaceOperandWith, unless the nodes are "distinct". I strongly suspect these nodes are "uniqued", which means that they are semantically constants (with far-too-lenient an API). Instead, you should construct a new node to attach to the NamedMDNode. |
Sorry for the delay, I was out all last week and missed this one. LGTM but with one question below about a test change.
test/Linker/module-flags-pic-1-a.ll | ||
---|---|---|
5 ↗ | (On Diff #110489) | Does this need to change - i.e. with this patch shouldn't it auto-upgrade? |
Duncan has a good point about replaceOperandWith, please address that (updating to remove patch accept).
The PIE test is in the same module.
test/Linker/module-flags-pic-1-a.ll needs to updated because the auto upgrade only happens when you load from bitcode. The texture format is not auto upgradeable and the old value still has valid syntax.
lib/IR/AutoUpgrade.cpp | ||
---|---|---|
2273–2274 ↗ | (On Diff #110489) | I am pretty sure the MDNode added to ModuleFlags are all uniqued. I am trying to modify the ModuleFlag here. Attaching new node to module flag is easy but removing is not. Sure, I can reconstruct the entire module flag NamedMDNode, but I am not sure if that is worthwhile if the MDNode is ensured to be uniqued. |
lib/IR/AutoUpgrade.cpp | ||
---|---|---|
2305–2311 ↗ | (On Diff #111754) | I think you should just change ModFlags->getOperand(I) in place. I think you'll need to add some API to NamedMDNode, but that should be straightforward. |