-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CodeGenFunction] Fix emission of implicit syncs before returns for r…
…eturn statements processed early in a function.
- Loading branch information
Showing
3 changed files
with
47 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -fcilkplus -verify -ftapir=none -S -emit-llvm -o - | FileCheck %s | ||
// expected-no-diagnostics | ||
|
||
void bar(); | ||
int baz(int); | ||
|
||
void foo(int p) { | ||
while (p) { | ||
if (baz(p)) | ||
return; | ||
_Cilk_spawn bar(); | ||
--p; | ||
} | ||
bar(); | ||
} | ||
|
||
// CHECK-LABEL: define {{.*}}void @foo( | ||
|
||
// CHECK: br i1 %{{.+}}, label %[[WHILE_BODY:.+]], label %[[WHILE_END:.+]] | ||
|
||
// CHECK: [[WHILE_BODY]]: | ||
// CHECK: br i1 %{{.+}}, label %[[THEN:.+]], label %[[END:.+]] | ||
|
||
// CHECK: [[THEN]]: | ||
// CHECK-NEXT: br label %[[RETURN:.+]] | ||
|
||
// CHECK: detach within %[[SYNCREG:.+]], label %[[DETACHED:.+]], label %[[CONTINUE:.+]] | ||
|
||
// CHECK: [[DETACHED]]: | ||
// CHECK: call void {{.*}}@bar() | ||
// CHECK: reattach within %[[SYNCREG]], label %[[CONTINUE]] | ||
|
||
// CHECK: [[CONTINUE]]: | ||
// CHECK: br | ||
|
||
// CHECK: [[WHILE_END]]: | ||
// CHECK-NEXT: call void {{.*}}@bar() | ||
// CHECK-NEXT: br label %[[RETURN]] | ||
|
||
// CHECK: [[RETURN]]: | ||
// CHECK-NEXT: sync within %[[SYNCREG]] | ||
|
||
// CHECK: ret void |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters