From 8f4de7a0725a14e4ccdf5448f2748736b0fa8014 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Tue, 19 Sep 2017 11:18:50 -0500 Subject: [PATCH 01/14] DeInlineAsm: Fix reference to "SingleThread" --- libs/Passes/DeInlineAsm.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libs/Passes/DeInlineAsm.cpp b/libs/Passes/DeInlineAsm.cpp index 2b6ada0f..39337c6d 100644 --- a/libs/Passes/DeInlineAsm.cpp +++ b/libs/Passes/DeInlineAsm.cpp @@ -36,8 +36,9 @@ class InlineAsmVisitor : public InstVisitor { // Handle "compiler barrier" idiom StringRef constraintString = inlineAsm->getConstraintString(); if (constraintString == "~{memory},~{dirflag},~{fpsr},~{flags}") { - replacement = new FenceInst( - M->getContext(), AtomicOrdering::AcquireRelease, SingleThread, &I); + replacement = + new FenceInst(M->getContext(), AtomicOrdering::AcquireRelease, + SyncScope::SingleThread, &I); } } else { SmallVector asmPieces; From 2a73c4bc1060feb4cf57a31e218dedb2883d6cf0 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Tue, 19 Sep 2017 11:34:48 -0500 Subject: [PATCH 02/14] StaticCodeGen: fix setFunctionAttributes, model after upstream. (this function is from CodeGen/CommandFlags.h but takes the build options as parameters instead of looking to globals) --- libs/StaticCodeGen/StaticCodeGen.cpp | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/libs/StaticCodeGen/StaticCodeGen.cpp b/libs/StaticCodeGen/StaticCodeGen.cpp index d0817863..333c2acf 100644 --- a/libs/StaticCodeGen/StaticCodeGen.cpp +++ b/libs/StaticCodeGen/StaticCodeGen.cpp @@ -67,29 +67,25 @@ static inline void setFunctionAttributes(StringRef CPU, StringRef Features, Module &M) { for (auto &F : M) { auto &Ctx = F.getContext(); - AttributeSet Attrs = F.getAttributes(), NewAttrs; + AttributeList Attrs = F.getAttributes(); + AttrBuilder NewAttrs; if (!CPU.empty()) - NewAttrs = NewAttrs.addAttribute(Ctx, AttributeSet::FunctionIndex, - "target-cpu", CPU); + NewAttrs.addAttribute( "target-cpu", CPU); if (!Features.empty()) - NewAttrs = NewAttrs.addAttribute(Ctx, AttributeSet::FunctionIndex, - "target-features", Features); + NewAttrs.addAttribute("target-features", Features); if (DisableFPElim.hasValue()) - NewAttrs = NewAttrs.addAttribute( - Ctx, AttributeSet::FunctionIndex, "no-frame-pointer-elim", + NewAttrs.addAttribute("no-frame-pointer-elim", DisableFPElim.getValue() ? "true" : "false"); if (DisableTailCalls.hasValue()) - NewAttrs = NewAttrs.addAttribute( - Ctx, AttributeSet::FunctionIndex, "disable-tail-calls", + NewAttrs.addAttribute("disable-tail-calls", toStringRef(DisableTailCalls.getValue())); if (StackRealign) - NewAttrs = NewAttrs.addAttribute(Ctx, AttributeSet::FunctionIndex, - "stackrealign"); + NewAttrs.addAttribute("stackrealign"); if (TrapFuncName.hasValue()) for (auto &B : F) @@ -98,13 +94,13 @@ static inline void setFunctionAttributes(StringRef CPU, StringRef Features, if (const auto *Callee = Call->getCalledFunction()) if (Callee->getIntrinsicID() == Intrinsic::debugtrap || Callee->getIntrinsicID() == Intrinsic::trap) - Call->addAttribute(AttributeSet::FunctionIndex, + Call->addAttribute(AttributeList::FunctionIndex, Attribute::get(Ctx, "trap-func-name", TrapFuncName.getValue())); // Let NewAttrs override Attrs. - NewAttrs = Attrs.addAttributes(Ctx, AttributeSet::FunctionIndex, NewAttrs); - F.setAttributes(NewAttrs); + F.setAttributes( + Attrs.addAttributes(Ctx, AttributeList::FunctionIndex, NewAttrs)); } } From 4f0623b8ed9d114d273eb8b1cd59dd0c5215ac66 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Tue, 19 Sep 2017 11:36:29 -0500 Subject: [PATCH 03/14] StaticCodeGen: KLUDGE: fix build, emit warning so this isn't forgotten. --- libs/StaticCodeGen/StaticCodeGen.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libs/StaticCodeGen/StaticCodeGen.cpp b/libs/StaticCodeGen/StaticCodeGen.cpp index 333c2acf..11ef245a 100644 --- a/libs/StaticCodeGen/StaticCodeGen.cpp +++ b/libs/StaticCodeGen/StaticCodeGen.cpp @@ -268,8 +268,9 @@ std::string CompilationOptions::serializeCompilationOptions() const { // Serialize OLvl buffer += std::to_string(OLvl); // Serialize TargetOptions + errs() << "Using incomplete serialization of compilation options, FIXME!\n"; buffer += std::to_string(TOptions.PrintMachineCode); - buffer += std::to_string(TOptions.LessPreciseFPMADOption); + // buffer += std::to_string(TOptions.LessPreciseFPMADOption); buffer += std::to_string(TOptions.UnsafeFPMath); buffer += std::to_string(TOptions.NoInfsFPMath); buffer += std::to_string(TOptions.NoNaNsFPMath); @@ -282,7 +283,7 @@ std::string CompilationOptions::serializeCompilationOptions() const { buffer += std::to_string(TOptions.EnableFastISel); buffer += std::to_string(TOptions.UseInitArray); buffer += std::to_string(TOptions.DisableIntegratedAS); - buffer += std::to_string(TOptions.CompressDebugSections); + buffer += std::to_string(static_cast(TOptions.CompressDebugSections)); buffer += std::to_string(TOptions.RelaxELFRelocations); buffer += std::to_string(TOptions.FunctionSections); buffer += std::to_string(TOptions.DataSections); From 63d91314c13bf29ca16ee42c3d18b4fd6adb2533 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Tue, 19 Sep 2017 11:47:10 -0500 Subject: [PATCH 04/14] lit/deasm-barrier: fix test for new fence IR format --- test/lit/deasm-barrier.ll | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/lit/deasm-barrier.ll b/test/lit/deasm-barrier.ll index 5cbe04e3..82f26625 100644 --- a/test/lit/deasm-barrier.ll +++ b/test/lit/deasm-barrier.ll @@ -2,7 +2,7 @@ ; __asm__ __volatile__ ("" ::: "memory") ; Which can be replaced with C11 'atomic_signal_fence(memory_order_acq_rel)' ; In LLVM IR that becomes (at least in my sample program) -; 'fence singlethread acq_rel' +; 'fence syncscope("singlethread") acq_rel' ; https://en.wikipedia.org/wiki/Memory_ordering#Compile-time_memory_barrier_implementation ; http://en.cppreference.com/w/c/atomic/atomic_signal_fence @@ -15,7 +15,7 @@ ; RUN: allopt -analyze -i %t llvm-dis |& FileCheck %s ; CHECK-NOT: call {{.*}} asm -; CHECK: fence singlethread acq_rel +; CHECK: fence syncscope("singlethread") acq_rel ; CHECK-NOT: call {{.*}} asm ; ModuleID = 'barrier.c' From 7185c8502e656befdc38283f727d14fba6370038 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Tue, 19 Sep 2017 13:22:22 -0500 Subject: [PATCH 05/14] StaticCodeGen: formatting, whoops --- libs/StaticCodeGen/StaticCodeGen.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/StaticCodeGen/StaticCodeGen.cpp b/libs/StaticCodeGen/StaticCodeGen.cpp index 11ef245a..9f9c3bb6 100644 --- a/libs/StaticCodeGen/StaticCodeGen.cpp +++ b/libs/StaticCodeGen/StaticCodeGen.cpp @@ -71,18 +71,18 @@ static inline void setFunctionAttributes(StringRef CPU, StringRef Features, AttrBuilder NewAttrs; if (!CPU.empty()) - NewAttrs.addAttribute( "target-cpu", CPU); + NewAttrs.addAttribute("target-cpu", CPU); if (!Features.empty()) NewAttrs.addAttribute("target-features", Features); if (DisableFPElim.hasValue()) NewAttrs.addAttribute("no-frame-pointer-elim", - DisableFPElim.getValue() ? "true" : "false"); + DisableFPElim.getValue() ? "true" : "false"); if (DisableTailCalls.hasValue()) NewAttrs.addAttribute("disable-tail-calls", - toStringRef(DisableTailCalls.getValue())); + toStringRef(DisableTailCalls.getValue())); if (StackRealign) NewAttrs.addAttribute("stackrealign"); From 1dc9a572f8337bf38b36b29123a6533a9b96d4d0 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Thu, 19 Oct 2017 14:26:01 -0500 Subject: [PATCH 06/14] Fix API usage: don't terminate varargs with nullptr --- tools/allmux/CtorUtils.cpp | 2 +- tools/allmux/allmux.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/allmux/CtorUtils.cpp b/tools/allmux/CtorUtils.cpp index d0fe41e2..a6805cf1 100644 --- a/tools/allmux/CtorUtils.cpp +++ b/tools/allmux/CtorUtils.cpp @@ -103,7 +103,7 @@ Function *allvm::createCtorDtorFunc(ArrayRef Fns, Module &M, // just create the function as whatever and then call setName() or something? auto NameS = Name.str(); auto *F = cast( - M.getOrInsertFunction(NameS, Builder.getVoidTy(), nullptr)); + M.getOrInsertFunction(NameS, Builder.getVoidTy())); Builder.SetInsertPoint(BasicBlock::Create(C, "entry", F)); diff --git a/tools/allmux/allmux.cpp b/tools/allmux/allmux.cpp index a1396e25..efd6662b 100644 --- a/tools/allmux/allmux.cpp +++ b/tools/allmux/allmux.cpp @@ -155,7 +155,7 @@ Expected> genMain(ArrayRef Es, LLVMContext &C, assert(AtExit); auto getCtorDtorFn = [&](auto FName) { - return MuxMain->getOrInsertFunction(FName, Builder.getVoidTy(), nullptr); + return MuxMain->getOrInsertFunction(FName, Builder.getVoidTy()); }; auto callCtor = [&](auto FName) { Builder.CreateCall(getCtorDtorFn(FName)); From 35656fc610849abbfa5936beee84549f5be7b383 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Thu, 19 Oct 2017 15:37:41 -0500 Subject: [PATCH 07/14] lit: Set XDG_CACHE_HOME to accomodate changed behavior Not really sure /why/ but user_cache_directory is now returning "successfully" but seems to think HOME is "/", which doesn't seem right AFAICT. nix build users have home of /var/empty and HOME=/homeless-shelter... --- test/lit.site.cfg.in | 1 + 1 file changed, 1 insertion(+) diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.in index 5e2f445c..bdd1b90b 100644 --- a/test/lit.site.cfg.in +++ b/test/lit.site.cfg.in @@ -17,6 +17,7 @@ curpath = os.environ.get('PATH', '') if curpath: newpath += ":" + curpath config.environment['PATH'] = newpath +config.environment['XDG_CACHE_HOME'] = config.test_exec_root + "/cache"; # TODO: Get this more reliably/directly: " = @LIBNONE_PATH@" or something libnone = "@LLVM_LIBRARY_OUTPUT_INTDIR@/libnone.a" From cd54eb7d54759d25e78144c42b4db33efaca7e0f Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Mon, 23 Oct 2017 14:49:55 -0500 Subject: [PATCH 08/14] allmux/*: formatting --- tools/allmux/CtorUtils.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/allmux/CtorUtils.cpp b/tools/allmux/CtorUtils.cpp index a6805cf1..56411b52 100644 --- a/tools/allmux/CtorUtils.cpp +++ b/tools/allmux/CtorUtils.cpp @@ -102,8 +102,7 @@ Function *allvm::createCtorDtorFunc(ArrayRef Fns, Module &M, // TODO: Better handle case where function with this name already exists; // just create the function as whatever and then call setName() or something? auto NameS = Name.str(); - auto *F = cast( - M.getOrInsertFunction(NameS, Builder.getVoidTy())); + auto *F = cast(M.getOrInsertFunction(NameS, Builder.getVoidTy())); Builder.SetInsertPoint(BasicBlock::Create(C, "entry", F)); From cab2a161b328859f0cfbecdfdb5b69d3e9687879 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Tue, 20 Feb 2018 18:41:05 -0600 Subject: [PATCH 09/14] StaticCodeGen: avoid using stdio on non-x86_64 --- libs/StaticCodeGen/StaticCodeGen.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/StaticCodeGen/StaticCodeGen.cpp b/libs/StaticCodeGen/StaticCodeGen.cpp index 9f9c3bb6..8e77d123 100644 --- a/libs/StaticCodeGen/StaticCodeGen.cpp +++ b/libs/StaticCodeGen/StaticCodeGen.cpp @@ -268,7 +268,11 @@ std::string CompilationOptions::serializeCompilationOptions() const { // Serialize OLvl buffer += std::to_string(OLvl); // Serialize TargetOptions +#ifdef __x86_64__ errs() << "Using incomplete serialization of compilation options, FIXME!\n"; +#else +#warning "Unable to emit runtime warning that serialization of compilation options is incomplete!" +#endif buffer += std::to_string(TOptions.PrintMachineCode); // buffer += std::to_string(TOptions.LessPreciseFPMADOption); buffer += std::to_string(TOptions.UnsafeFPMath); From 8c392c03b9f5bc4744b555ee63d29016c6bb5600 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Mon, 26 Feb 2018 14:11:57 -0600 Subject: [PATCH 10/14] default to clang5 build on llvm5 branch --- default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default.nix b/default.nix index 9990bd74..6d656284 100644 --- a/default.nix +++ b/default.nix @@ -3,5 +3,5 @@ let release = import ./nix/release.nix args; in { - allvm-tools = release.musl.allvm-tools-clang4; + allvm-tools = release.musl.allvm-tools-clang5; } From ddd535065ca1fd8a6939e6fcd83ca9680a84e119 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Mon, 26 Feb 2018 15:48:09 -0600 Subject: [PATCH 11/14] update-format $ nix-shell ./format.nix -A update --- libs/StaticCodeGen/StaticCodeGen.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libs/StaticCodeGen/StaticCodeGen.cpp b/libs/StaticCodeGen/StaticCodeGen.cpp index 8e77d123..175393a1 100644 --- a/libs/StaticCodeGen/StaticCodeGen.cpp +++ b/libs/StaticCodeGen/StaticCodeGen.cpp @@ -267,11 +267,12 @@ std::string CompilationOptions::serializeCompilationOptions() const { } // Serialize OLvl buffer += std::to_string(OLvl); - // Serialize TargetOptions +// Serialize TargetOptions #ifdef __x86_64__ errs() << "Using incomplete serialization of compilation options, FIXME!\n"; #else -#warning "Unable to emit runtime warning that serialization of compilation options is incomplete!" +#warning \ + "Unable to emit runtime warning that serialization of compilation options is incomplete!" #endif buffer += std::to_string(TOptions.PrintMachineCode); // buffer += std::to_string(TOptions.LessPreciseFPMADOption); From a65c0234630405009739b0babb200840120ef619 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Mon, 26 Feb 2018 15:49:10 -0600 Subject: [PATCH 12/14] StaticCodeGen: move comment to avoid silly placement --- libs/StaticCodeGen/StaticCodeGen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/StaticCodeGen/StaticCodeGen.cpp b/libs/StaticCodeGen/StaticCodeGen.cpp index 175393a1..ad20ab99 100644 --- a/libs/StaticCodeGen/StaticCodeGen.cpp +++ b/libs/StaticCodeGen/StaticCodeGen.cpp @@ -267,13 +267,13 @@ std::string CompilationOptions::serializeCompilationOptions() const { } // Serialize OLvl buffer += std::to_string(OLvl); -// Serialize TargetOptions #ifdef __x86_64__ errs() << "Using incomplete serialization of compilation options, FIXME!\n"; #else #warning \ "Unable to emit runtime warning that serialization of compilation options is incomplete!" #endif + // Serialize TargetOptions buffer += std::to_string(TOptions.PrintMachineCode); // buffer += std::to_string(TOptions.LessPreciseFPMADOption); buffer += std::to_string(TOptions.UnsafeFPMath); From a11ca833ad7baffb44ebe092fd6cda8acf3fc462 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Mon, 26 Feb 2018 15:54:08 -0600 Subject: [PATCH 13/14] overlay: use llvm_5, lost in rebased merge --- nix/overlay.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nix/overlay.nix b/nix/overlay.nix index 2f10b3b0..335bb415 100644 --- a/nix/overlay.nix +++ b/nix/overlay.nix @@ -1,6 +1,6 @@ self: super: rec { allvm-tools = super.callPackage ./build.nix { - inherit (self.llvmPackages_4) llvm clang lld; + inherit (self.llvmPackages_5) llvm clang lld; }; allvm-tools-variants = super.recurseIntoAttrs { From 66c6c31c73f6e3fac3c7af71f0de50c6bdb04a56 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Mon, 26 Feb 2018 15:55:44 -0600 Subject: [PATCH 14/14] update-format --- libs/all/Allexe.cpp | 2 +- tools/wllvm-extract/wllvm-extract.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/all/Allexe.cpp b/libs/all/Allexe.cpp index 98aa63c7..43632351 100644 --- a/libs/all/Allexe.cpp +++ b/libs/all/Allexe.cpp @@ -25,7 +25,7 @@ static std::unique_ptr moduleToBuffer(const Module *M) { false, // ShouldPreserveUseListOrder nullptr, // ModuleSummaryIndex (ThinLTO) true // Generate Hash - ); + ); return MemoryBuffer::getMemBufferCopy(OS.str()); } diff --git a/tools/wllvm-extract/wllvm-extract.cpp b/tools/wllvm-extract/wllvm-extract.cpp index 44e93df4..65d01a2e 100644 --- a/tools/wllvm-extract/wllvm-extract.cpp +++ b/tools/wllvm-extract/wllvm-extract.cpp @@ -109,7 +109,7 @@ static Error writeAsSingleBC(const WLLVMFile &File, StringRef Filename) { false, // ShouldPreserveUseListOrder nullptr, // ModuleSummaryIndex (ThinLTO) true // Generate Hash - ); + ); // We made it this far without error, keep the result. Out->keep(); return Error::success();