Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
8f4de7a
DeInlineAsm: Fix reference to "SingleThread"
dtzWill Sep 19, 2017
2a73c4b
StaticCodeGen: fix setFunctionAttributes, model after upstream.
dtzWill Sep 19, 2017
4f0623b
StaticCodeGen: KLUDGE: fix build, emit warning so this isn't forgotten.
dtzWill Sep 19, 2017
63d9131
lit/deasm-barrier: fix test for new fence IR format
dtzWill Sep 19, 2017
7185c85
StaticCodeGen: formatting, whoops
dtzWill Sep 19, 2017
1dc9a57
Fix API usage: don't terminate varargs with nullptr
dtzWill Oct 19, 2017
35656fc
lit: Set XDG_CACHE_HOME to accomodate changed behavior
dtzWill Oct 19, 2017
cd54eb7
allmux/*: formatting
dtzWill Oct 23, 2017
cab2a16
StaticCodeGen: avoid using stdio on non-x86_64
dtzWill Feb 21, 2018
8c392c0
default to clang5 build on llvm5 branch
dtzWill Feb 26, 2018
ddd5350
update-format
dtzWill Feb 26, 2018
a65c023
StaticCodeGen: move comment to avoid silly placement
dtzWill Feb 26, 2018
a11ca83
overlay: use llvm_5, lost in rebased merge
dtzWill Feb 26, 2018
66c6c31
update-format
dtzWill Feb 26, 2018
39a07fd
llvm6: use keyword syntax for target_link_libraries, fix build
dtzWill Jan 31, 2018
f216898
ZipArchive: WritableMemoryBuffer (LLVM 6 API update)
dtzWill Jan 31, 2018
25f182b
StaticCodeGen: DiagnosticHandler, ToolOutputFile (LLVM6-ify)
dtzWill Jan 31, 2018
34ae319
fixup all tool_output_file refs (LLVM6-ify)
dtzWill Jan 31, 2018
09e1ace
ALLVMLinker: redirects (LLVM6-ify)
dtzWill Jan 31, 2018
783c942
alld: includes, linking (LLVM6-ify)
dtzWill Jan 31, 2018
f7d2050
alley: don't include CommandFlags.h ? (LLVM6-ify)
dtzWill Jan 31, 2018
b6f3457
allopt: redirects are Optional<StringRef> now (LLVM6-ify)
dtzWill Jan 31, 2018
bb82241
allready: drop CommandFlags.h include (LLVM6-ify)
dtzWill Jan 31, 2018
78e026c
alltogether: include CommandFlags.def (LLVM6-ify)
dtzWill Jan 31, 2018
896befe
wllvm-extract: writeArchive returns Error now (LLVM6-ify)
dtzWill Jan 31, 2018
a556039
test: fixup llvm-lit discovery, just always use local (LLVM6-ify)
dtzWill Jan 31, 2018
a32ec25
StaticCodeGen: fix breakage in diagnosticHandler usage (LLVM6-ify)
dtzWill Jan 31, 2018
a56bff0
update-format
dtzWill Jan 31, 2018
5f3cdd4
ToolCommon: capture var instead of static, now that API lets us
dtzWill Feb 20, 2018
82b6330
update-format
dtzWill Feb 20, 2018
09c9fc6
set version printer later on llvm6
dtzWill Feb 20, 2018
6d2553b
overlay: whoops, llvm6
dtzWill Feb 26, 2018
447c022
default.nix: use clang6 by default
dtzWill Feb 26, 2018
7ba546a
alld: fix include missed during rebase
dtzWill Feb 26, 2018
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-clang6;
}
13 changes: 4 additions & 9 deletions include/allvm/ToolCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ class ALLVMTool {
llvm::cl::OptionCategory ALLVMOptCat{CatName};

auto getVersionPrinter() {
static std::string CapturedName = Name;
return []() {
llvm::raw_ostream &OS = llvm::outs();
OS << CapturedName << " (ALLVM Tools) " << allvm::getALLVMVersion()
<< "\n";
return [Name = this->Name](auto &OS) {
OS << Name << " (ALLVM Tools) " << allvm::getALLVMVersion() << "\n";
OS << " ALLVM Project (http://allvm.org)\n";
OS << " LLVM version " << LLVM_VERSION_STRING << "\n";

Expand All @@ -44,18 +41,16 @@ class ALLVMTool {
OS << ".\n"
<< " Default target: " << llvm::sys::getDefaultTargetTriple() << '\n'
<< " Host CPU: " << CPU << '\n';

};
}

public:
ALLVMTool(llvm::StringRef _Name, llvm::StringRef _Overview = "")
: Name(_Name), Overview(_Overview) {
llvm::cl::SetVersionPrinter(getVersionPrinter());
}
: Name(_Name), Overview(_Overview) {}

bool parseCLOpts(int argc, const char *const *argv) {
llvm::cl::HideUnrelatedOptions(ALLVMOptCat);
llvm::cl::SetVersionPrinter(getVersionPrinter());
return llvm::cl::ParseCommandLineOptions(argc, argv, Overview);
}

Expand Down
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
2 changes: 1 addition & 1 deletion libs/StaticCodeGen/ALLVMLinker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Error ALLVMLinker::callLinkerAsExternalProcess(StringRef LinkerProgram,
bool ExecutionFailed;
std::string ErrorMsg;
int Res = llvm::sys::ExecuteAndWait(LinkerProgram, LinkerArgv,
/*env*/ nullptr, /*Redirects*/ nullptr,
/*env*/ nullptr, /*Redirects*/ {},
/*secondsToWait*/ 0, /*memoryLimit*/ 0,
&ErrorMsg, &ExecutionFailed);

Expand Down
88 changes: 48 additions & 40 deletions libs/StaticCodeGen/StaticCodeGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,27 @@ using namespace allvm;
using namespace llvm;
using namespace object;

namespace {
struct LLCDiagnosticHandler : public DiagnosticHandler {
bool *HasError;
LLCDiagnosticHandler(bool *HasErrorPtr) : HasError(HasErrorPtr) {}
bool handleDiagnostics(const DiagnosticInfo &DI) override {
if (DI.getSeverity() == DS_Error)
*HasError = true;

if (auto *Remark = dyn_cast<DiagnosticInfoOptimizationBase>(&DI))
if (!Remark->isEnabled())
return true;

DiagnosticPrinterRawOStream DP(errs());
errs() << LLVMContext::getDiagnosticMessagePrefix(DI.getSeverity()) << ": ";
DI.print(DP);
errs() << "\n";
return true;
}
};
} // end anonymous namespace

static inline std::string getCPUStr(StringRef MCPU) {
// If user asked for the 'native' CPU, autodetect here. If autodection fails,
// this will set the CPU to an empty string which tells the target to
Expand Down Expand Up @@ -67,29 +88,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 +115,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 @@ -184,30 +201,14 @@ static Error compileModule(std::unique_ptr<Module> &M, raw_pwrite_stream &OS,
// Run passes to do compilation.
PM.run(*M);

auto HasError = *static_cast<bool *>(Context.getDiagnosticContext());
// TODO: Produce better error message?
if (HasError) {
auto HasError =
((const LLCDiagnosticHandler *)(Context.getDiagHandlerPtr()))->HasError;
if (*HasError)
return makeStaticCodeGenError("unknown error compiling to object file");
}

return Error::success();
}

static void DiagnosticHandler(const DiagnosticInfo &DI, void *Context) {
bool *HasError = static_cast<bool *>(Context);
if (DI.getSeverity() == DS_Error)
*HasError = true;

if (auto *Remark = dyn_cast<DiagnosticInfoOptimizationBase>(&DI))
if (!Remark->isEnabled())
return;

DiagnosticPrinterRawOStream DP(errs());
errs() << LLVMContext::getDiagnosticMessagePrefix(DI.getSeverity()) << ": ";
DI.print(DP);
errs() << "\n";
}

namespace allvm {

Error compileAllexe(Allexe &Input, raw_pwrite_stream &OS,
Expand All @@ -217,7 +218,8 @@ Error compileAllexe(Allexe &Input, raw_pwrite_stream &OS,

// Set a diagnostic handler that doesn't exit on the first error.
bool HasError = false;
Context.setDiagnosticHandler(DiagnosticHandler, &HasError);
Context.setDiagnosticHandler(
llvm::make_unique<LLCDiagnosticHandler>(&HasError));

// Get module to be compiled.
auto ExpM = Input.getModule(0, Context);
Expand All @@ -233,7 +235,7 @@ Error compileAllexe(Allexe &Input, raw_pwrite_stream &OS,

// Initialize compilation flags to the llc default values.
CompilationOptions::CompilationOptions()
: CMModel(CodeModel::Default), RelocModel(None), OLvl(CodeGenOpt::Default),
: CMModel(CodeModel::Small), RelocModel(None), OLvl(CodeGenOpt::Default),
NoVerify(false), DisableSimplifyLibCalls(false), DisableFPElim(None),
DisableTailCalls(None), StackRealign(false), TrapFuncName(None) {

Expand Down Expand Up @@ -271,9 +273,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 +294,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 Expand Up @@ -351,7 +359,7 @@ compileAllexe(Allexe &Input, StringRef Filename,
// Open the output file.
std::error_code EC;
sys::fs::OpenFlags OpenFlags = sys::fs::F_None;
auto FDOut = llvm::make_unique<tool_output_file>(Filename, EC, OpenFlags);
auto FDOut = llvm::make_unique<ToolOutputFile>(Filename, EC, OpenFlags);
if (EC) {
return makeStaticCodeGenError("error opening compilation output", EC);
}
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 libs/archive-rw/ZipArchive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ std::unique_ptr<MemoryBuffer> ZipArchive::getEntry(size_t index,
zip_stat_t statinfo;
zip_stat_index(archive, index, 0, &statinfo);
std::unique_ptr<MemoryBuffer> buf =
MemoryBuffer::getNewUninitMemBuffer(statinfo.size, files[index]);
WritableMemoryBuffer::getNewUninitMemBuffer(statinfo.size, files[index]);

// Decompress the file into the buffer.
zip_file_t *fd = zip_fopen_index(archive, index, 0);
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_6) llvm clang lld;
};

allvm-tools-variants = super.recurseIntoAttrs {
Expand Down
11 changes: 1 addition & 10 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,7 @@ set(ALLVM_TEST_PARAMS
set(LIT_REPORT ${CMAKE_CURRENT_BINARY_DIR}/report.xml)
set(ALLVM_TEST_EXTRA_ARGS --no-progress-bar -v --xunit-xml-output=${LIT_REPORT})

# try to find 'lit'
find_program(LIT_COMMAND llvm-lit)
if (EXISTS ${LLVM_INSTALL_PREFIX}/lit/lit.py)
set(LIT_COMMAND ${LLVM_INSTALL_PREFIX}/lit/lit.py)
endif()
if (NOT LIT_COMMAND)
set(LIT_COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/third_party/lit/lit.py)
endif()
set(LLVM_EXTERNAL_LIT ${CMAKE_SOURCE_DIR}/third_party/lit/lit.py)

# Check we have FileCheck utility, as indicator of the LLVM utilities.
find_program(FILECHECK_PATH FileCheck HINTS ${LLVM_TOOLS_BINARY_DIR})
Expand All @@ -56,5 +49,3 @@ add_lit_testsuites(ALLVM ${CMAKE_CURRENT_SOURCE_DIR}
PARAMS ${ALLVM_TEST_PARAMS}
DEPENDS ${ALLVM_TEST_DEPENDS}
)

message(STATUS "Using lit command: ${LIT_COMMAND}")
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
2 changes: 1 addition & 1 deletion tools/all-info/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ add_llvm_tool(all-info
all-info.cpp
)

target_link_libraries(all-info liball ResourcePaths)
target_link_libraries(all-info PRIVATE liball ResourcePaths)

add_definitions(${LLVM_DEFINITIONS})
2 changes: 1 addition & 1 deletion tools/alld/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ add_llvm_tool(alld
alld.cpp
)

target_link_libraries(alld ResourcePaths lldELF lldConfig lldCore)
target_link_libraries(alld PRIVATE ResourcePaths lldELF lldCommon)

llvm_config(alld
# These are taken directly from lld/ELF/CMakeLists.txt:
Expand Down
2 changes: 1 addition & 1 deletion tools/alld/alld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// Linker wrapper for lld.
//
//===----------------------------------------------------------------------===//
#include <lld/Driver/Driver.h>
#include <lld/Common/Driver.h>

#include <llvm/Support/ManagedStatic.h>
#include <llvm/Support/PrettyStackTrace.h>
Expand Down
1 change: 1 addition & 0 deletions tools/alley/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ add_llvm_tool(alley
alley.cpp
)
target_link_libraries(alley
PRIVATE
liball
AOTCompile
Cache
Expand Down
3 changes: 2 additions & 1 deletion tools/alley/alley.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#include "allvm/ResourceAnchor.h"
#include "allvm/ToolCommon.h"

#include <llvm/CodeGen/CommandFlags.h>
// XXX: Revisit this
//#include <llvm/CodeGen/CommandFlags.h>
#include <llvm/ExecutionEngine/MCJIT.h>
#include <llvm/IR/LLVMContext.h>
#include <llvm/IR/Module.h>
Expand Down
2 changes: 1 addition & 1 deletion tools/allmux/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ add_llvm_tool(allmux
allmux.cpp
CtorUtils.cpp
)
target_link_libraries(allmux liball Passes ResourcePaths)
target_link_libraries(allmux PRIVATE liball Passes ResourcePaths)

set(MM_BC ${CMAKE_CURRENT_SOURCE_DIR}/main/mux_main.bc)
install(FILES ${MM_BC} DESTINATION lib)
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/allopt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ add_llvm_tool(allopt
allopt.cpp
)

target_link_libraries(allopt liball ResourcePaths)
target_link_libraries(allopt PRIVATE liball ResourcePaths)

add_definitions(${LLVM_DEFINITIONS})
Loading