Fix comparisons of alloca alignment in inliner merging
Duncan pointed out a mistake in my fix in r186425 when only one of the allocas
being compared had the target-default alignment. This is essentially his
suggested solution. Thanks!
llvm-svn: 186510
diff --git a/llvm/lib/Transforms/IPO/Inliner.cpp b/llvm/lib/Transforms/IPO/Inliner.cpp
index f72121d..d75d6ca 100644
--- a/llvm/lib/Transforms/IPO/Inliner.cpp
+++ b/llvm/lib/Transforms/IPO/Inliner.cpp
@@ -216,9 +216,18 @@
AI->replaceAllUsesWith(AvailableAlloca);
- if (Align1 > Align2 || (!Align1 && TD &&
- TD->getABITypeAlignment(AI->getAllocatedType()) > Align2))
- AvailableAlloca->setAlignment(Align1);
+ if (Align1 != Align2) {
+ if (!Align1 || !Align2) {
+ assert(TD && "DataLayout required to compare default alignments");
+ unsigned TypeAlign = TD->getABITypeAlignment(AI->getAllocatedType());
+
+ Align1 = Align1 ? Align1 : TypeAlign;
+ Align2 = Align2 ? Align2 : TypeAlign;
+ }
+
+ if (Align1 > Align2)
+ AvailableAlloca->setAlignment(AI->getAlignment());
+ }
AI->eraseFromParent();
MergedAwayAlloca = true;