Page MenuHomePhabricator

Updating the TipsAndTricks.rst documentation of Polly related to bugpoint
AcceptedPublic

Authored by alexsusu on Oct 16 2017, 7:05 AM.

Details

Reviewers
Meinersbur
bollu
Summary

Updating the TipsAndTricks.rst documentation of Polly related to bugpoint.
The previous version explained poorly, incorrectly bugpoint - maybe they were referring to an older, simpler version of bugpoint.
We describe here the version of bugpoint as checked out from the SVN repository on Oct 2017.

Diff Detail

Event Timeline

alexsusu created this revision.Oct 16 2017, 7:05 AM
bollu accepted this revision.Oct 16 2017, 7:51 AM

LGTM! Thanks, I didn't realize that the options could interact with bugs in llc.

This revision is now accepted and ready to land.Oct 16 2017, 7:51 AM
alexsusu updated this revision to Diff 119157.Oct 16 2017, 7:59 AM

(nothing serious)

alexsusu updated this revision to Diff 119161.Oct 16 2017, 8:01 AM

(nothing serious, part 2)

Meinersbur edited edge metadata.Oct 17 2017, 1:52 PM

Thanks for improving our documentation!

TipsAndTricks.rst
18–20

Are you sure the additional flags -safe-auto, -compile-custom, -compile-command are needed? I never used them. AFAIU, -compile-custom will cause that -opt-command and -opt-args to be ignored.

Generally, there are two cases the distinguish: opt crashes or it does not. If opt crashes, llc should never be called since opt is a step before llc. If opt does not crash, bugpoint switches to another mode that tries to isolate a miscompile. I never actively used that mode.

Could you clarify which of the two modes this applies to?

Thanks for improving our documentation!

Are you sure the additional flags -safe-auto, -compile-custom, -compile-command are needed? I never used them. AFAIU, -compile-custom will cause that -opt-command and -opt-args to be ignored.

After triple-checking, -safe-auto is not needed. However, -compile-custom, -compile-command (and also -opt-command, although it overlaps with -compile-command - maybe this should be improved in bugpoint) are very useful - trying to remove any of them results in bugpoint no longer working properly from what I see.
So I UPDATED the documentation s.t. bugpoint has the minimal number of arguments.

Generally, there are two cases to distinguish: opt crashes or it does not. If opt crashes, llc should never be called since opt is a step before llc. If opt does not crash, bugpoint switches to another mode that tries to isolate a miscompile. I never actively used that mode.

From what I understand bugpoint uses normally llc, but to make it reduce a failing test in opt (as it it is the case for Polly) requires to use the arguments from the previous paragraph.

Could you clarify which of the two modes this applies to?

During the tests I did with bugpoint with the above mentioned arguments it never called llc, nor did bugpoint produce an object file - all I obtained were .bc LLVM IR bitcode files.

Alex

Could you check whether this works for you:

assume.diff
diff --git a/lib/Support/ScopHelper.cpp b/lib/Support/ScopHelper.cpp
index ac501113..9fea5471 100644
--- a/lib/Support/ScopHelper.cpp
+++ b/lib/Support/ScopHelper.cpp
@@ -500,7 +500,9 @@ bool polly::isIgnoredIntrinsic(const Value *V) {
     case llvm::Intrinsic::ptr_annotation:
     case llvm::Intrinsic::annotation:
     case llvm::Intrinsic::donothing:
+      break;
     case llvm::Intrinsic::assume:
+      llvm_unreachable("crash here");
     // Some debug info intrinsics are supported/ignored.
     case llvm::Intrinsic::dbg_value:
     case llvm::Intrinsic::dbg_declare:

(patch With this patch)

assume.c
#include "stdio.h"

int main(int argc, char *argv[]) {
  printf("Hello World!");
  for (int i = 0; i < argc; i+=1) {
    __builtin_assume(0 > argc);
  }
  return 0;
}

and

assume.sh
#! /bin/sh

LLVMPATH=${HOME}/build/llvm/release/bin

cat $0
cat assume.c
${LLVMPATH}/clang assume.c -O0 -S -emit-llvm -Xclang -disable-O0-optnone -o assume.ll
${LLVMPATH}/opt assume.ll -mem2reg -polly-scops -analyze
${LLVMPATH}/bugpoint -opt-command=${LLVMPATH}/opt assume.ll -mem2reg -polly-scops

echo 
echo "The reduced file is:" 
${LLVMPATH}/opt bugpoint-reduced-simplified.bc -S

For this outputs:

$ ./assume.sh
[...]
Dumped core
Emitted bitcode to 'bugpoint-reduced-simplified.bc'

*** You can reproduce the problem with: opt bugpoint-reduced-simplified.bc -polly-scops

The reduced file is:
; ModuleID = 'bugpoint-reduced-simplified.bc'
source_filename = "bugpoint-output-b82a770.bc"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: noinline nounwind uwtable
define void @main() #0 {
entry:
  br label %for.cond

for.cond:                                         ; preds = %for.body, %entry
  br i1 false, label %for.body, label %for.end

for.body:                                         ; preds = %for.cond
  call void @llvm.assume(i1 undef)
  br label %for.cond

for.end:                                          ; preds = %for.cond
  ret void
}

; Function Attrs: nounwind
declare void @llvm.assume(i1) #1

attributes #0 = { noinline nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { nounwind }

!llvm.ident = !{!0}

!0 = !{!"clang version 6.0.0 (trunk 314509) (llvm/trunk 314516)"}