aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/InlineFunction.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-12-25 20:42:38 +0000
committerChris Lattner <sabre@nondot.org>2010-12-25 20:42:38 +0000
commit7569d79de1bd97a6a17b81340ea6ce97d8a3c279 (patch)
treef53e35299a4ed20ce74fd81c5b034135c6175084 /lib/Transforms/Utils/InlineFunction.cpp
parent687140c818ba4b896329a83324714140b6580ef8 (diff)
switch the inliner alignment enforcement stuff to use the
getOrEnforceKnownAlignment function, which simplifies the code and makes it stronger. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122555 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/InlineFunction.cpp')
-rw-r--r--lib/Transforms/Utils/InlineFunction.cpp35
1 files changed, 8 insertions, 27 deletions
diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp
index 76fdd097c0..c1faf24113 100644
--- a/lib/Transforms/Utils/InlineFunction.cpp
+++ b/lib/Transforms/Utils/InlineFunction.cpp
@@ -24,6 +24,7 @@
#include "llvm/Analysis/DebugInfo.h"
#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/Target/TargetData.h"
+#include "llvm/Transforms/Utils/Local.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/CallSite.h"
@@ -247,34 +248,14 @@ static Value *HandleByValArgument(Value *Arg, Instruction *TheCall,
if (ByValAlignment <= 1) // 0 = unspecified, 1 = no particular alignment.
return Arg;
- // See if the argument is a (bitcasted) pointer to an alloca. If so, we can
- // round up the alloca if needed.
- if (AllocaInst *AI = dyn_cast<AllocaInst>(Arg->stripPointerCasts())) {
- unsigned AIAlign = AI->getAlignment();
-
- // If the alloca is known at least aligned as much as the byval, we can do
- // this optimization.
- if (AIAlign >= ByValAlignment)
- return Arg;
-
- // If the alloca has a specified alignment that is less than the byval,
- // then we can safely bump it up.
- if (AIAlign) {
- AI->setAlignment(ByValAlignment);
- return Arg;
- }
-
- // If the alignment has an unspecified alignment, then we can only modify
- // it if we have TD information. Doing so without TD info could end up
- // with us rounding the alignment *down* accidentally, which is badness.
- if (IFI.TD) {
- AIAlign = std::max(ByValAlignment, IFI.TD->getPrefTypeAlignment(AggTy));
- AI->setAlignment(AIAlign);
- return Arg;
- }
- }
+ // If the pointer is already known to be sufficiently aligned, or if we can
+ // round it up to a larger alignment, then we don't need a temporary.
+ if (getOrEnforceKnownAlignment(Arg, ByValAlignment,
+ IFI.TD) >= ByValAlignment)
+ return Arg;
- // Otherwise, we have to make a memcpy to get a safe alignment, pretty lame.
+ // Otherwise, we have to make a memcpy to get a safe alignment. This is bad
+ // for code quality, but rarely happens and is required for correctness.
}
LLVMContext &Context = Arg->getContext();