Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: lib/Transforms/NaCl/ConstantInsertExtractElementIndex.cpp

Issue 1151093004: Changes from 3.7 merge to files not in upstream (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-llvm.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 //===- ConstantInsertExtractElementIndex.cpp - Insert/Extract element -----===// 1 //===- ConstantInsertExtractElementIndex.cpp - Insert/Extract element -----===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // The LLVM Compiler Infrastructure
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // Transform all InsertElement and ExtractElement with non-constant or 10 // Transform all InsertElement and ExtractElement with non-constant or
(...skipping 16 matching lines...) Expand all
27 using namespace llvm; 27 using namespace llvm;
28 28
29 namespace { 29 namespace {
30 class ConstantInsertExtractElementIndex : public BasicBlockPass { 30 class ConstantInsertExtractElementIndex : public BasicBlockPass {
31 public: 31 public:
32 static char ID; // Pass identification, replacement for typeid 32 static char ID; // Pass identification, replacement for typeid
33 ConstantInsertExtractElementIndex() : BasicBlockPass(ID), M(0), DL(0) { 33 ConstantInsertExtractElementIndex() : BasicBlockPass(ID), M(0), DL(0) {
34 initializeConstantInsertExtractElementIndexPass( 34 initializeConstantInsertExtractElementIndexPass(
35 *PassRegistry::getPassRegistry()); 35 *PassRegistry::getPassRegistry());
36 } 36 }
37 void getAnalysisUsage(AnalysisUsage &AU) const override {
38 AU.addRequired<DataLayoutPass>();
39 BasicBlockPass::getAnalysisUsage(AU);
40 }
41 using BasicBlockPass::doInitialization; 37 using BasicBlockPass::doInitialization;
42 bool doInitialization(Module &Mod) override { 38 bool doInitialization(Module &Mod) override {
43 M = &Mod; 39 M = &Mod;
44 return false; // Unchanged. 40 return false; // Unchanged.
45 } 41 }
46 bool runOnBasicBlock(BasicBlock &BB) override; 42 bool runOnBasicBlock(BasicBlock &BB) override;
47 43
48 private: 44 private:
49 typedef SmallVector<Instruction *, 8> Instructions; 45 typedef SmallVector<Instruction *, 8> Instructions;
50 const Module *M; 46 const Module *M;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } 151 }
156 152
157 I->replaceAllUsesWith(Res); 153 I->replaceAllUsesWith(Res);
158 I->eraseFromParent(); 154 I->eraseFromParent();
159 } 155 }
160 } 156 }
161 157
162 bool ConstantInsertExtractElementIndex::runOnBasicBlock(BasicBlock &BB) { 158 bool ConstantInsertExtractElementIndex::runOnBasicBlock(BasicBlock &BB) {
163 bool Changed = false; 159 bool Changed = false;
164 if (!DL) 160 if (!DL)
165 DL = &getAnalysis<DataLayoutPass>().getDataLayout(); 161 DL = &BB.getParent()->getParent()->getDataLayout();
jvoung (off chromium) 2015/05/26 20:39:45 nit: Could be BB.getModule()->getDataLayout();
Derek Schuff 2015/05/26 22:01:32 Done.
166 Instructions OutOfRangeConstantIndices; 162 Instructions OutOfRangeConstantIndices;
167 Instructions NonConstantVectorIndices; 163 Instructions NonConstantVectorIndices;
168 164
169 findNonConstantInsertExtractElements(BB, OutOfRangeConstantIndices, 165 findNonConstantInsertExtractElements(BB, OutOfRangeConstantIndices,
170 NonConstantVectorIndices); 166 NonConstantVectorIndices);
171 if (!OutOfRangeConstantIndices.empty()) { 167 if (!OutOfRangeConstantIndices.empty()) {
172 Changed = true; 168 Changed = true;
173 fixOutOfRangeConstantIndices(BB, OutOfRangeConstantIndices); 169 fixOutOfRangeConstantIndices(BB, OutOfRangeConstantIndices);
174 } 170 }
175 if (!NonConstantVectorIndices.empty()) { 171 if (!NonConstantVectorIndices.empty()) {
176 Changed = true; 172 Changed = true;
177 fixNonConstantVectorIndices(BB, NonConstantVectorIndices); 173 fixNonConstantVectorIndices(BB, NonConstantVectorIndices);
178 } 174 }
179 return Changed; 175 return Changed;
180 } 176 }
181 177
182 BasicBlockPass *llvm::createConstantInsertExtractElementIndexPass() { 178 BasicBlockPass *llvm::createConstantInsertExtractElementIndexPass() {
183 return new ConstantInsertExtractElementIndex(); 179 return new ConstantInsertExtractElementIndex();
184 } 180 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698