[llvm-branch-commits] [cfe-branch] r276985 - Merging r276350:
Hans Wennborg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Jul 28 08:18:15 PDT 2016
Author: hans
Date: Thu Jul 28 10:18:14 2016
New Revision: 276985
URL: http://llvm.org/viewvc/llvm-project?rev=276985&view=rev
Log:
Merging r276350:
------------------------------------------------------------------------
r276350 | epilk | 2016-07-21 15:31:40 -0700 (Thu, 21 Jul 2016) | 3 lines
[CodeGen] Fix a crash when constant folding switch statement
Differential revision: https://reviews.llvm.org/D22542
------------------------------------------------------------------------
Modified:
cfe/branches/release_39/ (props changed)
cfe/branches/release_39/lib/CodeGen/CGStmt.cpp
cfe/branches/release_39/test/CodeGenCXX/switch-case-folding-2.cpp
Propchange: cfe/branches/release_39/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jul 28 10:18:14 2016
@@ -1,4 +1,4 @@
/cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:275880,275967,276361,276473,276716,276887,276891
+/cfe/trunk:275880,275967,276350,276361,276473,276716,276887,276891
/cfe/trunk/test:170344
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/release_39/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/lib/CodeGen/CGStmt.cpp?rev=276985&r1=276984&r2=276985&view=diff
==============================================================================
--- cfe/branches/release_39/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/branches/release_39/lib/CodeGen/CGStmt.cpp Thu Jul 28 10:18:14 2016
@@ -1249,6 +1249,14 @@ void CodeGenFunction::EmitCaseStmt(const
}
void CodeGenFunction::EmitDefaultStmt(const DefaultStmt &S) {
+ // If there is no enclosing switch instance that we're aware of, then this
+ // default statement can be elided. This situation only happens when we've
+ // constant-folded the switch.
+ if (!SwitchInsn) {
+ EmitStmt(S.getSubStmt());
+ return;
+ }
+
llvm::BasicBlock *DefaultBlock = SwitchInsn->getDefaultDest();
assert(DefaultBlock->empty() &&
"EmitDefaultStmt: Default block already defined?");
Modified: cfe/branches/release_39/test/CodeGenCXX/switch-case-folding-2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_39/test/CodeGenCXX/switch-case-folding-2.cpp?rev=276985&r1=276984&r2=276985&view=diff
==============================================================================
--- cfe/branches/release_39/test/CodeGenCXX/switch-case-folding-2.cpp (original)
+++ cfe/branches/release_39/test/CodeGenCXX/switch-case-folding-2.cpp Thu Jul 28 10:18:14 2016
@@ -18,4 +18,13 @@ int main(void) {
return test(5);
}
+void other_test() {
+ switch(0) {
+ case 0:
+ do {
+ default:;
+ } while(0);
+ }
+}
+
// CHECK: call i32 (i8*, ...) @_Z6printfPKcz
More information about the llvm-branch-commits
mailing list