From 0077b22aa4d86610718531c29a378662a9fe855c Mon Sep 17 00:00:00 2001 From: John McCall Date: Tue, 5 Oct 2010 02:33:56 +0000 Subject: If we're resolving all outstanding fixups, and there are multiple fixups for the same destination, then we must potentially rewrite the initial branch of every fixup. Without this patch, a short-circuit check meant to prevent a switch case from being redundantly added was preventing later fixups from being processed. Fixes PR8175 (again). llvm-svn: 115586 --- clang/lib/CodeGen/CodeGenFunction.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp') diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 5e301b5..043195c 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -1340,11 +1340,9 @@ static void ResolveAllBranchFixups(CodeGenFunction &CGF, llvm::SmallPtrSet CasesAdded; for (unsigned I = 0, E = CGF.EHStack.getNumBranchFixups(); I != E; ++I) { - // Skip this fixup if its destination isn't set or if we've - // already treated it. + // Skip this fixup if its destination isn't set. BranchFixup &Fixup = CGF.EHStack.getBranchFixup(I); if (Fixup.Destination == 0) continue; - if (!CasesAdded.insert(Fixup.Destination)) continue; // If there isn't an OptimisticBranchBlock, then InitialBranch is // still pointing directly to its destination; forward it to the @@ -1361,6 +1359,9 @@ static void ResolveAllBranchFixups(CodeGenFunction &CGF, Fixup.InitialBranch->setSuccessor(0, CleanupEntry); } + // Don't add this case to the switch statement twice. + if (!CasesAdded.insert(Fixup.Destination)) continue; + Switch->addCase(CGF.Builder.getInt32(Fixup.DestinationIndex), Fixup.Destination); } -- cgit v1.1