diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-12-04 20:58:01 -0500 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-12-04 20:58:01 -0500 |
commit | c4a784e00fbcb100b47d3568522dda85c60030e8 (patch) | |
tree | a999550399f6a84563138c4713e32b458e1cbf0b /lib/Transforms | |
parent | 438a6a75d6a43677aa5184c0a1573f86087f9be7 (diff) |
remove original illegal values
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/NaCl/ExpandI64.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/Transforms/NaCl/ExpandI64.cpp b/lib/Transforms/NaCl/ExpandI64.cpp index 329bd961a7..fc449fbd6b 100644 --- a/lib/Transforms/NaCl/ExpandI64.cpp +++ b/lib/Transforms/NaCl/ExpandI64.cpp @@ -50,8 +50,9 @@ namespace { // order to expand i64 arguments to pairs of i32s. class ExpandI64 : public ModulePass { typedef std::vector<Value*> SplitParts; + typedef std::map<Instruction*, SplitParts> SplitsMap; - std::map<Value*, SplitParts> Splits; // old i64 value to new insts + SplitsMap Splits; // old i64 value to new insts // splits a 64-bit instruction into 32-bit chunks. We do // not yet have the values yet, as they depend on other @@ -124,6 +125,7 @@ void ExpandI64::SplitInst(Instruction *I, DataLayout& DL) { bool ExpandI64::runOnModule(Module &M) { bool Changed = false; DataLayout DL(&M); + // first pass - split for (Module::iterator Iter = M.begin(), E = M.end(); Iter != E; ) { Function *Func = Iter++; for (Function::iterator BB = Func->begin(), E = Func->end(); @@ -149,6 +151,15 @@ bool ExpandI64::runOnModule(Module &M) { } } } + // second pass pass - finalize and connect + if (Changed) { + // Finalize each element + + // Remove original illegal values + for (SplitsMap::iterator I = Splits.begin(); I != Splits.end(); I++) { + I->first->eraseFromParent(); + } + } return Changed; } |