[PATCH] D108657: [CodeExtractor] Ensuring ordering of exitStub creation

Andrew Litteken via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 24 14:00:11 PDT 2021


AndrewLitteken added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/CodeExtractor.cpp:1268
+
+    Value *brVal = nullptr;
+    switch (NumExitBlocks) {
----------------
jroelofs wrote:
> Should there be an assert:
> 
> ```
> assert(NumExitBlocks < 0xffff && "too many exit blocks for switch");
> ```
> 
> or do you think that's too unlikely to matter?
I think it's pretty unlikely that there will ever by that many exits out of a function.


================
Comment at: llvm/lib/Transforms/Utils/CodeExtractor.cpp:1283
+    // Update the switch instruction.
+    TheSwitch->addCase(ConstantInt::get(Type::getInt16Ty(Context),
+                                        SuccNum),
----------------
jroelofs wrote:
> Doesn't the switch need the same type as the cases, or am I misunderstanding what's going on here?
They do, but if there are only two exit blocks, there are only two options, a 0 and 1, returned out of the outlined function.  If that's the case, the CodeExtractor simplifies this to a branch instruction anyway.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108657



More information about the llvm-commits mailing list