brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · a5eb3c2 Raw
45 lines · cpp
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9// Check that the condition register is restored properly during unwinding10// on AIX. Option -O3 is required so that the compiler will re-use the value11// in the condition register instead of re-evaluating the condition expression.12 13// REQUIRES: target={{.+}}-aix{{.*}}14// ADDITIONAL_COMPILE_FLAGS: -O315// UNSUPPORTED: no-exceptions16 17#include <cstdlib>18#include <cassert>19 20int __attribute__((noinline)) test2(int i) {21  // The inline assembly forces the prologue/epilogue to save/restore the22  // condition register.23  asm volatile("nop" : : : "cr2");24  if (i > 3) {25    throw i;26  }27  srand(i);28  return rand() + i;29}30 31void __attribute__((noinline)) test(int argc, const char **argv) {32  int a = atoi(argv[1]);33  int b = atoi(argv[2]);34  try {35    test2(a < b ? argc : b);36  } catch (int num) {37    assert(!(a < b));38  }39}40int main(int, char**) {41  const char *av[]={"a.out", "12", "10"};42  test(4, av);43  return 0;44}45