@@ -4741,7 +4741,12 @@ control flow, not values (the one exception being the
4741
4741
The terminator instructions are: ':ref: `ret <i_ret >`',
4742
4742
':ref: `br <i_br >`', ':ref: `switch <i_switch >`',
4743
4743
':ref: `indirectbr <i_indirectbr >`', ':ref: `invoke <i_invoke >`',
4744
- ':ref: `resume <i_resume >`', and ':ref: `unreachable <i_unreachable >`'.
4744
+ ':ref: `resume <i_resume >`', ':ref: `catchpad <i_catchpad >`',
4745
+ ':ref: `catchendpad <i_catchendpad >`',
4746
+ ':ref: `catchret <i_catchret >`',
4747
+ ':ref: `cleanupret <i_cleanupret >`',
4748
+ ':ref: `terminatepad <i_terminatepad >`',
4749
+ and ':ref: `unreachable <i_unreachable >`'.
4745
4750
4746
4751
.. _i_ret :
4747
4752
@@ -5095,6 +5100,301 @@ Example:
5095
5100
5096
5101
resume { i8*, i32 } %exn
5097
5102
5103
+ .. _i_catchpad :
5104
+
5105
+ '``catchpad ``' Instruction
5106
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5107
+
5108
+ Syntax:
5109
+ """""""
5110
+
5111
+ ::
5112
+
5113
+ <resultval> = catchpad <resultty> [<args>*]
5114
+ to label <normal label> unwind label <exception label>
5115
+
5116
+ Overview:
5117
+ """""""""
5118
+
5119
+ The '``catchpad ``' instruction is used by `LLVM's exception handling
5120
+ system <ExceptionHandling.html#overview> `_ to specify that a basic block
5121
+ is a catch block --- one where a personality routine attempts to transfer
5122
+ control to catch an exception.
5123
+ The ``args `` correspond to whatever information the personality
5124
+ routine requires to know if this is an appropriate place to catch the
5125
+ exception. Control is tranfered to the ``exception `` label if the
5126
+ ``catchpad `` is not an appropriate handler for the in-flight exception.
5127
+ The ``normal `` label should contain the code found in the ``catch ``
5128
+ portion of a ``try ``/``catch `` sequence. It defines values supplied by
5129
+ the :ref: `personality function <personalityfn >` upon re-entry to the
5130
+ function. The ``resultval `` has the type ``resultty ``.
5131
+
5132
+ Arguments:
5133
+ """"""""""
5134
+
5135
+ The instruction takes a list of arbitrary values which are interpreted
5136
+ by the :ref: `personality function <personalityfn >`.
5137
+
5138
+ The ``catchpad `` must be provided a ``normal `` label to transfer control
5139
+ to if the ``catchpad `` matches the exception and an ``exception ``
5140
+ label to transfer control to if it doesn't.
5141
+
5142
+ Semantics:
5143
+ """"""""""
5144
+
5145
+ The '``catchpad ``' instruction defines the values which are set by the
5146
+ :ref: `personality function <personalityfn >` upon re-entry to the function, and
5147
+ therefore the "result type" of the ``catchpad `` instruction. As with
5148
+ calling conventions, how the personality function results are
5149
+ represented in LLVM IR is target specific.
5150
+
5151
+ When the call stack is being unwound due to an exception being thrown,
5152
+ the exception is compared against the ``args ``. If it doesn't match,
5153
+ then control is transfered to the ``exception `` basic block.
5154
+
5155
+ The ``catchpad `` instruction has several restrictions:
5156
+
5157
+ - A catch block is a basic block which is the unwind destination of
5158
+ an exceptional instruction.
5159
+ - A catch block must have a '``catchpad ``' instruction as its
5160
+ first non-PHI instruction.
5161
+ - A catch block's ``exception `` edge must refer to a catch block or a
5162
+ catch-end block.
5163
+ - There can be only one '``catchpad ``' instruction within the
5164
+ catch block.
5165
+ - A basic block that is not a catch block may not include a
5166
+ '``catchpad ``' instruction.
5167
+ - It is undefined behavior for control to transfer from a ``catchpad `` to a
5168
+ ``cleanupret `` without first executing a ``catchret `` and a subsequent
5169
+ ``cleanuppad ``.
5170
+ - It is undefined behavior for control to transfer from a ``catchpad `` to a
5171
+ ``ret `` without first executing a ``catchret ``.
5172
+
5173
+ Example:
5174
+ """"""""
5175
+
5176
+ .. code-block :: llvm
5177
+
5178
+ ;; A catch block which can catch an integer.
5179
+ %res = catchpad { i8*, i32 } [i8** @_ZTIi]
5180
+ to label %int.handler unwind label %terminate
5181
+
5182
+ .. _i_catchendpad :
5183
+
5184
+ '``catchendpad ``' Instruction
5185
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5186
+
5187
+ Syntax:
5188
+ """""""
5189
+
5190
+ ::
5191
+
5192
+ catchendpad unwind label <nextaction>
5193
+ catchendpad unwind to caller
5194
+
5195
+ Overview:
5196
+ """""""""
5197
+
5198
+ The '``catchendpad ``' instruction is used by `LLVM's exception handling
5199
+ system <ExceptionHandling.html#overview> `_ to communicate to the
5200
+ :ref: `personality function <personalityfn >` which invokes are associated
5201
+ with a chain of :ref: `catchpad <i_catchpad >` instructions.
5202
+
5203
+ The ``nextaction `` label indicates where control should transfer to if
5204
+ none of the ``catchpad `` instructions are suitable for catching the
5205
+ in-flight exception.
5206
+
5207
+ If a ``nextaction `` label is not present, the instruction unwinds out of
5208
+ its parent function. The
5209
+ :ref: `personality function <personalityfn >` will continue processing
5210
+ exception handling actions in the caller.
5211
+
5212
+ Arguments:
5213
+ """"""""""
5214
+
5215
+ The instruction optionally takes a label, ``nextaction ``, indicating
5216
+ where control should transfer to if none of the preceding
5217
+ ``catchpad `` instructions are suitable for the in-flight exception.
5218
+
5219
+ Semantics:
5220
+ """"""""""
5221
+
5222
+ When the call stack is being unwound due to an exception being thrown
5223
+ and none of the constituent ``catchpad `` instructions match, then
5224
+ control is transfered to ``nextaction `` if it is present. If it is not
5225
+ present, control is transfered to the caller.
5226
+
5227
+ The ``catchendpad `` instruction has several restrictions:
5228
+
5229
+ - A catch-end block is a basic block which is the unwind destination of
5230
+ an exceptional instruction.
5231
+ - A catch-end block must have a '``catchendpad ``' instruction as its
5232
+ first non-PHI instruction.
5233
+ - There can be only one '``catchendpad ``' instruction within the
5234
+ catch block.
5235
+ - A basic block that is not a catch-end block may not include a
5236
+ '``catchendpad ``' instruction.
5237
+ - Exactly one catch block may unwind to a ``catchendpad ``.
5238
+ - The unwind target of invokes between a ``catchpad `` and a
5239
+ corresponding ``catchret `` must be its ``catchendpad ``.
5240
+
5241
+ Example:
5242
+ """"""""
5243
+
5244
+ .. code-block :: llvm
5245
+
5246
+ catchendpad unwind label %terminate
5247
+ catchendpad unwind to caller
5248
+
5249
+ .. _i_catchret :
5250
+
5251
+ '``catchret ``' Instruction
5252
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^
5253
+
5254
+ Syntax:
5255
+ """""""
5256
+
5257
+ ::
5258
+
5259
+ catchret label <normal>
5260
+
5261
+ Overview:
5262
+ """""""""
5263
+
5264
+ The '``catchret ``' instruction is a terminator instruction that has a
5265
+ single successor.
5266
+
5267
+
5268
+ Arguments:
5269
+ """"""""""
5270
+
5271
+ The '``catchret ``' instruction requires one argument which specifies
5272
+ where control will transfer to next.
5273
+
5274
+ Semantics:
5275
+ """"""""""
5276
+
5277
+ The '``catchret ``' instruction ends the existing (in-flight) exception
5278
+ whose unwinding was interrupted with a
5279
+ :ref: `catchpad <i_catchpad >` instruction.
5280
+ The :ref: `personality function <personalityfn >` gets a chance to execute
5281
+ arbitrary code to, for example, run a C++ destructor.
5282
+ Control then transfers to ``normal ``.
5283
+
5284
+ Example:
5285
+ """"""""
5286
+
5287
+ .. code-block :: llvm
5288
+
5289
+ catchret label %continue
5290
+
5291
+ .. _i_cleanupret :
5292
+
5293
+ '``cleanupret ``' Instruction
5294
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5295
+
5296
+ Syntax:
5297
+ """""""
5298
+
5299
+ ::
5300
+
5301
+ cleanupret <type> <value> unwind label <continue>
5302
+ cleanupret <type> <value> unwind to caller
5303
+
5304
+ Overview:
5305
+ """""""""
5306
+
5307
+ The '``cleanupret ``' instruction is a terminator instruction that has
5308
+ an optional successor.
5309
+
5310
+
5311
+ Arguments:
5312
+ """"""""""
5313
+
5314
+ The '``cleanupret ``' instruction requires one argument, which must have the
5315
+ same type as the result of any '``cleanuppad ``' instruction in the same
5316
+ function. It also has an optional successor, ``continue ``.
5317
+
5318
+ Semantics:
5319
+ """"""""""
5320
+
5321
+ The '``cleanupret ``' instruction indicates to the
5322
+ :ref: `personality function <personalityfn >` that one
5323
+ :ref: `cleanuppad <i_cleanuppad >` it transferred control to has ended.
5324
+ It transfers control to ``continue `` or unwinds out of the function.
5325
+
5326
+ Example:
5327
+ """"""""
5328
+
5329
+ .. code-block :: llvm
5330
+
5331
+ cleanupret void unwind to caller
5332
+ cleanupret { i8*, i32 } %exn unwind label %continue
5333
+
5334
+ .. _i_terminatepad :
5335
+
5336
+ '``terminatepad ``' Instruction
5337
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5338
+
5339
+ Syntax:
5340
+ """""""
5341
+
5342
+ ::
5343
+
5344
+ terminatepad [<args>*] unwind label <exception label>
5345
+ terminatepad [<args>*] unwind to caller
5346
+
5347
+ Overview:
5348
+ """""""""
5349
+
5350
+ The '``terminatepad ``' instruction is used by `LLVM's exception handling
5351
+ system <ExceptionHandling.html#overview> `_ to specify that a basic block
5352
+ is a terminate block --- one where a personality routine may decide to
5353
+ terminate the program.
5354
+ The ``args `` correspond to whatever information the personality
5355
+ routine requires to know if this is an appropriate place to terminate the
5356
+ program. Control is transferred to the ``exception `` label if the
5357
+ personality routine decides not to terminate the program for the
5358
+ in-flight exception.
5359
+
5360
+ Arguments:
5361
+ """"""""""
5362
+
5363
+ The instruction takes a list of arbitrary values which are interpreted
5364
+ by the :ref: `personality function <personalityfn >`.
5365
+
5366
+ The ``terminatepad `` may be given an ``exception `` label to
5367
+ transfer control to if the in-flight exception matches the ``args ``.
5368
+
5369
+ Semantics:
5370
+ """"""""""
5371
+
5372
+ When the call stack is being unwound due to an exception being thrown,
5373
+ the exception is compared against the ``args ``. If it matches,
5374
+ then control is transfered to the ``exception `` basic block. Otherwise,
5375
+ the program is terminated via personality-specific means. Typically,
5376
+ the first argument to ``terminatepad `` specifies what function the
5377
+ personality should defer to in order to terminate the program.
5378
+
5379
+ The ``terminatepad `` instruction has several restrictions:
5380
+
5381
+ - A terminate block is a basic block which is the unwind destination of
5382
+ an exceptional instruction.
5383
+ - A terminate block must have a '``terminatepad ``' instruction as its
5384
+ first non-PHI instruction.
5385
+ - There can be only one '``terminatepad ``' instruction within the
5386
+ terminate block.
5387
+ - A basic block that is not a terminate block may not include a
5388
+ '``terminatepad ``' instruction.
5389
+
5390
+ Example:
5391
+ """"""""
5392
+
5393
+ .. code-block :: llvm
5394
+
5395
+ ;; A terminate block which only permits integers.
5396
+ terminatepad [i8** @_ZTIi] unwind label %continue
5397
+
5098
5398
.. _i_unreachable :
5099
5399
5100
5400
'``unreachable ``' Instruction
@@ -8052,6 +8352,72 @@ Example:
8052
8352
catch i8** @_ZTIi
8053
8353
filter [1 x i8**] [@_ZTId]
8054
8354
8355
+ .. _i_cleanuppad :
8356
+
8357
+ '``cleanuppad ``' Instruction
8358
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8359
+
8360
+ Syntax:
8361
+ """""""
8362
+
8363
+ ::
8364
+
8365
+ <resultval> = cleanuppad <resultty> [<args>*]
8366
+
8367
+ Overview:
8368
+ """""""""
8369
+
8370
+ The '``cleanuppad ``' instruction is used by `LLVM's exception handling
8371
+ system <ExceptionHandling.html#overview> `_ to specify that a basic block
8372
+ is a cleanup block --- one where a personality routine attempts to
8373
+ transfer control to run cleanup actions.
8374
+ The ``args `` correspond to whatever additional
8375
+ information the :ref: `personality function <personalityfn >` requires to
8376
+ execute the cleanup.
8377
+ The ``resultval `` has the type ``resultty ``.
8378
+
8379
+ Arguments:
8380
+ """"""""""
8381
+
8382
+ The instruction takes a list of arbitrary values which are interpreted
8383
+ by the :ref: `personality function <personalityfn >`.
8384
+
8385
+ Semantics:
8386
+ """"""""""
8387
+
8388
+ The '``cleanuppad ``' instruction defines the values which are set by the
8389
+ :ref: `personality function <personalityfn >` upon re-entry to the function, and
8390
+ therefore the "result type" of the ``cleanuppad `` instruction. As with
8391
+ calling conventions, how the personality function results are
8392
+ represented in LLVM IR is target specific.
8393
+
8394
+ When the call stack is being unwound due to an exception being thrown,
8395
+ the :ref: `personality function <personalityfn >` transfers control to the
8396
+ ``cleanuppad `` with the aid of the personality-specific arguments.
8397
+
8398
+ The ``cleanuppad `` instruction has several restrictions:
8399
+
8400
+ - A cleanup block is a basic block which is the unwind destination of
8401
+ an exceptional instruction.
8402
+ - A cleanup block must have a '``cleanuppad ``' instruction as its
8403
+ first non-PHI instruction.
8404
+ - There can be only one '``cleanuppad ``' instruction within the
8405
+ cleanup block.
8406
+ - A basic block that is not a cleanup block may not include a
8407
+ '``cleanuppad ``' instruction.
8408
+ - It is undefined behavior for control to transfer from a ``cleanuppad `` to a
8409
+ ``catchret `` without first executing a ``cleanupret `` and a subsequent
8410
+ ``catchpad ``.
8411
+ - It is undefined behavior for control to transfer from a ``cleanuppad `` to a
8412
+ ``ret `` without first executing a ``cleanupret ``.
8413
+
8414
+ Example:
8415
+ """"""""
8416
+
8417
+ .. code-block :: llvm
8418
+
8419
+ %res = cleanuppad { i8*, i32 } [label %nextaction]
8420
+
8055
8421
.. _intrinsics :
8056
8422
8057
8423
Intrinsic Functions
0 commit comments