summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Value.cpp
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2014-08-01 23:28:49 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2014-08-01 23:28:49 +0000
commit3441ffe98dc12bad0b779c292a55670d70c277d7 (patch)
tree31544a1bb2b450af9245ef852a8a0464fb5577ad /llvm/lib/IR/Value.cpp
parente52646cd802fa38471bfed3740ab3377d9da0687 (diff)
downloadbcm5719-llvm-3441ffe98dc12bad0b779c292a55670d70c277d7.tar.gz
bcm5719-llvm-3441ffe98dc12bad0b779c292a55670d70c277d7.zip
IR: Add Value::reverseUseList()
I'm going to use this to improve `verify-uselistorder`. Part of PR5680. llvm-svn: 214594
Diffstat (limited to 'llvm/lib/IR/Value.cpp')
-rw-r--r--llvm/lib/IR/Value.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp
index 1ab2183b656..555823b3f28 100644
--- a/llvm/lib/IR/Value.cpp
+++ b/llvm/lib/IR/Value.cpp
@@ -614,6 +614,25 @@ Value *Value::DoPHITranslation(const BasicBlock *CurBB,
LLVMContext &Value::getContext() const { return VTy->getContext(); }
+void Value::reverseUseList() {
+ if (!UseList || !UseList->Next)
+ // No need to reverse 0 or 1 uses.
+ return;
+
+ Use *Head = UseList;
+ Use *Current = UseList->Next;
+ Head->Next = nullptr;
+ while (Current) {
+ Use *Next = Current->Next;
+ Current->Next = Head;
+ Head->setPrev(&Current->Next);
+ Head = Current;
+ Current = Next;
+ }
+ UseList = Head;
+ Head->setPrev(&UseList);
+}
+
//===----------------------------------------------------------------------===//
// ValueHandleBase Class
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud