[llvm-commits] [llvm] r118788 - in /llvm/trunk: lib/Transforms/Scalar/Sink.cpp test/Analysis/TypeBasedAliasAnalysis/sink.ll
Dan Gohman
gohman at apple.com
Thu Nov 11 08:21:48 PST 2010
Author: djg
Date: Thu Nov 11 10:21:47 2010
New Revision: 118788
URL: http://llvm.org/viewvc/llvm-project?rev=118788&view=rev
Log:
Make Sink tbaa-aware.
Added:
llvm/trunk/test/Analysis/TypeBasedAliasAnalysis/sink.ll
Modified:
llvm/trunk/lib/Transforms/Scalar/Sink.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/Sink.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/Sink.cpp?rev=118788&r1=118787&r2=118788&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/Sink.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/Sink.cpp Thu Nov 11 10:21:47 2010
@@ -15,6 +15,7 @@
#define DEBUG_TYPE "sink"
#include "llvm/Transforms/Scalar.h"
#include "llvm/IntrinsicInst.h"
+#include "llvm/LLVMContext.h"
#include "llvm/Analysis/Dominators.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/AliasAnalysis.h"
@@ -158,9 +159,11 @@
Value *Ptr = L->getPointerOperand();
uint64_t Size = AA->getTypeStoreSize(L->getType());
+ const MDNode *TBAAInfo = L->getMetadata(LLVMContext::MD_tbaa);
+ AliasAnalysis::Location Loc(Ptr, Size, TBAAInfo);
for (SmallPtrSet<Instruction *, 8>::iterator I = Stores.begin(),
E = Stores.end(); I != E; ++I)
- if (AA->getModRefInfo(*I, Ptr, Size) & AliasAnalysis::Mod)
+ if (AA->getModRefInfo(*I, Loc) & AliasAnalysis::Mod)
return false;
}
Added: llvm/trunk/test/Analysis/TypeBasedAliasAnalysis/sink.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/TypeBasedAliasAnalysis/sink.ll?rev=118788&view=auto
==============================================================================
--- llvm/trunk/test/Analysis/TypeBasedAliasAnalysis/sink.ll (added)
+++ llvm/trunk/test/Analysis/TypeBasedAliasAnalysis/sink.ll Thu Nov 11 10:21:47 2010
@@ -0,0 +1,20 @@
+; RUN: opt -tbaa -enable-tbaa -sink -S < %s | FileCheck %s
+
+; CHECK: a:
+; CHECK: %f = load float* %p, !tbaa !2
+; CHECK: store float %f, float* %q
+
+define void @foo(float* %p, i1 %c, float* %q, float* %r) {
+ %f = load float* %p, !tbaa !0
+ store float 0.0, float* %r, !tbaa !1
+ br i1 %c, label %a, label %b
+a:
+ store float %f, float* %q
+ br label %b
+b:
+ ret void
+}
+
+!0 = metadata !{metadata !"A", metadata !2}
+!1 = metadata !{metadata !"B", metadata !2}
+!2 = metadata !{metadata !"test"}
More information about the llvm-commits
mailing list