Skip to content

Instantly share code, notes, and snippets.

@nomaddo
Created August 31, 2018 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nomaddo/ad5a54e5b6672d512ac4deb48c18d92c to your computer and use it in GitHub Desktop.
Save nomaddo/ad5a54e5b6672d512ac4deb48c18d92c to your computer and use it in GitHub Desktop.
/* clang-6 -O1 -S -emit-llvm
extern int f(int);
int g(int in)
{
int x = 0;
switch(in)
{
case 0:
x += f(in);
case 1:
x += 34;
case 2:
return in;
}
return f(x);
}
*/
define i32 @g(i32) local_unnamed_addr #0 {
switch i32 %0, label %4 [
i32 0, label %2
i32 1, label %6
i32 2, label %6
]
; <label>:2: ; preds = %1
%3 = tail call i32 @f(i32 %0) #2
br label %6
; <label>:4: ; preds = %1
%5 = tail call i32 @f(i32 0) #2
br label %6
; <label>:6: ; preds = %1, %1, %2, %4
%7 = phi i32 [ %5, %4 ], [ 0, %2 ], [ %0, %1 ], [ %0, %1 ]
ret i32 %7
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment