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

[WIP] update to LLVM 5 #21

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
5 changes: 3 additions & 2 deletions libs/Passes/DeInlineAsm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ class InlineAsmVisitor : public InstVisitor<InlineAsmVisitor> {
// 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<StringRef, 3> asmPieces;
Expand Down
38 changes: 20 additions & 18 deletions libs/StaticCodeGen/StaticCodeGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
DisableFPElim.getValue() ? "true" : "false");
NewAttrs.addAttribute("no-frame-pointer-elim",
DisableFPElim.getValue() ? "true" : "false");

if (DisableTailCalls.hasValue())
NewAttrs = NewAttrs.addAttribute(
Ctx, AttributeSet::FunctionIndex, "disable-tail-calls",
toStringRef(DisableTailCalls.getValue()));
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)
Expand All @@ -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));
}
}

Expand Down Expand Up @@ -271,9 +267,15 @@ std::string CompilationOptions::serializeCompilationOptions() const {
}
// Serialize OLvl
buffer += std::to_string(OLvl);
#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.LessPreciseFPMADOption);
buffer += std::to_string(TOptions.UnsafeFPMath);
buffer += std::to_string(TOptions.NoInfsFPMath);
buffer += std::to_string(TOptions.NoNaNsFPMath);
Expand All @@ -286,7 +288,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<int>(TOptions.CompressDebugSections));
buffer += std::to_string(TOptions.RelaxELFRelocations);
buffer += std::to_string(TOptions.FunctionSections);
buffer += std::to_string(TOptions.DataSections);
Expand Down
2 changes: 1 addition & 1 deletion libs/all/Allexe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static std::unique_ptr<MemoryBuffer> moduleToBuffer(const Module *M) {
false, // ShouldPreserveUseListOrder
nullptr, // ModuleSummaryIndex (ThinLTO)
true // Generate Hash
);
);
return MemoryBuffer::getMemBufferCopy(OS.str());
}

Expand Down
2 changes: 1 addition & 1 deletion nix/overlay.nix
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
1 change: 1 addition & 0 deletions test/lit.site.cfg.in
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions test/lit/deasm-barrier.ll
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand Down
3 changes: 1 addition & 2 deletions tools/allmux/CtorUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,7 @@ Function *allvm::createCtorDtorFunc(ArrayRef<Constant *> 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<Function>(
M.getOrInsertFunction(NameS, Builder.getVoidTy(), nullptr));
auto *F = cast<Function>(M.getOrInsertFunction(NameS, Builder.getVoidTy()));

Builder.SetInsertPoint(BasicBlock::Create(C, "entry", F));

Expand Down
2 changes: 1 addition & 1 deletion tools/allmux/allmux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ Expected<std::unique_ptr<Module>> genMain(ArrayRef<Entry> 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));
Expand Down
2 changes: 1 addition & 1 deletion tools/wllvm-extract/wllvm-extract.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down