Fix EnforceKnownAlignment so that it doesn't ever reduce the alignment

of an alloca or global variable.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@64693 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman 2009-02-16 23:02:21 +00:00
parent e2a8dfefe5
commit ecd0fb51cb
2 changed files with 30 additions and 4 deletions

View File

@ -9237,15 +9237,23 @@ static unsigned EnforceKnownAlignment(Value *V,
// If there is a large requested alignment and we can, bump up the alignment
// of the global.
if (!GV->isDeclaration()) {
GV->setAlignment(PrefAlign);
Align = PrefAlign;
if (GV->getAlignment() >= PrefAlign)
Align = GV->getAlignment();
else {
GV->setAlignment(PrefAlign);
Align = PrefAlign;
}
}
} else if (AllocationInst *AI = dyn_cast<AllocationInst>(V)) {
// If there is a requested alignment and if this is an alloca, round up. We
// don't do this for malloc, because some systems can't respect the request.
if (isa<AllocaInst>(AI)) {
AI->setAlignment(PrefAlign);
Align = PrefAlign;
if (AI->getAlignment() >= PrefAlign)
Align = AI->getAlignment();
else {
AI->setAlignment(PrefAlign);
Align = PrefAlign;
}
}
}

File diff suppressed because one or more lines are too long