diff options
| author | Johannes Doerfert <johannes@jdoerfert.de> | 2019-11-01 13:57:49 -0500 |
|---|---|---|
| committer | Johannes Doerfert <johannes@jdoerfert.de> | 2019-11-02 00:30:31 -0500 |
| commit | ed47a9cde4f667058ac34ef7805fc4093a5a4f7b (patch) | |
| tree | 6ce601fdbd4ea4a8388485968ad6bfa5c5458248 /llvm/test/Transforms | |
| parent | 15cd90a2c44aacbab1fe8682b8c07101ccffb9c4 (diff) | |
| download | bcm5719-llvm-ed47a9cde4f667058ac34ef7805fc4093a5a4f7b.tar.gz bcm5719-llvm-ed47a9cde4f667058ac34ef7805fc4093a5a4f7b.zip | |
[Attributor][FIX] Handle the default case of a switch
In D69605 only the "cases" of a switch were handled but if none matched
we did not make the default case life. This is fixed now and properly
tested (with code from IPConstantProp/user-with-multiple-uses.ll).
Diffstat (limited to 'llvm/test/Transforms')
| -rw-r--r-- | llvm/test/Transforms/FunctionAttrs/liveness.ll | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/llvm/test/Transforms/FunctionAttrs/liveness.ll b/llvm/test/Transforms/FunctionAttrs/liveness.ll index 85afb10ca08..2526d65bbf5 100644 --- a/llvm/test/Transforms/FunctionAttrs/liveness.ll +++ b/llvm/test/Transforms/FunctionAttrs/liveness.ll @@ -1,5 +1,6 @@ -; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes ; RUN: opt -attributor --attributor-disable=false -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=6 -S < %s | FileCheck %s +; UTC_ARGS: --turn off declare void @no_return_call() nofree noreturn nounwind readnone @@ -748,3 +749,43 @@ define void @useless_arg_ext_int_ext(i32* %a) { call void @useless_arg_ext_int(i32* %a) ret void } + +; UTC_ARGS: --turn on + +; FIXME: We should fold terminators. + +define internal i32 @switch_default(i64 %i) nounwind { +; CHECK-LABEL: define {{[^@]+}}@switch_default +; CHECK-SAME: (i64 [[I:%.*]]) +; CHECK-NEXT: entry: +; CHECK-NEXT: switch i64 0, label [[SW_DEFAULT:%.*]] [ +; CHECK-NEXT: i64 3, label [[RETURN:%.*]] +; CHECK-NEXT: i64 10, label [[RETURN]] +; CHECK-NEXT: ] +; CHECK: sw.default: +; CHECK-NEXT: ret i32 123 +; CHECK: return: +; CHECK-NEXT: unreachable +; +entry: + switch i64 %i, label %sw.default [ + i64 3, label %return + i64 10, label %return + ] + +sw.default: + ret i32 123 + +return: + ret i32 0 +} + +define i32 @switch_default_caller() { +; CHECK-LABEL: define {{[^@]+}}@switch_default_caller() +; CHECK-NEXT: [[CALL2:%.*]] = tail call i32 @switch_default(i64 0) +; CHECK-NEXT: ret i32 123 +; + %call2 = tail call i32 @switch_default(i64 0) + ret i32 %call2 +} +; UTC_ARGS: --turn off |

