[cfe-commits] r154420 - in /cfe/trunk: lib/CodeGen/CGStmt.cpp test/CodeGen/debug-line-1.c test/CodeGen/switch-dce.c
Eric Christopher
echristo at apple.com
Tue Apr 10 11:20:20 PDT 2012
Author: echristo
Date: Tue Apr 10 13:20:19 2012
New Revision: 154420
URL: http://llvm.org/viewvc/llvm-project?rev=154420&view=rev
Log:
For debug and coverage analysis if we're not optimizing go ahead
and emit a relatively empty block for a plain break statement. This
enables us to track where we went through a switch.
PR9796 & rdar://11215207
Added:
cfe/trunk/test/CodeGen/debug-line-1.c
Modified:
cfe/trunk/lib/CodeGen/CGStmt.cpp
cfe/trunk/test/CodeGen/switch-dce.c
Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=154420&r1=154419&r2=154420&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Tue Apr 10 13:20:19 2012
@@ -892,7 +892,7 @@
// If the body of the case is just a 'break', and if there was no fallthrough,
// try to not emit an empty block.
- if (isa<BreakStmt>(S.getSubStmt())) {
+ if ((CGM.getCodeGenOpts().OptimizationLevel > 0) && isa<BreakStmt>(S.getSubStmt())) {
JumpDest Block = BreakContinueStack.back().BreakBlock;
// Only do this optimization if there are no cleanups that need emitting.
Added: cfe/trunk/test/CodeGen/debug-line-1.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-line-1.c?rev=154420&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/debug-line-1.c (added)
+++ cfe/trunk/test/CodeGen/debug-line-1.c Tue Apr 10 13:20:19 2012
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple x86_64-unk-unk -o - -emit-llvm -g %s | FileCheck %s
+// PR9796
+
+// Check to make sure that we emit the block for the break so that we can count the line.
+// CHECK: sw.bb: ; preds = %entry
+// CHECK: br label %sw.epilog, !dbg !21
+
+extern int atoi(const char *);
+
+int f(char* arg) {
+ int x = atoi(arg);
+
+ switch(x) {
+ case 1:
+ break;
+ }
+
+ return 0;
+}
Modified: cfe/trunk/test/CodeGen/switch-dce.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/switch-dce.c?rev=154420&r1=154419&r2=154420&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/switch-dce.c (original)
+++ cfe/trunk/test/CodeGen/switch-dce.c Tue Apr 10 13:20:19 2012
@@ -216,32 +216,19 @@
}
}
-
-// rdar://9289524 - Check that the empty cases don't produce an empty block.
+// Verify that case 42 only calls test14 once.
// CHECK: @test13
-// CHECK: switch
-// CHECK: i32 42, label [[EPILOG:%[0-9.a-z]+]]
-// CHECK: i32 11, label [[EPILOG]]
+// CHECK: call void @test13(i32 97)
+// CHECK-NEXT: br label %[[EPILOG2:[0-9.a-z]+]]
+// CHECK: [[EPILOG2]]
+// CHECK-NEXT: br label [[EPILOG:%[0-9.a-z]+]]
+// CHECK: call void @test13(i32 42)
+// CHECK-NEXT: br label [[EPILOG]]
void test13(int x) {
switch (x) {
- case 42: break; // No empty block please.
- case 11: break; // No empty block please.
- default: test13(42); break;
- }
-}
-
-
-// Verify that case 42 only calls test14 once.
-// CHECK: @test14
-// CHECK: call void @test14(i32 97)
-// CHECK-NEXT: br label [[EPILOG2:%[0-9.a-z]+]]
-// CHECK: call void @test14(i32 42)
-// CHECK-NEXT: br label [[EPILOG2]]
-void test14(int x) {
- switch (x) {
- case 42: test14(97); // fallthrough
+ case 42: test13(97); // fallthrough
case 11: break;
- default: test14(42); break;
+ default: test13(42); break;
}
}
More information about the cfe-commits
mailing list