From 7d0b1d77b3d4d47df477519fd1bf099b3df6f899 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Tue, 12 Nov 2019 14:06:12 +0000 Subject: [Examples] Add IRTransformations directory to examples. This patch adds a new IRTransformations directory to llvm/examples/. This is intended to serve as a new home for example transformations/analysis code used by various tutorials. If LLVM_BUILD_EXAMPLES is enabled, the ExamplesIRTransforms library is linked into the opt binary and the example passes become available. To start off with, it contains the CFG simplifications used in the IR part of the 'Getting Started With LLVM: Basics' tutorial at the US LLVM Developers Meeting 2019. Reviewers: paquette, jfb, meikeb, lhames, kbarton Reviewed By: paquette Differential Revision: https://reviews.llvm.org/D69416 --- .../tut-simplify-cfg6-dead-self-loop.ll | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 llvm/test/Examples/IRTransforms/SimplifyCFG/tut-simplify-cfg6-dead-self-loop.ll (limited to 'llvm/test/Examples/IRTransforms/SimplifyCFG/tut-simplify-cfg6-dead-self-loop.ll') diff --git a/llvm/test/Examples/IRTransforms/SimplifyCFG/tut-simplify-cfg6-dead-self-loop.ll b/llvm/test/Examples/IRTransforms/SimplifyCFG/tut-simplify-cfg6-dead-self-loop.ll new file mode 100644 index 00000000000..f9705a6948b --- /dev/null +++ b/llvm/test/Examples/IRTransforms/SimplifyCFG/tut-simplify-cfg6-dead-self-loop.ll @@ -0,0 +1,25 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt -tut-simplifycfg -tut-simplifycfg-version=v1 -S < %s | FileCheck %s +; RUN: opt -tut-simplifycfg -tut-simplifycfg-version=v2 -S < %s | FileCheck %s +; RUN: opt -tut-simplifycfg -tut-simplifycfg-version=v3 -S < %s | FileCheck %s + +define i32 @simp1() { +; CHECK-LABEL: @simp1( +; CHECK-NEXT: entry: +; CHECK-NEXT: ret i32 1 +; CHECK: bb.1: +; CHECK-NEXT: br label [[BB_1:%.*]] +; CHECK: bb.2: +; CHECK-NEXT: [[P:%.*]] = phi i32 [ 0, [[BB_2:%.*]] ] +; CHECK-NEXT: br label [[BB_2]] +; +entry: + ret i32 1 + +bb.1: + br label %bb.1 + +bb.2: + %p = phi i32 [ 0, %bb.2] + br label %bb.2 +} -- cgit v1.2.3