Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Not Working:
- BB0:
- // %31 = phi i32* [ %.pre.i, %land.lhs.true.cleanup_crit_edge.i ], [ %26, %lor.lhs.false.i ]
- BB1:
- // %33 = call i32 (...) @register_trav_edge1(i32* %.pre.i, i32* %31, i32 1, i32 16)
- Working:
- // %31 = phi i32* [ %.pre.i, %land.lhs.true.cleanup_crit_edge.i ], [ %26, %lor.lhs.false.i ]
- // %33 = call i32 (...) @register_trav_edge1(i32* %.pre.i, i32* %31, i32 1, i32 16)
- bool isUsedInPhiInCurrentBB(llvm::Instruction * instr, llvm::PHINode * phi) {
- for (auto &I : *(instr->getParent())) {
- if (llvm::PHINode * bb_phi = dyn_cast<llvm::PHINode>(&I)) {
- for (int i = 0; i < bb_phi->getNumIncomingValues(); ++i) {
- if (bb_phi->getIncomingValue(i) == dyn_cast<llvm::Value>(instr)) {
- phi = bb_phi;
- return true;
- }
- }
- }
- else {
- break;
- }
- }
- return false;
- }
- int main() {
- llvm::PHINode * phi_source;
- if (llvm::Instruction * instr = dyn_cast<llvm::Instruction>(gdi.source)) {
- if (!dyn_cast<llvm::PHINode>(gdi.source)) {
- if (isUsedInPhiInCurrentBB(instr,phi_source)) {
- gdi.source = dyn_cast<llvm::Value>(phi_source);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement