[LLVMdev] About LLVM switch instruction
Mark Lacey
mark.lacey at apple.com
Wed Jul 17 21:29:18 PDT 2013
On Jul 17, 2013, at 9:01 PM, Milind Chabbi <Milind.Chabbi at rice.edu> wrote:
> I am performing a transformation that requires changing the targets of
> a basic block ending with a switch instruction.
> In particular, I need to delete the edge that goes to the "default"
> basic block.
> But, LLVM switch instruction always wants a default target basic block
> for a switch instruction.
> It is not clear how to accomplish this, since I don't have a
> replacement default target block.
> I could potentially fake that edge to be one of the other case label
> targets, but that is an ugly hack and I don't want to do that.
> I would appreciate if you can suggest better alternatives.
Hi Milind,
If you make the "default" branch to a block that has an UnreachableInst as a terminator, the SimplifyCFG pass will remove one of the switch cases and replace the block that the default branches to with the block that this removed case branches to. This sounds a lot like the "ugly hack" that you would like to avoid. Would it be a reasonable solution for what you are trying to accomplish?
Mark
More information about the llvm-dev
mailing list