Commit e531750c authored by Matt Arsenault's avatar Matt Arsenault Committed by Matt Arsenault
Browse files

clang: Add -fconvergent-functions flag

The CUDA builtin library is apparently compiled in C++ mode, so the
assumption of convergent needs to be made in a typically non-SPMD
language. The functions in the library should still be assumed
convergent. Currently they are not, which is potentially incorrect and
this happens to work after the library is linked.
parent ce5de93e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -122,6 +122,7 @@ LANGOPT(WritableStrings , 1, 0, "writable string support")
LANGOPT(ConstStrings      , 1, 0, "const-qualified string support")
ENUM_LANGOPT(LaxVectorConversions, LaxVectorConversionKind, 2,
             LaxVectorConversionKind::All, "lax vector conversions")
LANGOPT(ConvergentFunctions, 1, 1, "Assume convergent functions")
LANGOPT(AltiVec           , 1, 0, "AltiVec-style vector initializers")
LANGOPT(ZVector           , 1, 0, "System z vector extensions")
LANGOPT(Exceptions        , 1, 0, "exception handling")
+1 −1
Original line number Diff line number Diff line
@@ -312,7 +312,7 @@ public:
  }

  bool assumeFunctionsAreConvergent() const {
    return (CUDA && CUDAIsDevice) || OpenCL;
    return ConvergentFunctions;
  }

  /// Return the OpenCL C or C++ version as a VersionTuple.
+3 −0
Original line number Diff line number Diff line
@@ -546,6 +546,9 @@ def cxx_isystem : JoinedOrSeparate<["-"], "cxx-isystem">, Group<clang_i_Group>,
  MetaVarName<"<directory>">;
def c : Flag<["-"], "c">, Flags<[DriverOption]>, Group<Action_Group>,
  HelpText<"Only run preprocess, compile, and assemble steps">;
def fconvergent_functions : Joined<["-"], "fconvergent-functions">, Group<f_Group>, Flags<[CC1Option]>,
  HelpText<"Assume functions may be convergent">;

def cuda_device_only : Flag<["--"], "cuda-device-only">,
  HelpText<"Compile CUDA code for device only">;
def cuda_host_only : Flag<["--"], "cuda-host-only">,
+3 −0
Original line number Diff line number Diff line
@@ -2776,6 +2776,9 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK,
  Opts.BlocksRuntimeOptional = Args.hasArg(OPT_fblocks_runtime_optional);
  Opts.Coroutines = Opts.CPlusPlus2a || Args.hasArg(OPT_fcoroutines_ts);

  Opts.ConvergentFunctions = Opts.OpenCL || (Opts.CUDA && Opts.CUDAIsDevice) ||
    Args.hasArg(OPT_fconvergent_functions);

  Opts.DoubleSquareBracketAttributes =
      Args.hasFlag(OPT_fdouble_square_bracket_attributes,
                   OPT_fno_double_square_bracket_attributes,
+8 −0
Original line number Diff line number Diff line
// RUN: %clang_cc1 -triple i386-pc-win32 -emit-llvm -fconvergent-functions -o - < %s | FileCheck -check-prefix=CONVFUNC %s
// RUN: %clang_cc1 -triple i386-pc-win32 -emit-llvm -o - < %s | FileCheck -check-prefix=NOCONVFUNC %s

// Test that the -fconvergent-functions flag works

// CONVFUNC: attributes #0 = { convergent {{.*}} }
// NOCONVFUNC-NOT: convergent
void func() { }
Loading