Skip to content

Commit da8d60f

Browse files
authored
[docs][nfc] Fix code-formatting in UB docs (#139079)
1 parent d2fe889 commit da8d60f

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

llvm/docs/UndefinedBehavior.rst

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,12 @@ Take the following example function:
300300
entry:
301301
br label %loop
302302
303-
loop:
303+
loop:
304304
%i = phi i32 [ 0, %entry ], [ %i2, %loop.end ]
305305
%cond = icmp ule i32 %i, %n
306306
br i1 %cond, label %loop.cont, label %exit
307307
308-
loop.cont:
308+
loop.cont:
309309
br i1 %c, label %then, label %else
310310
311311
then:
@@ -334,22 +334,22 @@ We would obtain the following IR:
334334
entry:
335335
br i1 %c, label %then, label %else
336336
337-
then:
337+
then:
338338
%i = phi i32 [ 0, %entry ], [ %i2, %then.cont ]
339339
%cond = icmp ule i32 %i, %n
340340
br i1 %cond, label %then.cont, label %exit
341341
342-
then.cont:
342+
then.cont:
343343
...
344344
%i2 = add i32 %i, 1
345345
br label %then
346346
347-
else:
347+
else:
348348
%i3 = phi i32 [ 0, %entry ], [ %i4, %else.cont ]
349349
%cond = icmp ule i32 %i3, %n
350350
br i1 %cond, label %else.cont, label %exit
351351
352-
else.cont:
352+
else.cont:
353353
...
354354
%i4 = add i32 %i3, 1
355355
br label %else
@@ -381,6 +381,8 @@ We can make the loop unswitching optimization above correct as follows:
381381
entry:
382382
%c2 = freeze i1 %c
383383
br i1 %c2, label %then, label %else
384+
...
385+
}
384386
385387
386388
Writing Tests Without Undefined Behavior
@@ -399,7 +401,7 @@ particular divisor value because our optimization kicks in regardless:
399401
define i32 @fn(i8 %a) {
400402
%div = udiv i8 %a, poison
401403
...
402-
}
404+
}
403405
404406
The issue with this test is that it triggers immediate UB. This prevents
405407
verification tools like Alive from validating the correctness of the
@@ -412,7 +414,7 @@ The test above should use a dummy function argument instead of using poison:
412414
define i32 @fn(i8 %a, i8 %dummy) {
413415
%div = udiv i8 %a, %dummy
414416
...
415-
}
417+
}
416418
417419
Common sources of immediate UB in tests include branching on undef/poison
418420
conditions and dereferencing undef/poison/null pointers.

0 commit comments

Comments
 (0)