[llvm] r265084 - [LoopVectorize] Don't unconditionally print vectorization diagnostics

Akira Hatanaka via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 31 17:42:07 PDT 2016


Forgot to mention that the original patch was written by Duncan Exon Smith
and I added the test case.

On Thu, Mar 31, 2016 at 5:34 PM, Akira Hatanaka via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: ahatanak
> Date: Thu Mar 31 19:34:39 2016
> New Revision: 265084
>
> URL: http://llvm.org/viewvc/llvm-project?rev=265084&view=rev
> Log:
> [LoopVectorize] Don't unconditionally print vectorization diagnostics
> when compiling with LTO.
>
> r244523 a new class DiagnosticInfoOptimizationRemarkAnalysisAliasing for
> optimization analysis remarks related to pointer aliasing without
> guarding it in isDiagnosticEnabled in LLVMContext.cpp. This caused the
> diagnostic message to be printed unconditionally when compiling with
> LTO.
>
> This commit cleans up isDiagnosticEnabled and makes sure all the
> vectorization optimization remarks are guarded.
>
> rdar://problem/25382153
>
> Modified:
>     llvm/trunk/include/llvm/IR/DiagnosticInfo.h
>     llvm/trunk/lib/IR/LLVMContext.cpp
>     llvm/trunk/test/LTO/X86/diagnostic-handler-remarks.ll
>
> Modified: llvm/trunk/include/llvm/IR/DiagnosticInfo.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DiagnosticInfo.h?rev=265084&r1=265083&r2=265084&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/IR/DiagnosticInfo.h (original)
> +++ llvm/trunk/include/llvm/IR/DiagnosticInfo.h Thu Mar 31 19:34:39 2016
> @@ -58,6 +58,8 @@ enum DiagnosticKind {
>    DK_OptimizationRemarkAnalysisFPCommute,
>    DK_OptimizationRemarkAnalysisAliasing,
>    DK_OptimizationFailure,
> +  DK_FirstRemark = DK_OptimizationRemark,
> +  DK_LastRemark = DK_OptimizationFailure,
>    DK_MIRParser,
>    DK_PGOProfile,
>    DK_Unsupported,
> @@ -340,6 +342,11 @@ public:
>    const char *getPassName() const { return PassName; }
>    const Twine &getMsg() const { return Msg; }
>
> +  static bool classof(const DiagnosticInfo *DI) {
> +    return DI->getKind() >= DK_FirstRemark &&
> +           DI->getKind() <= DK_LastRemark;
> +  }
> +
>  private:
>    /// Name of the pass that triggers this report. If this matches the
>    /// regular expression given in -Rpass=regexp, then the remark will
>
> Modified: llvm/trunk/lib/IR/LLVMContext.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/LLVMContext.cpp?rev=265084&r1=265083&r2=265084&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/IR/LLVMContext.cpp (original)
> +++ llvm/trunk/lib/IR/LLVMContext.cpp Thu Mar 31 19:34:39 2016
> @@ -223,27 +223,9 @@ static bool isDiagnosticEnabled(const Di
>    // pattern, passed via one of the -pass-remarks* flags, matches the
> name of
>    // the pass that is emitting the diagnostic. If there is no match,
> ignore the
>    // diagnostic and return.
> -  switch (DI.getKind()) {
> -  case llvm::DK_OptimizationRemark:
> -    if (!cast<DiagnosticInfoOptimizationRemark>(DI).isEnabled())
> -      return false;
> -    break;
> -  case llvm::DK_OptimizationRemarkMissed:
> -    if (!cast<DiagnosticInfoOptimizationRemarkMissed>(DI).isEnabled())
> -      return false;
> -    break;
> -  case llvm::DK_OptimizationRemarkAnalysis:
> -    if (!cast<DiagnosticInfoOptimizationRemarkAnalysis>(DI).isEnabled())
> -      return false;
> -    break;
> -  case llvm::DK_OptimizationRemarkAnalysisFPCommute:
> -    if (!cast<DiagnosticInfoOptimizationRemarkAnalysisFPCommute>(DI)
> -             .isEnabled())
> -      return false;
> -    break;
> -  default:
> -    break;
> -  }
> +  if (auto *Remark = dyn_cast<DiagnosticInfoOptimizationBase>(&DI))
> +    return Remark->isEnabled();
> +
>    return true;
>  }
>
>
> Modified: llvm/trunk/test/LTO/X86/diagnostic-handler-remarks.ll
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LTO/X86/diagnostic-handler-remarks.ll?rev=265084&r1=265083&r2=265084&view=diff
>
> ==============================================================================
> --- llvm/trunk/test/LTO/X86/diagnostic-handler-remarks.ll (original)
> +++ llvm/trunk/test/LTO/X86/diagnostic-handler-remarks.ll Thu Mar 31
> 19:34:39 2016
> @@ -3,31 +3,38 @@
>
>  ; Confirm that there are -pass-remarks.
>  ; RUN: llvm-lto -pass-remarks=inline \
> +; RUN:          -exported-symbol _func2
> -pass-remarks-analysis=loop-vectorize \
>  ; RUN:          -exported-symbol _main -o %t.o %t.bc 2>&1 | \
>  ; RUN:     FileCheck %s -allow-empty -check-prefix=REMARKS
>  ; RUN: llvm-nm %t.o | FileCheck %s -check-prefix NM
>
>  ; RUN: llvm-lto -pass-remarks=inline -use-diagnostic-handler \
> +; RUN:          -exported-symbol _func2
> -pass-remarks-analysis=loop-vectorize \
>  ; RUN:         -exported-symbol _main -o %t.o %t.bc 2>&1 | \
>  ; RUN:     FileCheck %s -allow-empty -check-prefix=REMARKS_DH
>  ; RUN: llvm-nm %t.o | FileCheck %s -check-prefix NM
>
>  ; Confirm that -pass-remarks are not printed by default.
>  ; RUN: llvm-lto \
> +; RUN:         -exported-symbol _func2 \
>  ; RUN:         -exported-symbol _main -o %t.o %t.bc 2>&1 | \
>  ; RUN:     FileCheck %s -allow-empty
>  ; RUN: llvm-nm %t.o | FileCheck %s -check-prefix NM
>
>  ; RUN: llvm-lto -use-diagnostic-handler \
> +; RUN:         -exported-symbol _func2 \
>  ; RUN:         -exported-symbol _main -o %t.o %t.bc 2>&1 | \
>  ; RUN:     FileCheck %s -allow-empty
>  ; RUN: llvm-nm %t.o | FileCheck %s -check-prefix NM
>
> -; REMARKS: remark:
> -; REMARKS_DH: llvm-lto: remark:
> +; REMARKS: remark: {{.*}} foo inlined into main
> +; REMARKS: remark: {{.*}} loop not vectorized: cannot prove it is safe to
> reorder memory operations
> +; REMARKS_DH: llvm-lto: remark: {{.*}} foo inlined into main
> +; REMARKS_DH: llvm-lto: remark: {{.*}} loop not vectorized: cannot prove
> it is safe to reorder memory operations
>  ; CHECK-NOT: remark:
>  ; CHECK-NOT: llvm-lto:
>  ; NM-NOT: foo
> +; NM: func2
>  ; NM: main
>
>  target triple = "x86_64-apple-darwin"
> @@ -43,3 +50,44 @@ define i32 @main() {
>    %i = call i32 @foo()
>    ret i32 %i
>  }
> +
> +define i32 @func2(i32* %out, i32* %out2, i32* %A, i32* %B, i32* %C, i32*
> %D, i32* %E, i32* %F) {
> +entry:
> +  br label %for.body
> +
> +for.body:                                         ; preds = %for.body,
> %entry
> +  %i.037 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
> +  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %i.037
> +  %0 = load i32, i32* %arrayidx, align 4
> +  %arrayidx1 = getelementptr inbounds i32, i32* %B, i64 %i.037
> +  %1 = load i32, i32* %arrayidx1, align 4
> +  %add = add nsw i32 %1, %0
> +  %arrayidx2 = getelementptr inbounds i32, i32* %C, i64 %i.037
> +  %2 = load i32, i32* %arrayidx2, align 4
> +  %add3 = add nsw i32 %add, %2
> +  %arrayidx4 = getelementptr inbounds i32, i32* %E, i64 %i.037
> +  %3 = load i32, i32* %arrayidx4, align 4
> +  %add5 = add nsw i32 %add3, %3
> +  %arrayidx6 = getelementptr inbounds i32, i32* %F, i64 %i.037
> +  %4 = load i32, i32* %arrayidx6, align 4
> +  %add7 = add nsw i32 %add5, %4
> +  %arrayidx8 = getelementptr inbounds i32, i32* %out, i64 %i.037
> +  store i32 %add7, i32* %arrayidx8, align 4
> +  %5 = load i32, i32* %arrayidx, align 4
> +  %6 = load i32, i32* %arrayidx1, align 4
> +  %add11 = add nsw i32 %6, %5
> +  %7 = load i32, i32* %arrayidx2, align 4
> +  %add13 = add nsw i32 %add11, %7
> +  %8 = load i32, i32* %arrayidx4, align 4
> +  %add15 = add nsw i32 %add13, %8
> +  %9 = load i32, i32* %arrayidx6, align 4
> +  %add17 = add nsw i32 %add15, %9
> +  %arrayidx18 = getelementptr inbounds i32, i32* %out2, i64 %i.037
> +  store i32 %add17, i32* %arrayidx18, align 4
> +  %inc = add i64 %i.037, 1
> +  %exitcond = icmp eq i64 %inc, 256
> +  br i1 %exitcond, label %for.end, label %for.body
> +
> +for.end:                                          ; preds = %for.body
> +  ret i32 undef
> +}
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160331/c72155af/attachment.html>


More information about the llvm-commits mailing list