[llvm-commits] [llvm] r159667 - in /llvm/trunk: include/llvm/Analysis/MemoryBuiltins.h lib/Analysis/MemoryBuiltins.cpp
Nuno Lopes
nunoplopes at sapo.pt
Tue Jul 3 10:13:25 PDT 2012
Author: nlopes
Date: Tue Jul 3 12:13:25 2012
New Revision: 159667
URL: http://llvm.org/viewvc/llvm-project?rev=159667&view=rev
Log:
fold PHI nodes in SizeOffsetEvaluator whenever possible.
Unfortunately this change requires the cache map to hold WeakVHs instead
Modified:
llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h
llvm/trunk/lib/Analysis/MemoryBuiltins.cpp
Modified: llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h?rev=159667&r1=159666&r2=159667&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h (original)
+++ llvm/trunk/include/llvm/Analysis/MemoryBuiltins.h Tue Jul 3 12:13:25 2012
@@ -22,6 +22,7 @@
#include "llvm/Support/DataTypes.h"
#include "llvm/Support/InstVisitor.h"
#include "llvm/Support/TargetFolder.h"
+#include "llvm/Support/ValueHandle.h"
namespace llvm {
class CallInst;
@@ -195,7 +196,8 @@
: public InstVisitor<ObjectSizeOffsetEvaluator, SizeOffsetEvalType> {
typedef IRBuilder<true, TargetFolder> BuilderTy;
- typedef DenseMap<const Value*, SizeOffsetEvalType> CacheMapTy;
+ typedef std::pair<WeakVH, WeakVH> WeakEvalType;
+ typedef DenseMap<const Value*, WeakEvalType> CacheMapTy;
typedef SmallPtrSet<const Value*, 8> PtrSetTy;
const TargetData *TD;
@@ -216,19 +218,19 @@
ObjectSizeOffsetEvaluator(const TargetData *TD, LLVMContext &Context);
SizeOffsetEvalType compute(Value *V);
- bool knownSize(SizeOffsetEvalType &SizeOffset) {
+ bool knownSize(SizeOffsetEvalType SizeOffset) {
return SizeOffset.first;
}
- bool knownOffset(SizeOffsetEvalType &SizeOffset) {
+ bool knownOffset(SizeOffsetEvalType SizeOffset) {
return SizeOffset.second;
}
- bool anyKnown(SizeOffsetEvalType &SizeOffset) {
+ bool anyKnown(SizeOffsetEvalType SizeOffset) {
return knownSize(SizeOffset) || knownOffset(SizeOffset);
}
- bool bothKnown(SizeOffsetEvalType &SizeOffset) {
+ bool bothKnown(SizeOffsetEvalType SizeOffset) {
return knownSize(SizeOffset) && knownOffset(SizeOffset);
}
Modified: llvm/trunk/lib/Analysis/MemoryBuiltins.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemoryBuiltins.cpp?rev=159667&r1=159666&r2=159667&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/MemoryBuiltins.cpp (original)
+++ llvm/trunk/lib/Analysis/MemoryBuiltins.cpp Tue Jul 3 12:13:25 2012
@@ -682,7 +682,19 @@
SizePHI->addIncoming(EdgeData.first, PHI.getIncomingBlock(i));
OffsetPHI->addIncoming(EdgeData.second, PHI.getIncomingBlock(i));
}
- return std::make_pair(SizePHI, OffsetPHI);
+
+ Value *Size = SizePHI, *Offset = OffsetPHI, *Tmp;
+ if ((Tmp = SizePHI->hasConstantValue())) {
+ Size = Tmp;
+ SizePHI->replaceAllUsesWith(Size);
+ SizePHI->eraseFromParent();
+ }
+ if ((Tmp = OffsetPHI->hasConstantValue())) {
+ Offset = Tmp;
+ OffsetPHI->replaceAllUsesWith(Offset);
+ OffsetPHI->eraseFromParent();
+ }
+ return std::make_pair(Size, Offset);
}
SizeOffsetEvalType ObjectSizeOffsetEvaluator::visitSelectInst(SelectInst &I) {
More information about the llvm-commits
mailing list