From 81c03447fc6358197258903e3fc6ee65b16ee768 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Sat, 27 Mar 2010 01:54:00 +0000 Subject: [PATCH] When we promote a load of an argument make sure to take the alignment of the previous load - it's usually important. For example, we don't want to blindly turn an unaligned load into an aligned one. llvm-svn: 99699 --- llvm/lib/Transforms/IPO/ArgumentPromotion.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp index 00b147e8851e2..40a87e880d7bf 100644 --- a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp +++ b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp @@ -687,7 +687,11 @@ CallGraphNode *ArgPromotion::DoPromotion(Function *F, Ops.clear(); AA.copyValue(OrigLoad->getOperand(0), V); } - Args.push_back(new LoadInst(V, V->getName()+".val", Call)); + // Since we're replacing a load make sure we take the alignment + // of the previous load. + LoadInst *newLoad = new LoadInst(V, V->getName()+".val", Call); + newLoad->setAlignment(OrigLoad->getAlignment()); + Args.push_back(newLoad); AA.copyValue(OrigLoad, Args.back()); } }