[PATCH] D69498: IR: Invert convergent attribute handling

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 27 19:27:07 PDT 2019


arsenm created this revision.
arsenm added reviewers: jlebar, tra, yaxunl, jdoerfert, nhaehnle, resistor, bogner, chandlerc, Anastasia, rjmccall, aaron.ballman.
Herald added subscribers: jsji, jfb, dexonsmith, steven_wu, atanasyan, zzheng, kbarton, aheejin, hiraditya, sbc100, wdng, jvesely, nemanjai, sdardis, mehdi_amini, jholewinski.
Herald added a project: LLVM.

While we're planning to fix the convergent definition in D68994 <https://reviews.llvm.org/D68994>, I thought
this would be an opportunity to fix another design flaw in the convergent 
attribute.

Invert the direction of the convergent attribute by removing it, and
adding the noconvergent attribute. The current convergent attribute is
currently odd, as adding it is required for correctness. There is a
burden on frontends in environments that care about convergent
operations to add the attribute just in case it is needed. This has
proven to be somewhat problematic, and different frontend projects
have consistently run into problems related to this. OpenMP and SYCL
for example are currently not assuming convergent by default.

      

The backwards definition also did not provide a way to directly
specify non-convergent functions in some cases. There is no way to
specify a negative attribute, so when convergent needs to be assumed,
there was no way to opt-out. By inverting this, user attribute usage
is more flexible.

      

Assume the old convergent semantics by default, so an undecorated
function is correct with respect to convergence. For compatbility
purposes, the old attribute can simply be ignored. The new
noconvergent attribute produces the old default behavior.

      

Infer the noconvergent attribute, which is similar to nounwind.

      

The main risk of this change is negative tests in control flow
passes. They may no longer trigger due to not having noconvergent, and
not for what they truly intended to test. I've speculatively added
noconvergent to JumpThreading tests and a handful of others, but other
passes may be relevant.

      

For now this is just trying to change the IR attribute handling. The
MachineInstr flag and intrinsic decoration are still in the positive
direction. IntrConvergent should probably be inverted, but I think
having the MI flag be positive is probably fine.

      

The source language attribute for convergent is now a no-op. It could
arguably try to enable convergence in a non-SPMD language, but using
this would probably be very error prone. A user facing noconvergent
attribute is probably the next step.


https://reviews.llvm.org/D69498

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGObjCMac.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CXX/except/except.spec/p14-ir.cpp
  clang/test/CXX/special/class.dtor/p3-0x.cpp
  clang/test/CodeGen/2008-04-08-NoExceptions.c
  clang/test/CodeGen/aarch64-tme.cpp
  clang/test/CodeGen/address-safety-attr-flavors.cpp
  clang/test/CodeGen/address-safety-attr.cpp
  clang/test/CodeGen/address-space-field1.c
  clang/test/CodeGen/alias.c
  clang/test/CodeGen/asm-attrs.c
  clang/test/CodeGen/attr-naked.c
  clang/test/CodeGen/attributes.c
  clang/test/CodeGen/builtin-attributes.c
  clang/test/CodeGen/builtin-sqrt.c
  clang/test/CodeGen/complex-builtins.c
  clang/test/CodeGen/complex-libcalls.c
  clang/test/CodeGen/convergent-functions.cpp
  clang/test/CodeGen/exceptions-seh-finally.c
  clang/test/CodeGen/function-attributes.c
  clang/test/CodeGen/incomplete-function-type-2.c
  clang/test/CodeGen/libcall-declarations.c
  clang/test/CodeGen/libcalls-fno-builtin.c
  clang/test/CodeGen/libcalls.c
  clang/test/CodeGen/math-builtins.c
  clang/test/CodeGen/math-libcalls.c
  clang/test/CodeGen/memtag-attr.cpp
  clang/test/CodeGen/micromips-attr.c
  clang/test/CodeGen/mips-constraint-regs.c
  clang/test/CodeGen/mips-vector-arg.c
  clang/test/CodeGen/mips16-attr.c
  clang/test/CodeGen/mrtd.c
  clang/test/CodeGen/ms-declspecs.c
  clang/test/CodeGen/noduplicate-cxx11-test.cpp
  clang/test/CodeGen/noinline.c
  clang/test/CodeGen/noplt.c
  clang/test/CodeGen/ppc64-complex-parms.c
  clang/test/CodeGen/ppc64-complex-return.c
  clang/test/CodeGen/ppc64-extend.c
  clang/test/CodeGen/pragma-weak.c
  clang/test/CodeGen/sanitize-thread-attr.cpp
  clang/test/CodeGen/sanitize-thread-no-checking-at-run-time.m
  clang/test/CodeGen/stackrealign-main.c
  clang/test/CodeGen/struct-passing.c
  clang/test/CodeGen/unwind-attr.c
  clang/test/CodeGenCUDA/amdgpu-kernel-attrs.cu
  clang/test/CodeGenCUDA/convergent.cu
  clang/test/CodeGenCUDA/propagate-metadata.cu
  clang/test/CodeGenCXX/2009-05-04-PureConstNounwind.cpp
  clang/test/CodeGenCXX/attr-x86-no_caller_saved_registers.cpp
  clang/test/CodeGenCXX/attr.cpp
  clang/test/CodeGenCXX/builtin-operator-new-delete.cpp
  clang/test/CodeGenCXX/cxx11-exception-spec.cpp
  clang/test/CodeGenCXX/cxx11-noreturn.cpp
  clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
  clang/test/CodeGenCXX/debug-info-globalinit.cpp
  clang/test/CodeGenCXX/derived-to-base.cpp
  clang/test/CodeGenCXX/dynamic-cast.cpp
  clang/test/CodeGenCXX/exceptions.cpp
  clang/test/CodeGenCXX/global-dtor-no-atexit.cpp
  clang/test/CodeGenCXX/global-init.cpp
  clang/test/CodeGenCXX/inline-hint.cpp
  clang/test/CodeGenCXX/inline-template-hint.cpp
  clang/test/CodeGenCXX/main-norecurse.cpp
  clang/test/CodeGenCXX/microsoft-abi-array-cookies.cpp
  clang/test/CodeGenCXX/new-alias.cpp
  clang/test/CodeGenCXX/new.cpp
  clang/test/CodeGenCXX/no-exceptions.cpp
  clang/test/CodeGenCXX/noinline-template.cpp
  clang/test/CodeGenCXX/optnone-and-attributes.cpp
  clang/test/CodeGenCXX/optnone-class-members.cpp
  clang/test/CodeGenCXX/optnone-def-decl.cpp
  clang/test/CodeGenCXX/optnone-templates.cpp
  clang/test/CodeGenCXX/reference-cast.cpp
  clang/test/CodeGenCXX/runtimecc.cpp
  clang/test/CodeGenCXX/threadsafe-statics.cpp
  clang/test/CodeGenCXX/thunks.cpp
  clang/test/CodeGenCXX/virtual-base-cast.cpp
  clang/test/CodeGenCXX/virtual-function-calls.cpp
  clang/test/CodeGenCXX/wasm-eh.cpp
  clang/test/CodeGenCoroutines/coro-unhandled-exception.cpp
  clang/test/CodeGenObjC/arc-no-arc-exceptions.m
  clang/test/CodeGenObjC/arc.m
  clang/test/CodeGenObjC/attr-noreturn.m
  clang/test/CodeGenObjC/attr-objc-runtime-visible.m
  clang/test/CodeGenObjC/class-stubs.m
  clang/test/CodeGenObjC/gnu-exceptions.m
  clang/test/CodeGenObjC/nonlazy-msgSend.m
  clang/test/CodeGenObjC/objc-literal-debugger-test.m
  clang/test/CodeGenObjC/objc-literal-tests.m
  clang/test/CodeGenObjCXX/arc-marker-funclet.mm
  clang/test/CodeGenObjCXX/lambda-expressions.mm
  clang/test/CodeGenOpenCL/amdgpu-attrs.cl
  clang/test/CodeGenOpenCL/builtins-amdgcn.cl
  clang/test/CodeGenOpenCL/convergent.cl
  clang/test/CodeGenOpenCL/func-call-dbg-loc.cl
  clang/test/CodeGenOpenCLCXX/template-address-spaces.cl
  clang/test/Driver/darwin-iphone-defaults.m
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  clang/test/OpenMP/openmp_win_codegen.cpp
  clang/test/PCH/objc_container.m
  clang/test/Sema/libbuiltins-ctype-powerpc64.c
  clang/test/Sema/libbuiltins-ctype-x86_64.c
  clang/test/SemaCXX/pragma-optimize.cpp
  llvm/docs/LangRef.rst
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/Bitcode/LLVMBitCodes.h
  llvm/include/llvm/IR/Attributes.td
  llvm/include/llvm/IR/CallSite.h
  llvm/include/llvm/IR/Function.h
  llvm/include/llvm/IR/InstrTypes.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/Transforms/IPO/Attributor.h
  llvm/lib/AsmParser/LLLexer.cpp
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/AsmParser/LLToken.h
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/IR/Attributes.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/IPO/Attributor.cpp
  llvm/lib/Transforms/IPO/ForceFunctionAttrs.cpp
  llvm/lib/Transforms/IPO/FunctionAttrs.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/lib/Transforms/Utils/CodeExtractor.cpp
  llvm/test/Analysis/BasicAA/intrinsics.ll
  llvm/test/Analysis/TypeBasedAliasAnalysis/functionattrs.ll
  llvm/test/Analysis/TypeBasedAliasAnalysis/intrinsics.ll
  llvm/test/Assembler/invalid-noconvergent-argument.ll
  llvm/test/Assembler/invalid-noconvergent-return.ll
  llvm/test/Bindings/llvm-c/debug_info.ll
  llvm/test/Bitcode/attributes.ll
  llvm/test/Bitcode/compatibility-3.6.ll
  llvm/test/Bitcode/compatibility-3.7.ll
  llvm/test/Bitcode/compatibility-3.8.ll
  llvm/test/Bitcode/compatibility-3.9.ll
  llvm/test/Bitcode/compatibility-4.0.ll
  llvm/test/Bitcode/compatibility-5.0.ll
  llvm/test/Bitcode/compatibility-6.0.ll
  llvm/test/Bitcode/compatibility.ll
  llvm/test/Bitcode/convergent-upgrade.ll
  llvm/test/Bitcode/convergent-upgrade.ll.bc
  llvm/test/Bitcode/ptest-new.ll
  llvm/test/Bitcode/ptest-old.ll
  llvm/test/Bitcode/upgrade-invariant-group-barrier.ll
  llvm/test/CodeGen/AMDGPU/buffer-intrinsics-mmo-offsets.ll
  llvm/test/CodeGen/AMDGPU/convergent-inlineasm.ll
  llvm/test/CodeGen/AMDGPU/lds-output-queue.ll
  llvm/test/CodeGen/AMDGPU/llvm.amdgcn.init.exec.ll
  llvm/test/CodeGen/AMDGPU/schedule-vs-if-nested-loop-failure.ll
  llvm/test/CodeGen/Mips/micromips-b-range.ll
  llvm/test/CodeGen/NVPTX/convergent-mir-call.ll
  llvm/test/CodeGen/X86/inline-asm-avx512f-x-constraint.ll
  llvm/test/CodeGen/X86/inline-asm-default-clobbers.ll
  llvm/test/Feature/intrinsics.ll
  llvm/test/Other/invariant.group.ll
  llvm/test/TableGen/intrin-side-effects.td
  llvm/test/Transforms/CallSiteSplitting/callsite-instructions-before-call.ll
  llvm/test/Transforms/CallSiteSplitting/callsite-no-or-structure.ll
  llvm/test/Transforms/CallSiteSplitting/callsite-split-debug.ll
  llvm/test/Transforms/CallSiteSplitting/callsite-split-or-phi.ll
  llvm/test/Transforms/CallSiteSplitting/callsite-split-preserve-debug.ll
  llvm/test/Transforms/CallSiteSplitting/callsite-split.ll
  llvm/test/Transforms/CallSiteSplitting/convergent.ll
  llvm/test/Transforms/CallSiteSplitting/musttail.ll
  llvm/test/Transforms/CallSiteSplitting/noduplicate.ll
  llvm/test/Transforms/DeadArgElim/2010-04-30-DbgInfo.ll
  llvm/test/Transforms/ForcedFunctionAttrs/noconvergent.ll
  llvm/test/Transforms/FunctionAttrs/arg_returned.ll
  llvm/test/Transforms/FunctionAttrs/atomic.ll
  llvm/test/Transforms/FunctionAttrs/convergent.ll
  llvm/test/Transforms/FunctionAttrs/fn_noreturn.ll
  llvm/test/Transforms/FunctionAttrs/incompatible_fn_attrs.ll
  llvm/test/Transforms/FunctionAttrs/liveness.ll
  llvm/test/Transforms/FunctionAttrs/noconvergent.ll
  llvm/test/Transforms/FunctionAttrs/nofree-attributor.ll
  llvm/test/Transforms/FunctionAttrs/nofree.ll
  llvm/test/Transforms/FunctionAttrs/norecurse.ll
  llvm/test/Transforms/FunctionAttrs/noreturn_async.ll
  llvm/test/Transforms/FunctionAttrs/noreturn_sync.ll
  llvm/test/Transforms/FunctionAttrs/nosync.ll
  llvm/test/Transforms/FunctionAttrs/nounwind.ll
  llvm/test/Transforms/FunctionAttrs/operand-bundles-scc.ll
  llvm/test/Transforms/FunctionAttrs/optnone.ll
  llvm/test/Transforms/FunctionAttrs/read-write-scc.ll
  llvm/test/Transforms/FunctionAttrs/read_write_returned_arguments_scc.ll
  llvm/test/Transforms/FunctionAttrs/willreturn.ll
  llvm/test/Transforms/GVNHoist/hoist-convergent.ll
  llvm/test/Transforms/GVNHoist/hoist-pr31891.ll
  llvm/test/Transforms/InferAddressSpaces/NVPTX/clone_constexpr.ll
  llvm/test/Transforms/InferFunctionAttrs/norecurse_debug.ll
  llvm/test/Transforms/Inline/cgscc-update.ll
  llvm/test/Transforms/Inline/inline_invoke.ll
  llvm/test/Transforms/Inline/noalias-calls.ll
  llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll
  llvm/test/Transforms/InstCombine/convergent.ll
  llvm/test/Transforms/InstCombine/sdiv-guard.ll
  llvm/test/Transforms/JumpThreading/2010-08-26-and.ll
  llvm/test/Transforms/JumpThreading/and-and-cond.ll
  llvm/test/Transforms/JumpThreading/and-cond.ll
  llvm/test/Transforms/JumpThreading/assume-edge-dom.ll
  llvm/test/Transforms/JumpThreading/assume.ll
  llvm/test/Transforms/JumpThreading/basic.ll
  llvm/test/Transforms/JumpThreading/branch-no-const.ll
  llvm/test/Transforms/JumpThreading/callbr-edge-split.ll
  llvm/test/Transforms/JumpThreading/combine-metadata.ll
  llvm/test/Transforms/JumpThreading/compare.ll
  llvm/test/Transforms/JumpThreading/crash.ll
  llvm/test/Transforms/JumpThreading/ddt-crash.ll
  llvm/test/Transforms/JumpThreading/ddt-crash2.ll
  llvm/test/Transforms/JumpThreading/fold-not-thread.ll
  llvm/test/Transforms/JumpThreading/guards.ll
  llvm/test/Transforms/JumpThreading/header-succ.ll
  llvm/test/Transforms/JumpThreading/implied-cond.ll
  llvm/test/Transforms/JumpThreading/indirectbr.ll
  llvm/test/Transforms/JumpThreading/landing-pad.ll
  llvm/test/Transforms/JumpThreading/lvi-load.ll
  llvm/test/Transforms/JumpThreading/lvi-tristate.ll
  llvm/test/Transforms/JumpThreading/or-undef.ll
  llvm/test/Transforms/JumpThreading/phi-eq.ll
  llvm/test/Transforms/JumpThreading/phi-known.ll
  llvm/test/Transforms/JumpThreading/pr26096.ll
  llvm/test/Transforms/JumpThreading/pr27840.ll
  llvm/test/Transforms/JumpThreading/pr33917.ll
  llvm/test/Transforms/JumpThreading/range-compare.ll
  llvm/test/Transforms/JumpThreading/select.ll
  llvm/test/Transforms/JumpThreading/stale-loop-info-after-unfold-select.ll
  llvm/test/Transforms/JumpThreading/static-profile.ll
  llvm/test/Transforms/JumpThreading/thread-cmp.ll
  llvm/test/Transforms/JumpThreading/thread-loads.ll
  llvm/test/Transforms/JumpThreading/threading_prof1.ll
  llvm/test/Transforms/JumpThreading/threading_prof2.ll
  llvm/test/Transforms/JumpThreading/unreachable-loops.ll
  llvm/test/Transforms/JumpThreading/update-edge-weight.ll
  llvm/test/Transforms/LoopDistribute/basic-with-memchecks.ll
  llvm/test/Transforms/LoopRotate/convergent.ll
  llvm/test/Transforms/LoopUnroll/2011-08-08-PhiUpdate.ll
  llvm/test/Transforms/LoopUnroll/2011-08-09-PhiUpdate.ll
  llvm/test/Transforms/LoopUnroll/convergent.ll
  llvm/test/Transforms/LoopUnroll/loop-remarks-with-hotness.ll
  llvm/test/Transforms/LoopUnroll/loop-remarks.ll
  llvm/test/Transforms/LoopUnroll/runtime-loop-multiple-exits.ll
  llvm/test/Transforms/LoopUnswitch/2008-11-03-Invariant.ll
  llvm/test/Transforms/LoopUnswitch/2011-11-18-SimpleSwitch.ll
  llvm/test/Transforms/LoopUnswitch/2011-11-18-TwoSwitches-Threshold.ll
  llvm/test/Transforms/LoopUnswitch/2011-11-18-TwoSwitches.ll
  llvm/test/Transforms/LoopUnswitch/basictest.ll
  llvm/test/Transforms/LoopUnswitch/simplify-with-nonvalness.ll
  (33 more files...)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D69498.226611.patch
Type: text/x-patch
Size: 416570 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191028/790e14d7/attachment-0001.bin>


More information about the llvm-commits mailing list