Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for LLVM 3.8 #900

Merged
merged 8 commits into from
Jul 12, 2018
Merged

Support for LLVM 3.8 #900

merged 8 commits into from
Jul 12, 2018

Conversation

jirislaby
Copy link
Contributor

The story never ends...

sudo apt-get install -y llvm-${LLVM_VERSION}-tools clang-${LLVM_VERSION}
sudo apt-get install -y clang-${LLVM_VERSION}
if [ "${LLVM_VERSION}" != "3.8" ]; then
sudo apt-get install -y llvm-${LLVM_VERSION}-tools
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is llvm-3.8-tools not needed anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this was needed before we started using llvm-toolchain repos. It should not be needed now. I will try to drop it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For 3.8, this is still needed, because:

Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
 llvm-3.8-tools : Depends: llvm-3.8-dev (= 1:3.8~svn278388-1~exp1) but 1:3.8-2ubuntu3~trusty5 is to be installed
E: Unable to correct problems, you have held broken packages.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, thanks for having a look. Do you know if it's needed at all, considering llvm-3.8 works without it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kren1 llvm-tools contains FileCheck and not, so you we need for testing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this means no testing for llvm-3.8? I guess for those two programs we could use an different llvm-tools version?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But tests are run and succeed AFAICT. So the tools are maybe in different package in 3.8?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, FileCheck and not are downloaded if not available, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jirislaby Yes, exactly. And we can either use lit provided with LLVM or the python package.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what't the solution here? I feel like we don't need to special case this for 3.8.

@@ -2210,8 +2210,13 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
!fpWidthToSemantics(right->getWidth()))
return terminateStateOnExecError(state, "Unsupported FRem operation");
llvm::APFloat Res(*fpWidthToSemantics(left->getWidth()), left->getAPValue());
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
Res.mod(
APFloat(*fpWidthToSemantics(right->getWidth()), right->getAPValue()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rounding was removed because it was never needed: llvm-mirror/llvm@ff278be

@codecov
Copy link

codecov bot commented May 24, 2018

Codecov Report

Merging #900 into master will decrease coverage by <.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #900      +/-   ##
==========================================
- Coverage   65.91%   65.91%   -0.01%     
==========================================
  Files         141      141              
  Lines       16152    16154       +2     
  Branches     3739     3739              
==========================================
+ Hits        10647    10648       +1     
- Misses       3816     3817       +1     
  Partials     1689     1689
Flag Coverage Δ
#systemtests 65.16% <0%> (-0.01%) ⬇️
#unittests 10.74% <0%> (-0.01%) ⬇️
Impacted Files Coverage Δ
lib/Core/Executor.cpp 75.7% <ø> (ø) ⬆️
lib/Module/IntrinsicCleaner.cpp 87.87% <ø> (ø) ⬆️
lib/Core/StatsTracker.cpp 87.19% <ø> (ø) ⬆️
lib/Module/Optimize.cpp 88.28% <ø> (ø) ⬆️
lib/Module/ModuleUtil.cpp 60.48% <ø> (ø) ⬆️
lib/Module/LowerSwitch.cpp 77.77% <ø> (ø) ⬆️
tools/klee/main.cpp 64.22% <0%> (-0.19%) ⬇️
lib/Core/AddressSpace.cpp 58.33% <0%> (+0.59%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3eece12...9d054d6. Read the comment docs.

@@ -110,8 +114,12 @@ bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b, Module &M) {
case Intrinsic::uadd_with_overflow:
case Intrinsic::usub_with_overflow:
case Intrinsic::umul_with_overflow: {
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
// ctor needs the iterator, but we already increased ours
IRBuilder<> builder(ii->getParent(), i_);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I missing something, but I can't see why this would be necessary in 3.8, the constructros doesn't seem to have changed?

@@ -102,7 +102,12 @@ static void AddStandardCompilePasses(klee::LegacyLLVMPassManagerTy &PM) {
addPass(PM, createCFGSimplificationPass()); // Clean up after IPCP & DAE

addPass(PM, createPruneEHPass()); // Remove dead EH info
addPass(PM, createFunctionAttrsPass()); // Deduce function attrs
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
addPass(PM, createPostOrderFunctionAttrsPass());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be a refactoring in llvm-mirror/llvm@e96fb9a

#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
addPass(Passes, createPostOrderFunctionAttrsPass());
addPass(Passes, createReversePostOrderFunctionAttrsPass());
// addPass(Passes, createGlobalsAAWrapperPass());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stray comment.

raw_svector_ostream ds(d); ds << i; ds.flush();
raw_svector_ostream ds(d);
ds << i;
// SmallString is always up-to-date, no need to flush. See Support/raw_ostream.h
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jirislaby jirislaby force-pushed the llvm_38 branch 2 times, most recently from e7100fa to 41c0eb6 Compare June 15, 2018 13:38
@ccadar
Copy link
Contributor

ccadar commented Jun 29, 2018

@jirislaby , what's the status with this one? I guess it's ready for a rebase?

@ccadar ccadar changed the title support for llvm 3.8 Support for LLVM 3.8 Jun 29, 2018
@MartinNowack
Copy link
Contributor

@jirislaby Do you have time to rebase your patch? Otherwise I can try to do it.

@jirislaby
Copy link
Contributor Author

@MartinNowack coincidently I have been working on this today. It was tough due to rework in ef90f1e but it's done.

@MartinNowack
Copy link
Contributor

@jirislaby Fantastic!! I assumed there was some pain involved - sorry for that.

@ccadar
Copy link
Contributor

ccadar commented Jul 9, 2018

@MartinNowack , do you know why the Travis logs are so verbose since the switch to Docker? It would be nice to reduce verbosity a bit if possible.

@MartinNowack
Copy link
Contributor

@ccadar Yes, that't true - but that is only when they are building LLVM. Otherwise it should be much shorter.

@ccadar
Copy link
Contributor

ccadar commented Jul 10, 2018

But why was LLVM built? I thought we don't do this. Also, what was the source of the initial Travis CI failures? (I see you restarted it and it worked the second time)

@MartinNowack
Copy link
Contributor

@ccadar The llvm images were not built/rebuild to fix a bug with the coverage.
The original source of the Travis CI build was a timeout of the build it's restricted to 50min (and cannot be extended). The actual run can be extended.

Copy link
Contributor

@MartinNowack MartinNowack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jirislaby I like the changes.
Please:

  • fix my minor comments
  • rebase
  • merge commits

Beside that, I think we are ready to go.

@@ -162,8 +162,12 @@ static bool linkTwoModules(llvm::Module *Dest,
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be rearranged as the error message is not propagated anymore.
Therefore we have to generate our own.

#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
   // Get the potential error message (Src is moved and won't be available later)
   errorMsg =
           "Linking module " + src->getModuleIdentifier() + " failed";

   auto linkResult = Linker::linkModules(*Dest, std::move(Src));
#else if LLVM_VERSION_CODE >= LLVM_VERSION(3,6)
...

std::error_code ec = memberNameErr.getError();
std::error_code ec;
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
ErrorOr<object::Archive::Child> childErr = *AI;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use auto if possible.
I would prefere childOrErr to indicate that it contains a child or an error.

return false;
}
#else
object::Archive::child_iterator childErr = AI;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

auto as well.

The rounding was removed because it was never needed:
llvm-mirror/llvm@ff278be

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
createFunctionAttrsPass was split to createPostOrderFunctionAttrsPass
and createReversePostOrderFunctionAttrsPass in LLVM commit e96fb9ab15d4.

createGlobalsModRefPass was changed to createGlobalsAAWrapperPass in
LLVM commit 9146833fa313.

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
No need to flush it, see llvm-mirror/llvm@d4177b2

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
@jirislaby
Copy link
Contributor Author

@MartinNowack rebaed and fixed. What do you mean by merging commits? You mean squash them together? But as we did for llvm 3.7, the multiple commits are easier to follow (even in history).

@MartinNowack
Copy link
Contributor

@jirislaby Yes, i meant merging them but looking at your messages. I'm fine with it.

@MartinNowack
Copy link
Contributor

@jirislaby
Sorry, typo - capital S.

"Linking module " + src->getModuleIdentifier() + " failed";

Should be:

 "Linking module " + Src->getModuleIdentifier() + " failed";

LLVM commit d912be98f8eb changed the prototype of linkModules to accept
std::unique_ptr. Adapt to that.

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
jirislaby and others added 4 commits July 12, 2018 22:26
After LLVM commit 25569fdcdab0, archive iterator returns
object::Archive::Child instead of child_iterator, adapt to that.

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
LLVM commit eac309550f25 removed implicit iterator conversions. So we
have to get the iterators explicitly now.

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
alias in LLVM 3.8 has a new format, it adds an AliaseeTy parameter. So
handle this in the tests.

[v2] add comments about what was changed and why

Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
@MartinNowack
Copy link
Contributor

@jirislaby Thanks a lot for your hard work. The zero change in coverage for diff is expected as LLVM 3.8 code is not exercised for coverage runs. Reduction in general is also expected, new code is added but additional code not tested.
Anyway, first coreutils tests run well. Let's give it a go. Going to merge.

@MartinNowack MartinNowack merged commit 79ac709 into klee:master Jul 12, 2018
@jirislaby jirislaby deleted the llvm_38 branch July 13, 2018 06:44
@jbuening jbuening mentioned this pull request Jul 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants