[PATCH] D104849: [SimplifyCFG] Tail-merging all blocks with `resume` terminator

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 24 10:13:20 PDT 2021


rnk added inline comments.


================
Comment at: llvm/test/Transforms/SimplifyCFG/tail-merge-resume.ll:28
+; CHECK:       common.resume:
+; CHECK-NEXT:    [[COMMON_RESUME_OP:%.*]] = phi { i8*, i32 } [ [[LP2:%.*]], [[LPAD2]] ], [ [[LP]], [[RESUME0]] ], [ [[LP]], [[RESUME1]] ]
+; CHECK-NEXT:    resume { i8*, i32 } [[COMMON_RESUME_OP]]
----------------
I thought PHIs of structs were considered non-canonical, but it looks like LLVM creates them in this C++ example:
```
$ cat t.cpp
struct Cleanup {
  ~Cleanup();
};
void maythrow();
void resumeFromPhi() {
  Cleanup a;
  maythrow();
  Cleanup b;
  maythrow();
}

$ clang -S t.cpp  -o - -emit-llvm -O2 | grep phi
  %.pn = phi { i8*, i32 } [ %3, %lpad1 ], [ %2, %lpad ]
```

We should be OK then.


================
Comment at: llvm/test/Transforms/SimplifyCFG/tail-merge-resume.ll:67
   call void @quux()
   resume { i8*, i32 } %lp
 }
----------------
I think it's worth adding an extra block where the resume has a phi operand. That is the dominant pattern coming from clang, so it's important to show that simplifycfg can take a standalone resume block and merge it in.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104849/new/

https://reviews.llvm.org/D104849



More information about the llvm-commits mailing list