diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-02-14 14:51:06 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-02-14 14:51:06 -0800 |
commit | b3d5de7043272a13341ea7ae0ac176a5782f13a7 (patch) | |
tree | 4f9c9aeab4d4b8aa07a6428e21ceb89552c46d37 /lib/Target/JSBackend/SimplifyAllocas.cpp | |
parent | 9c0197b97dc9b5be2132f8e6ebe9737d0d7dd7c1 (diff) | |
parent | 8dd47ed0fe367f1d6c0f7cb404d58b24be8b6f5c (diff) |
Merge pull request #14 from sunfishcode/incoming
Instead of lowering pointers, teach the JSBackend how to handle them
Diffstat (limited to 'lib/Target/JSBackend/SimplifyAllocas.cpp')
-rw-r--r-- | lib/Target/JSBackend/SimplifyAllocas.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/Target/JSBackend/SimplifyAllocas.cpp b/lib/Target/JSBackend/SimplifyAllocas.cpp index 2fda6be948..858ded32a1 100644 --- a/lib/Target/JSBackend/SimplifyAllocas.cpp +++ b/lib/Target/JSBackend/SimplifyAllocas.cpp @@ -72,12 +72,11 @@ bool SimplifyAllocas::runOnFunction(Function &Func) { } std::vector<Instruction*> Aliases; // the bitcasts of this alloca for (Instruction::use_iterator UI = AI->use_begin(), UE = AI->use_end(); UI != UE && !Fail; ++UI) { - Instruction *U = dyn_cast<Instruction>(*UI); - if (!U || U->getOpcode() != Instruction::BitCast) { Fail = true; break; } + Instruction *U = cast<Instruction>(*UI); + if (U->getOpcode() != Instruction::BitCast) { Fail = true; break; } // bitcasting just to do loads and stores is ok for (Instruction::use_iterator BUI = U->use_begin(), BUE = U->use_end(); BUI != BUE && !Fail; ++BUI) { - Instruction *BU = dyn_cast<Instruction>(*BUI); - if (!BU) { Fail = true; break; } + Instruction *BU = cast<Instruction>(*BUI); if (BU->getOpcode() == Instruction::Load) { CHECK_TYPE(BU->getType()); break; @@ -88,7 +87,7 @@ bool SimplifyAllocas::runOnFunction(Function &Func) { } if (!Fail) Aliases.push_back(U); } - if (!Fail && Aliases.size() > 0) { + if (!Fail && Aliases.size() > 0 && ActualType) { // success, replace the alloca and the bitcast aliases with a single simple alloca AllocaInst *NA = new AllocaInst(ActualType, ConstantInt::get(i32, 1), "", I); NA->takeName(AI); |