[llvm-commits] [poolalloc] r141426 - /poolalloc/trunk/lib/DSA/Local.cpp
John Criswell
criswell at uiuc.edu
Fri Oct 7 15:21:38 PDT 2011
Author: criswell
Date: Fri Oct 7 17:21:38 2011
New Revision: 141426
URL: http://llvm.org/viewvc/llvm-project?rev=141426&view=rev
Log:
Added support for the cmpxchg instruction.
Modified:
poolalloc/trunk/lib/DSA/Local.cpp
Modified: poolalloc/trunk/lib/DSA/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=141426&r1=141425&r2=141426&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/Local.cpp (original)
+++ poolalloc/trunk/lib/DSA/Local.cpp Fri Oct 7 17:21:38 2011
@@ -118,6 +118,7 @@
void visitSelectInst(SelectInst &SI);
void visitLoadInst(LoadInst &LI);
void visitStoreInst(StoreInst &SI);
+ void visitAtomicCmpXchgInst(AtomicCmpXchgInst &I);
void visitAtomicRMWInst(AtomicRMWInst &I);
void visitReturnInst(ReturnInst &RI);
void visitVAArgInst(VAArgInst &I);
@@ -415,6 +416,57 @@
Dest.getNode()->mergeTypeInfo(StoredTy, Dest.getOffset());
}
+void GraphBuilder::visitAtomicCmpXchgInst(AtomicCmpXchgInst &I) {
+ if (isa<PointerType>(I.getType())) {
+ visitInstruction (I);
+ return;
+ }
+
+ //
+ // Create a DSNode for the dereferenced pointer . If the DSNode is NULL, do
+ // nothing more (this can occur if the pointer is a NULL constant; bugpoint
+ // can generate such code).
+ //
+ DSNodeHandle Ptr = getValueDest(I.getPointerOperand());
+ if (Ptr.isNull()) return;
+
+ //
+ // Make that the memory object is read and written.
+ //
+ Ptr.getNode()->setReadMarker();
+ Ptr.getNode()->setModifiedMarker();
+
+ //
+ // If the result of the compare-and-swap is a pointer, then we need to do
+ // a few things:
+ // o Merge the compare and swap values (which are pointers) with the result
+ // o Merge the DSNode of the pointer *within* the memory object with the
+ // DSNode of the compare, swap, and result DSNode.
+ //
+ if (isa<PointerType>(I.getType())) {
+ //
+ // Get the DSNodeHandle of the memory object returned from the load. Make
+ // it the DSNodeHandle of the instruction's result.
+ //
+ DSNodeHandle FieldPtr = getLink (Ptr);
+ setDestTo(I, getLink(Ptr));
+
+ //
+ // Merge the result, compare, and swap values of the instruction.
+ //
+ FieldPtr.mergeWith (getValueDest (I.getCompareOperand()));
+ FieldPtr.mergeWith (getValueDest (I.getNewValOperand()));
+ }
+
+ //
+ // Modify the DSNode so that it has the loaded/written type at the
+ // appropriate offset.
+ //
+ Ptr.getNode()->growSizeForType(I.getType(), Ptr.getOffset());
+ Ptr.getNode()->mergeTypeInfo(I.getType(), Ptr.getOffset());
+ return;
+}
+
void GraphBuilder::visitAtomicRMWInst(AtomicRMWInst &I) {
//
// Create a DSNode for the dereferenced pointer . If the DSNode is NULL, do
More information about the llvm-commits
mailing list