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

Side by Side Diff: lib/Transforms/NaCl/SimplifyStructRegSignatures.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 //===- SimplifyStructRegSignatures.cpp - struct regs to struct pointers----===// 1 //===- SimplifyStructRegSignatures.cpp - struct regs to struct pointers----===//
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 // This pass replaces function signatures exposing struct registers 10 // This pass replaces function signatures exposing struct registers
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "llvm/IR/Type.h" 48 #include "llvm/IR/Type.h"
49 #include "llvm/IR/Use.h" 49 #include "llvm/IR/Use.h"
50 #include "llvm/IR/User.h" 50 #include "llvm/IR/User.h"
51 #include "llvm/IR/Value.h" 51 #include "llvm/IR/Value.h"
52 #include "llvm/Pass.h" 52 #include "llvm/Pass.h"
53 #include "llvm/PassInfo.h" 53 #include "llvm/PassInfo.h"
54 #include "llvm/PassRegistry.h" 54 #include "llvm/PassRegistry.h"
55 #include "llvm/PassSupport.h" 55 #include "llvm/PassSupport.h"
56 #include "llvm/Transforms/NaCl.h" 56 #include "llvm/Transforms/NaCl.h"
57 #include "llvm/Support/Debug.h" 57 #include "llvm/Support/Debug.h"
58 #include "llvm/Support/raw_ostream.h"
58 59
59 #include <cassert> 60 #include <cassert>
60 #include <cstddef> 61 #include <cstddef>
61 62
62 using namespace llvm; 63 using namespace llvm;
63 64
64 namespace { 65 namespace {
65 66
66 static const unsigned int TypicalFuncArity = 8; 67 static const unsigned int TypicalFuncArity = 8;
67 68
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 UpdateArgNames(OldFunc, NewFunc); 472 UpdateArgNames(OldFunc, NewFunc);
472 ApplyByValAndSRet(OldFunc, NewFunc); 473 ApplyByValAndSRet(OldFunc, NewFunc);
473 474
474 NewFunc->getBasicBlockList().splice(NewFunc->begin(), 475 NewFunc->getBasicBlockList().splice(NewFunc->begin(),
475 OldFunc->getBasicBlockList()); 476 OldFunc->getBasicBlockList());
476 477
477 fixFunctionBody(Ctx, OldFunc, NewFunc); 478 fixFunctionBody(Ctx, OldFunc, NewFunc);
478 FunctionsToDelete.insert(OldFunc); 479 FunctionsToDelete.insert(OldFunc);
479 auto Found = DISubprogramMap.find(OldFunc); 480 auto Found = DISubprogramMap.find(OldFunc);
480 if (Found != DISubprogramMap.end()) 481 if (Found != DISubprogramMap.end())
481 Found->second.replaceFunction(NewFunc); 482 Found->second->replaceFunction(NewFunc);
482 } else { 483 } else {
483 AssociatedFctLoc = OldFunc; 484 AssociatedFctLoc = OldFunc;
484 } 485 }
485 scheduleInstructionsForCleanup(AssociatedFctLoc); 486 scheduleInstructionsForCleanup(AssociatedFctLoc);
486 return NewFT != OldFT; 487 return NewFT != OldFT;
487 } 488 }
488 489
489 bool SimplifyStructRegSignatures::runOnModule(Module &M) { 490 bool SimplifyStructRegSignatures::runOnModule(Module &M) {
490 bool Changed = false; 491 bool Changed = false;
491 492
492 const DataLayout *DL = M.getDataLayout();
493 unsigned PreferredAlignment = 0; 493 unsigned PreferredAlignment = 0;
494 if (DL) 494 PreferredAlignment = M.getDataLayout().getStackAlignment();
495 PreferredAlignment = DL->getStackAlignment();
496 495
497 LLVMContext &Ctx = M.getContext(); 496 LLVMContext &Ctx = M.getContext();
498 auto DISubprogramMap = makeSubprogramMap(M); 497 auto DISubprogramMap = makeSubprogramMap(M);
499 498
500 // Change function signatures and fix a changed function body by 499 // Change function signatures and fix a changed function body by
501 // wiring the new arguments. Call sites are unchanged at this point. 500 // wiring the new arguments. Call sites are unchanged at this point.
502 for (Module::iterator Iter = M.begin(), E = M.end(); Iter != E;) { 501 for (Module::iterator Iter = M.begin(), E = M.end(); Iter != E;) {
503 Function *Func = Iter++; 502 Function *Func = Iter++;
504 checkNoUnsupportedInstructions(Ctx, Func); 503 checkNoUnsupportedInstructions(Ctx, Func);
505 Changed |= simplifyFunction(Ctx, Func, DISubprogramMap); 504 Changed |= simplifyFunction(Ctx, Func, DISubprogramMap);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 errs() << *Resume << '\n'; 538 errs() << *Resume << '\n';
540 report_fatal_error( 539 report_fatal_error(
541 "Resumes with aggregate register signatures are not supported."); 540 "Resumes with aggregate register signatures are not supported.");
542 } 541 }
543 } 542 }
544 } 543 }
545 544
546 ModulePass *llvm::createSimplifyStructRegSignaturesPass() { 545 ModulePass *llvm::createSimplifyStructRegSignaturesPass() {
547 return new SimplifyStructRegSignatures(); 546 return new SimplifyStructRegSignatures();
548 } 547 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698