[polly] r252725 - ScopDetection: Do not allow blocks to reference operands in error blocks

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 11 09:05:15 PST 2015


Do we allow arbitrary code in error blocks as well as blocks only
reachable by error blocks or do we perform all our checks on these
blocks too?

On 11/11, Tobias Grosser via llvm-commits wrote:
> Author: grosser
> Date: Wed Nov 11 06:44:18 2015
> New Revision: 252725
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=252725&view=rev
> Log:
> ScopDetection: Do not allow blocks to reference operands in error blocks
> 
> r252713 introduced a couple of regressions due to later basic blocks refering
> to instructions defined in error blocks which have not yet been modeled.
> 
> This commit is currently just encoding limitations of our modeling and code
> generation backends to ensure correctness. In theory, we should be able to
> generate and optimize such regions, as everything that is dominated by an error
> region is assumed to not be executed anyhow. We currently just lack the code
> to make this happen in practice.
>
> Added:
>     polly/trunk/test/ScopDetect/error-block-referenced-from-scop.ll
> Modified:
>     polly/trunk/lib/Analysis/ScopDetection.cpp
>     polly/trunk/lib/Support/ScopHelper.cpp
> 
> Modified: polly/trunk/lib/Analysis/ScopDetection.cpp
> URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopDetection.cpp?rev=252725&r1=252724&r2=252725&view=diff
> ==============================================================================
> --- polly/trunk/lib/Analysis/ScopDetection.cpp (original)
> +++ polly/trunk/lib/Analysis/ScopDetection.cpp Wed Nov 11 06:44:18 2015
> @@ -729,6 +729,16 @@ bool ScopDetection::isValidMemoryAccess(
>  
>  bool ScopDetection::isValidInstruction(Instruction &Inst,
>                                         DetectionContext &Context) const {
> +  for (auto &Op : Inst.operands()) {
> +    auto *OpInst = dyn_cast<Instruction>(&Op);
> +
> +    if (!OpInst)
> +      continue;
> +
> +    if (isErrorBlock(*OpInst->getParent(), Context.CurRegion, *LI, *DT))
> +      return false;
> +  }
> +
>    // We only check the call instruction but not invoke instruction.
>    if (CallInst *CI = dyn_cast<CallInst>(&Inst)) {
>      if (isValidCallInst(*CI))
> 
> Modified: polly/trunk/lib/Support/ScopHelper.cpp
> URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Support/ScopHelper.cpp?rev=252725&r1=252724&r2=252725&view=diff
> ==============================================================================
> --- polly/trunk/lib/Support/ScopHelper.cpp (original)
> +++ polly/trunk/lib/Support/ScopHelper.cpp Wed Nov 11 06:44:18 2015
> @@ -368,6 +368,9 @@ bool polly::isErrorBlock(BasicBlock &BB,
>  
>    for (Instruction &Inst : BB)
>      if (CallInst *CI = dyn_cast<CallInst>(&Inst)) {
> +      if (isIgnoredIntrinsic(CI))
> +        return false;
> +
Why was this necessary?

>        if (!CI->doesNotAccessMemory())
>          return true;
>        if (CI->doesNotReturn())
> 
> Added: polly/trunk/test/ScopDetect/error-block-referenced-from-scop.ll
> URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopDetect/error-block-referenced-from-scop.ll?rev=252725&view=auto
> ==============================================================================
> --- polly/trunk/test/ScopDetect/error-block-referenced-from-scop.ll (added)
> +++ polly/trunk/test/ScopDetect/error-block-referenced-from-scop.ll Wed Nov 11 06:44:18 2015
> @@ -0,0 +1,54 @@
> +; RUN: opt %loadPolly -polly-code-generator=isl -polly-detect -analyze < %s \
> +; RUN:     | FileCheck %s
> +;
> +; CHECK-NOT: Valid Region for Scop:
> +
> +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
> +target triple = "x86_64-unknown-linux-gnu"
> +
> +; Function Attrs: nounwind uwtable
> +define void @hoge() #0 {
> +bb:
> +  br label %bb1
> +
> +bb1:                                              ; preds = %bb
> +  br i1 undef, label %bb2, label %bb7
> +
> +bb2:                                              ; preds = %bb1
> +  %tmp = load i32, i32* undef, align 8, !tbaa !1
> +  %tmp3 = tail call i32 @widget() #2
> +  br i1 false, label %bb4, label %bb5
> +
> +bb4:                                              ; preds = %bb2
> +  br label %bb8
> +
> +bb5:                                              ; preds = %bb2
> +  %tmp6 = sub i32 %tmp, %tmp3
> +  br label %bb8
> +
> +bb7:                                              ; preds = %bb1
> +  br label %bb8
> +
> +bb8:                                              ; preds = %bb7, %bb5, %bb4
> +  ret void
> +}
> +
> +; Function Attrs: inlinehint nounwind readonly uwtable
> +declare i32 @widget() #1
> +
> +attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
> +attributes #1 = { inlinehint nounwind readonly uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
> +attributes #2 = { nounwind readonly }
> +
> +!llvm.ident = !{!0}
> +
> +!0 = !{!"clang version 3.8.0 (trunk 252700) (llvm/trunk 252705)"}
> +!1 = !{!2, !7, i64 8}
> +!2 = !{!"cli_target_info", !3, i64 0, !6, i64 8, !4, i64 32}
> +!3 = !{!"long", !4, i64 0}
> +!4 = !{!"omnipotent char", !5, i64 0}
> +!5 = !{!"Simple C/C++ TBAA"}
> +!6 = !{!"cli_exe_info", !7, i64 0, !8, i64 4, !3, i64 8, !9, i64 16}
> +!7 = !{!"int", !4, i64 0}
> +!8 = !{!"short", !4, i64 0}
> +!9 = !{!"any pointer", !4, i64 0}
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits

-- 

Johannes Doerfert
Researcher / PhD Student

Compiler Design Lab (Prof. Hack)
Saarland University, Computer Science
Building E1.3, Room 4.31

Tel. +49 (0)681 302-57521 : doerfert at cs.uni-saarland.de
Fax. +49 (0)681 302-3065  : http://www.cdl.uni-saarland.de/people/doerfert
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 213 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151111/f85c2bc4/attachment.sig>


More information about the llvm-commits mailing list