[llvm-commits] [llvm] r116751 - in /llvm/trunk: include/llvm/Analysis/AliasSetTracker.h lib/Analysis/AliasSetTracker.cpp test/Analysis/TypeBasedAliasAnalysis/licm.ll
Dan Gohman
gohman at apple.com
Mon Oct 18 14:28:01 PDT 2010
Author: djg
Date: Mon Oct 18 16:28:00 2010
New Revision: 116751
URL: http://llvm.org/viewvc/llvm-project?rev=116751&view=rev
Log:
Don't pass the raw invalid pointer used to represent conflicting
TBAA information to AliasAnalysis.
Modified:
llvm/trunk/include/llvm/Analysis/AliasSetTracker.h
llvm/trunk/lib/Analysis/AliasSetTracker.cpp
llvm/trunk/test/Analysis/TypeBasedAliasAnalysis/licm.ll
Modified: llvm/trunk/include/llvm/Analysis/AliasSetTracker.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/AliasSetTracker.h?rev=116751&r1=116750&r2=116751&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/AliasSetTracker.h (original)
+++ llvm/trunk/include/llvm/Analysis/AliasSetTracker.h Mon Oct 18 16:28:00 2010
@@ -67,7 +67,21 @@
unsigned getSize() const { return Size; }
- const MDNode *getTBAAInfo() const { return TBAAInfo; }
+ /// getRawTBAAInfo - Return the raw TBAAInfo member. In addition to
+ /// being null or a pointer to an MDNode, this could be -1, meaning
+ /// there was conflicting information.
+ const MDNode *getRawTBAAInfo() const {
+ return TBAAInfo;
+ }
+
+ /// getTBAAInfo - Return the TBAAInfo, or null if there is no
+ /// information or conflicting information.
+ const MDNode *getTBAAInfo() const {
+ // If we have conflicting TBAAInfo, return null.
+ if (TBAAInfo == reinterpret_cast<const MDNode *>(-1))
+ return 0;
+ return TBAAInfo;
+ }
AliasSet *getAliasSet(AliasSetTracker &AST) {
assert(AS && "No AliasSet yet!");
@@ -195,6 +209,7 @@
Value *getPointer() const { return CurNode->getValue(); }
unsigned getSize() const { return CurNode->getSize(); }
+ const MDNode *getRawTBAAInfo() const { return CurNode->getRawTBAAInfo(); }
const MDNode *getTBAAInfo() const { return CurNode->getTBAAInfo(); }
iterator& operator++() { // Preincrement
Modified: llvm/trunk/lib/Analysis/AliasSetTracker.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/AliasSetTracker.cpp?rev=116751&r1=116750&r2=116751&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/AliasSetTracker.cpp (original)
+++ llvm/trunk/lib/Analysis/AliasSetTracker.cpp Mon Oct 18 16:28:00 2010
@@ -158,7 +158,8 @@
// to be sure it doesn't alias the set...
for (iterator I = begin(), E = end(); I != E; ++I)
if (AA.alias(AliasAnalysis::Location(Ptr, Size, TBAAInfo),
- AliasAnalysis::Location(I.getPointer(), I.getSize(), I.getTBAAInfo())))
+ AliasAnalysis::Location(I.getPointer(), I.getSize(),
+ I.getTBAAInfo())))
return true;
// Check the call sites list and invoke list...
@@ -376,7 +377,7 @@
bool X;
for (AliasSet::iterator ASI = AS.begin(), E = AS.end(); ASI != E; ++ASI) {
AliasSet &NewAS = addPointer(ASI.getPointer(), ASI.getSize(),
- ASI.getTBAAInfo(),
+ ASI.getRawTBAAInfo(),
(AliasSet::AccessType)AS.AccessTy, X);
if (AS.isVolatile()) NewAS.setVolatile();
}
@@ -531,7 +532,8 @@
// Add it to the alias set it aliases...
I = PointerMap.find(From);
AliasSet *AS = I->second->getAliasSet(*this);
- AS->addPointer(*this, Entry, I->second->getSize(), I->second->getTBAAInfo(),
+ AS->addPointer(*this, Entry, I->second->getSize(),
+ I->second->getRawTBAAInfo(),
true);
}
Modified: llvm/trunk/test/Analysis/TypeBasedAliasAnalysis/licm.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/TypeBasedAliasAnalysis/licm.ll?rev=116751&r1=116750&r2=116751&view=diff
==============================================================================
--- llvm/trunk/test/Analysis/TypeBasedAliasAnalysis/licm.ll (original)
+++ llvm/trunk/test/Analysis/TypeBasedAliasAnalysis/licm.ll Mon Oct 18 16:28:00 2010
@@ -3,6 +3,7 @@
; LICM should be able to hoist the address load out of the loop
; by using TBAA information.
+; CHECK: @foo
; CHECK: entry:
; CHECK-NEXT: %tmp3 = load double** @P, !tbaa !0
; CHECK-NEXT: br label %for.body
@@ -31,3 +32,30 @@
!0 = metadata !{metadata !"root", null}
!1 = metadata !{metadata !"pointer", metadata !0}
!2 = metadata !{metadata !"double", metadata !0}
+
+; LICM shouldn't hoist anything here.
+
+; CHECK: @bar
+; CHECK: loop:
+; CHECK: load
+; CHECK: store
+; CHECK: load
+; CHECK: store
+; CHECK: br label %loop
+
+define void @bar(i8** %p) nounwind {
+entry:
+ %q = bitcast i8** %p to i8*
+ br label %loop
+
+loop:
+ %tmp51 = load i8** %p, !tbaa !4
+ store i8* %tmp51, i8** %p
+ %tmp40 = load i8* %q, !tbaa !5
+ store i8 %tmp40, i8* %q
+ br label %loop
+}
+
+!3 = metadata !{metadata !"pointer", metadata !4}
+!4 = metadata !{metadata !"char", metadata !5}
+!5 = metadata !{metadata !"root", null}
More information about the llvm-commits
mailing list