Remove GlobalValue::getAlignment().

This function is deceptive at best: it doesn't return what you'd expect.
If you have an arbitrary GlobalValue and you want to determine the
alignment of that pointer, Value::getPointerAlignment() returns the
correct value.  If you want the actual declared alignment of a function
or variable, GlobalObject::getAlignment() returns that.

This patch switches all the users of GlobalValue::getAlignment to an
appropriate alternative.

Differential Revision: https://reviews.llvm.org/D80368
This commit is contained in:
Eli Friedman
2020-05-18 20:38:13 -07:00
parent f8bd6a75ed
commit a2caa3b614
25 changed files with 73 additions and 78 deletions

View File

@@ -1179,7 +1179,7 @@ void ModuleBitcodeWriter::writeModuleInfo() {
std::map<std::string, unsigned> GCMap;
unsigned MaxAlignment = 0;
unsigned MaxGlobalType = 0;
for (const GlobalValue &GV : M.globals()) {
for (const GlobalVariable &GV : M.globals()) {
MaxAlignment = std::max(MaxAlignment, GV.getAlignment());
MaxGlobalType = std::max(MaxGlobalType, VE.getTypeID(GV.getValueType()));
if (GV.hasSection()) {