private HashMap<Block, HashSet<Integer>> calculateGlobalLiveSpan(ArrayList<Block> leafnodes) {

		HashSet<Block> allBlocks = new HashSet<Block>();
		Queue<AbstractMap.SimpleEntry<Block, HashSet<Integer>>> queue = new LinkedList<AbstractMap.SimpleEntry<Block, HashSet<Integer>>>();
		for (Block node : leafnodes) {
			queue.add(new AbstractMap.SimpleEntry<Block, HashSet<Integer>>(node,
					new HashSet<Integer>()));
		}

		while (!queue.isEmpty()) {
			SimpleEntry<Block, HashSet<Integer>> entry = queue.remove();
			Block blk = entry.getKey();
			HashSet<Integer> liveness = entry.getValue();
			if (!allBlocks.contains(blk)) {
				blk.calculateLocalLiveness();

				allBlocks.add(blk);
			}
			SimpleEntry<HashSet<Integer>, Boolean> status = blk.pushUpLiveness(liveness);
			liveness = status.getKey();
			if (status.getValue()) { // the liveness changed,
				for (Block predecessor : blk.getPredecessors()) {
					queue.add(new AbstractMap.SimpleEntry<Block, HashSet<Integer>>(predecessor, blk
							.chooseCorrectPushupPhi(predecessor, liveness)));
				}
			} else {
				// if not yet visited
				for (Block predecessor : blk.getPredecessors()) {
					if (!allBlocks.contains(predecessor)) {
						queue.add(new AbstractMap.SimpleEntry<Block, HashSet<Integer>>(predecessor,
								blk.chooseCorrectPushupPhi(predecessor, liveness)));
					}
				}
			}
		}

		HashMap<Block, HashSet<Integer>> globalLiveSpan = new HashMap<Block, HashSet<Integer>>();
		for (Block blk : allBlocks) {
			globalLiveSpan.put(blk, blk.getUsefullVar());
		}
		return globalLiveSpan;
	}