summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
diff options
context:
space:
mode:
authorVictor Hernandez <vhernandez@apple.com>2009-09-18 22:35:49 +0000
committerVictor Hernandez <vhernandez@apple.com>2009-09-18 22:35:49 +0000
commit5d034499ad2b0cd99833dd66e9359bf17088fa11 (patch)
treec7c7349c462240747f9fcdd168666acfcc8464c5 /llvm/lib/Transforms/IPO/FunctionAttrs.cpp
parent3d8f8625967ac153e80ff100ac88a3393631df24 (diff)
downloadbcm5719-llvm-5d034499ad2b0cd99833dd66e9359bf17088fa11.tar.gz
bcm5719-llvm-5d034499ad2b0cd99833dd66e9359bf17088fa11.zip
Enhance transform passes so that they apply the same tranforms to malloc calls as to MallocInst.
Reviewed by Dan Gohman. llvm-svn: 82300
Diffstat (limited to 'llvm/lib/Transforms/IPO/FunctionAttrs.cpp')
-rw-r--r--llvm/lib/Transforms/IPO/FunctionAttrs.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
index 26b4152291e..14c94da5595 100644
--- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -26,6 +26,7 @@
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/CallGraph.h"
#include "llvm/Analysis/CaptureTracking.h"
+#include "llvm/Analysis/MallocHelper.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/UniqueVector.h"
@@ -152,8 +153,8 @@ bool FunctionAttrs::AddReadAttrs(const std::vector<CallGraphNode *> &SCC) {
// Writes memory. Just give up.
return false;
- if (isa<MallocInst>(I))
- // MallocInst claims not to write memory! PR3754.
+ if (isa<MallocInst>(I) || isMalloc(I))
+ // malloc claims not to write memory! PR3754.
return false;
// If this instruction may read memory, remember that.
@@ -247,8 +248,11 @@ bool FunctionAttrs::IsFunctionMallocLike(Function *F,
if (Instruction *RVI = dyn_cast<Instruction>(RetVal))
switch (RVI->getOpcode()) {
// Extend the analysis by looking upwards.
- case Instruction::GetElementPtr:
case Instruction::BitCast:
+ if (isMalloc(RVI))
+ break;
+ // fall through
+ case Instruction::GetElementPtr:
FlowsToReturn.insert(RVI->getOperand(0));
continue;
case Instruction::Select: {
@@ -267,6 +271,8 @@ bool FunctionAttrs::IsFunctionMallocLike(Function *F,
case Instruction::Malloc:
break;
case Instruction::Call:
+ if (isMalloc(RVI))
+ break;
case Instruction::Invoke: {
CallSite CS(RVI);
if (CS.paramHasAttr(0, Attribute::NoAlias))
OpenPOWER on IntegriCloud