Fix the merging of the constantness of declarations.
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 30 Oct 2014 20:50:23 +0000 (20:50 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 30 Oct 2014 20:50:23 +0000 (20:50 +0000)
commitd1e64b1e93ccf8836dc76f36adda880bbeab196f
tree7d2d1adae7224b3bf3eb0749e2e6e0bad44a4df6
parent533e26103e1cdeb4201056ba8ff655d3f2604b9f
Fix the merging of the constantness of declarations.

The langref says:

LLVM explicitly allows declarations of global variables to be marked
constant, even if the final definition of the global is not. This
capability can be used to enable slightly better optimization of the
program, but requires the language definition to guarantee that
optimizations based on the ‘constantness’ are valid for the
translation units that do not include the definition.

Given that definition, when merging two declarations, we have to drop
constantness if of of them is not marked contant, since the Module
without the constant marker might not have the necessary guarantees.

llvm-svn: 220927
llvm/lib/Linker/LinkModules.cpp
llvm/test/Linker/ConstantGlobals3.ll