mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Prevent infinite loops from being optimized away.
https://github.com/llvm/llvm-project/commit/6c3129549374c0e81e28fd0a21e96f8087b63a78 adds "mustprogress" to loops, which causes empty, side-effect free loops to be optimized away. These loops are intentionally infinite for purposes of testing, so add asm statements that prevent them from being removed. PiperOrigin-RevId: 375188453
This commit is contained in:
@@ -520,13 +520,14 @@ cc_binary(
|
||||
srcs = ["concurrency.cc"],
|
||||
linkstatic = 1,
|
||||
deps = [
|
||||
"@com_google_absl//absl/strings",
|
||||
"@com_google_absl//absl/time",
|
||||
gbenchmark,
|
||||
gtest,
|
||||
"//test/util:platform_util",
|
||||
"//test/util:test_main",
|
||||
"//test/util:test_util",
|
||||
"//test/util:thread_util",
|
||||
"@com_google_absl//absl/strings",
|
||||
"@com_google_absl//absl/time",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "absl/time/clock.h"
|
||||
#include "absl/time/time.h"
|
||||
#include "benchmark/benchmark.h"
|
||||
#include "test/util/platform_util.h"
|
||||
#include "test/util/test_util.h"
|
||||
#include "test/util/thread_util.h"
|
||||
@@ -106,6 +107,8 @@ TEST(ConcurrencyTest, MultiProcessConcurrency) {
|
||||
pid_t child_pid = fork();
|
||||
if (child_pid == 0) {
|
||||
while (true) {
|
||||
int x = 0;
|
||||
benchmark::DoNotOptimize(x); // Don't optimize this loop away.
|
||||
}
|
||||
}
|
||||
ASSERT_THAT(child_pid, SyscallSucceeds());
|
||||
|
||||
Reference in New Issue
Block a user