Rebase to the llvm-project monorepo

The new git submodule src/llvm-project is a monorepo replacing src/llvm
and src/tools/{clang,lld,lldb}.  This also serves as a rebase for these
projects to the new 8.x branch from trunk.

The src/llvm-emscripten fork is unchanged for now.
This commit is contained in:
Josh Stone 2019-01-16 09:59:03 -08:00
parent bf669d1e32
commit df0466d0bb
18 changed files with 166 additions and 65 deletions

21
.gitmodules vendored
View File

@ -1,7 +1,3 @@
[submodule "src/llvm"]
path = src/llvm
url = https://github.com/rust-lang/llvm.git
branch = master
[submodule "src/rust-installer"]
path = src/tools/rust-installer
url = https://github.com/rust-lang/rust-installer.git
@ -38,20 +34,13 @@
[submodule "src/stdsimd"]
path = src/stdsimd
url = https://github.com/rust-lang-nursery/stdsimd.git
[submodule "src/tools/lld"]
path = src/tools/lld
url = https://github.com/rust-lang/lld.git
[submodule "src/tools/lldb"]
path = src/tools/lldb
url = https://github.com/rust-lang-nursery/lldb.git
branch = rust-release-80-v2
[submodule "src/tools/clang"]
path = src/tools/clang
url = https://github.com/rust-lang-nursery/clang.git
branch = rust-release-80-v2
[submodule "src/doc/rustc-guide"]
path = src/doc/rustc-guide
url = https://github.com/rust-lang/rustc-guide.git
[submodule "src/doc/edition-guide"]
path = src/doc/edition-guide
url = https://github.com/rust-lang-nursery/edition-guide
url = https://github.com/rust-lang-nursery/edition-guide.git
[submodule "src/llvm-project"]
path = src/llvm-project
url = https://github.com/rust-lang/llvm-project.git
branch = rustc/8.0-2019-01-16

View File

@ -23,7 +23,7 @@ The Rust Project includes packages written by third parties.
The following third party packages are included, and carry
their own copyright notices and license terms:
* LLVM. Code for this package is found in src/llvm.
* LLVM. Code for this package is found in src/llvm-project.
Copyright (c) 2003-2013 University of Illinois at
Urbana-Champaign. All rights reserved.
@ -73,8 +73,8 @@ their own copyright notices and license terms:
OTHER DEALINGS WITH THE SOFTWARE.
* Additional libraries included in LLVM carry separate
BSD-compatible licenses. See src/llvm/LICENSE.txt for
details.
BSD-compatible licenses. See src/llvm-project/llvm/LICENSE.TXT
for details.
* compiler-rt, in src/compiler-rt is dual licensed under
LLVM's license and MIT:

View File

@ -701,21 +701,13 @@ class RustBuild(object):
filtered_submodules = []
submodules_names = []
for module in submodules:
if module.endswith("llvm"):
if self.get_toml('llvm-config'):
if module.endswith("llvm-project"):
if self.get_toml('llvm-config') and self.get_toml('lld') != 'true':
continue
if module.endswith("llvm-emscripten"):
backends = self.get_toml('codegen-backends')
if backends is None or not 'emscripten' in backends:
continue
if module.endswith("lld"):
config = self.get_toml('lld')
if config is None or config == 'false':
continue
if module.endswith("lldb") or module.endswith("clang"):
config = self.get_toml('lldb')
if config is None or config == 'false':
continue
check = self.check_submodule(module, slow_submodules)
filtered_submodules.append((module, check))
submodules_names.append(module)

View File

@ -788,7 +788,24 @@ fn filter_fn(exclude_dirs: &[&str], dir: &str, path: &Path) -> bool {
if spath.ends_with("~") || spath.ends_with(".pyc") {
return false
}
if (spath.contains("llvm/test") || spath.contains("llvm\\test")) &&
const LLVM_PROJECTS: &[&str] = &[
"llvm-project/clang", "llvm-project\\clang",
"llvm-project/lld", "llvm-project\\lld",
"llvm-project/lldb", "llvm-project\\lldb",
"llvm-project/llvm", "llvm-project\\llvm",
];
if spath.contains("llvm-project") && !spath.ends_with("llvm-project")
&& !LLVM_PROJECTS.iter().any(|path| spath.contains(path))
{
return false;
}
const LLVM_TEST: &[&str] = &[
"llvm-project/llvm/test", "llvm-project\\llvm\\test",
"llvm-emscripten/test", "llvm-emscripten\\test",
];
if LLVM_TEST.iter().any(|path| spath.contains(path)) &&
(spath.ends_with(".ll") ||
spath.ends_with(".td") ||
spath.ends_with(".s")) {
@ -2076,7 +2093,7 @@ fn run(self, builder: &Builder) -> Option<PathBuf> {
}
builder.info(&format!("Dist LlvmTools stage{} ({})", stage, target));
let src = builder.src.join("src/llvm");
let src = builder.src.join("src/llvm-project/llvm");
let name = pkgname(builder, "llvm-tools");
let tmp = tmpdir(builder);
@ -2135,7 +2152,7 @@ impl Step for Lldb {
const DEFAULT: bool = true;
fn should_run(run: ShouldRun) -> ShouldRun {
run.path("src/tools/lldb")
run.path("src/llvm-project/lldb").path("src/tools/lldb")
}
fn make_run(run: RunConfig) {
@ -2160,7 +2177,7 @@ fn run(self, builder: &Builder) -> Option<PathBuf> {
}
builder.info(&format!("Dist Lldb ({})", target));
let src = builder.src.join("src/tools/lldb");
let src = builder.src.join("src/llvm-project/lldb");
let name = pkgname(builder, "lldb");
let tmp = tmpdir(builder);

View File

@ -36,7 +36,10 @@ impl Step for Llvm {
const ONLY_HOSTS: bool = true;
fn should_run(run: ShouldRun) -> ShouldRun {
run.path("src/llvm").path("src/llvm-emscripten")
run.path("src/llvm-project")
.path("src/llvm-project/llvm")
.path("src/llvm")
.path("src/llvm-emscripten")
}
fn make_run(run: RunConfig) {
@ -97,7 +100,7 @@ fn run(self, builder: &Builder) -> PathBuf {
t!(fs::create_dir_all(&out_dir));
// http://llvm.org/docs/CMake.html
let root = if self.emscripten { "src/llvm-emscripten" } else { "src/llvm" };
let root = if self.emscripten { "src/llvm-emscripten" } else { "src/llvm-project/llvm" };
let mut cfg = cmake::Config::new(builder.src.join(root));
let profile = match (builder.config.llvm_optimize, builder.config.llvm_release_debuginfo) {
@ -189,8 +192,7 @@ fn run(self, builder: &Builder) -> PathBuf {
}
if want_lldb {
cfg.define("LLVM_EXTERNAL_CLANG_SOURCE_DIR", builder.src.join("src/tools/clang"));
cfg.define("LLVM_EXTERNAL_LLDB_SOURCE_DIR", builder.src.join("src/tools/lldb"));
cfg.define("LLVM_ENABLE_PROJECTS", "clang;lldb");
// For the time being, disable code signing.
cfg.define("LLDB_CODESIGN_IDENTITY", "");
} else {
@ -411,7 +413,7 @@ impl Step for Lld {
const ONLY_HOSTS: bool = true;
fn should_run(run: ShouldRun) -> ShouldRun {
run.path("src/tools/lld")
run.path("src/llvm-project/lld").path("src/tools/lld")
}
fn make_run(run: RunConfig) {
@ -441,7 +443,7 @@ fn run(self, builder: &Builder) -> PathBuf {
let _time = util::timeit(&builder);
t!(fs::create_dir_all(&out_dir));
let mut cfg = cmake::Config::new(builder.src.join("src/tools/lld"));
let mut cfg = cmake::Config::new(builder.src.join("src/llvm-project/lld"));
configure_cmake(builder, target, &mut cfg);
// This is an awful, awful hack. Discovered when we migrated to using

View File

@ -45,8 +45,7 @@ function fetch_submodule {
rm $cached
}
included="src/llvm src/llvm-emscripten src/doc/book src/doc/rust-by-example"
included="$included src/tools/lld src/tools/clang src/tools/lldb"
included="src/llvm-project src/llvm-emscripten src/doc/book src/doc/rust-by-example"
modules="$(git config --file .gitmodules --get-regexp '\.path$' | cut -d' ' -f2)"
modules=($modules)
use_git=""

View File

@ -12,7 +12,7 @@
use llvm;
use llvm::debuginfo::{DIFile, DIType, DIScope, DIBuilder, DISubprogram, DIArray, DIFlags,
DILexicalBlock};
DISPFlags, DILexicalBlock};
use rustc::hir::CodegenFnAttrFlags;
use rustc::hir::def_id::{DefId, CrateNum, LOCAL_CRATE};
use rustc::ty::subst::{Substs, UnpackedKind};
@ -283,7 +283,6 @@ fn create_function_debug_context(
let linkage_name = mangled_name_of_instance(self, instance);
let scope_line = span_start(self, span).line;
let is_local_to_unit = is_node_local_to_unit(self, def_id);
let function_name = CString::new(name).unwrap();
let linkage_name = SmallCStr::new(&linkage_name.as_str());
@ -300,6 +299,14 @@ fn create_function_debug_context(
flags |= DIFlags::FlagNoReturn;
}
let mut spflags = DISPFlags::SPFlagDefinition;
if is_node_local_to_unit(self, def_id) {
spflags |= DISPFlags::SPFlagLocalToUnit;
}
if self.sess().opts.optimize != config::OptLevel::No {
spflags |= DISPFlags::SPFlagOptimized;
}
let fn_metadata = unsafe {
llvm::LLVMRustDIBuilderCreateFunction(
DIB(self),
@ -309,11 +316,9 @@ fn create_function_debug_context(
file_metadata,
loc.line as c_uint,
function_type_metadata,
is_local_to_unit,
true,
scope_line as c_uint,
flags,
self.sess().opts.optimize != config::OptLevel::No,
spflags,
llfn,
template_parameters,
None)

View File

@ -2,7 +2,7 @@
DIBuilder, DIDescriptor, DIFile, DILexicalBlock, DISubprogram, DIType,
DIBasicType, DIDerivedType, DICompositeType, DIScope, DIVariable,
DIGlobalVariableExpression, DIArray, DISubrange, DITemplateTypeParameter, DIEnumerator,
DINameSpace, DIFlags,
DINameSpace, DIFlags, DISPFlags,
};
use libc::{c_uint, c_int, size_t, c_char};
@ -591,6 +591,20 @@ pub struct DIFlags: ::libc::uint32_t {
const FlagMainSubprogram = (1 << 21);
}
}
// These values **must** match with LLVMRustDISPFlags!!
bitflags! {
#[repr(C)]
#[derive(Default)]
pub struct DISPFlags: ::libc::uint32_t {
const SPFlagZero = 0;
const SPFlagVirtual = 1;
const SPFlagPureVirtual = 2;
const SPFlagLocalToUnit = (1 << 2);
const SPFlagDefinition = (1 << 3);
const SPFlagOptimized = (1 << 4);
}
}
}
extern { pub type ModuleBuffer; }
@ -1387,11 +1401,9 @@ pub fn LLVMRustDIBuilderCreateFunction(Builder: &DIBuilder<'a>,
File: &'a DIFile,
LineNo: c_uint,
Ty: &'a DIType,
isLocalToUnit: bool,
isDefinition: bool,
ScopeLine: c_uint,
Flags: DIFlags,
isOptimized: bool,
SPFlags: DISPFlags,
Fn: &'a Value,
TParam: &'a DIArray,
Decl: Option<&'a DIDescriptor>)
@ -1529,7 +1541,7 @@ pub fn LLVMRustDIBuilderCreateEnumerationType(Builder: &DIBuilder<'a>,
AlignInBits: u32,
Elements: &'a DIArray,
ClassType: &'a DIType,
IsFixed: bool)
IsScoped: bool)
-> &'a DIType;
pub fn LLVMRustDIBuilderCreateUnionType(Builder: &DIBuilder<'a>,

@ -1 +0,0 @@
Subproject commit f4728ed8fa2296c5b009bb85550e157e1e57ed0b

1
src/llvm-project Submodule

@ -0,0 +1 @@
Subproject commit a27fbee5abaee63ac45c8cb9a0c73889c3b98471

View File

@ -789,7 +789,7 @@ struct LLVMRustThinLTOData {
StringMap<GVSummaryMapTy> ModuleToDefinedGVSummaries;
#if LLVM_VERSION_GE(7, 0)
LLVMRustThinLTOData() : Index(/* isPerformingAnalysis = */ false) {}
LLVMRustThinLTOData() : Index(/* HaveGVs = */ false) {}
#endif
};
@ -865,7 +865,12 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
auto deadIsPrevailing = [&](GlobalValue::GUID G) {
return PrevailingType::Unknown;
};
#if LLVM_VERSION_GE(8, 0)
computeDeadSymbolsWithConstProp(Ret->Index, Ret->GUIDPreservedSymbols,
deadIsPrevailing, /* ImportEnabled = */ true);
#else
computeDeadSymbols(Ret->Index, Ret->GUIDPreservedSymbols, deadIsPrevailing);
#endif
#else
computeDeadSymbols(Ret->Index, Ret->GUIDPreservedSymbols);
#endif

View File

@ -294,7 +294,7 @@ extern "C" void LLVMRustSetHasUnsafeAlgebra(LLVMValueRef V) {
extern "C" LLVMValueRef
LLVMRustBuildAtomicLoad(LLVMBuilderRef B, LLVMValueRef Source, const char *Name,
LLVMAtomicOrdering Order) {
LoadInst *LI = new LoadInst(unwrap(Source), 0);
LoadInst *LI = new LoadInst(unwrap(Source));
LI->setAtomic(fromRust(Order));
return wrap(unwrap(B)->Insert(LI, Name));
}
@ -511,6 +511,71 @@ static DINode::DIFlags fromRust(LLVMRustDIFlags Flags) {
return Result;
}
// These values **must** match debuginfo::DISPFlags! They also *happen*
// to match LLVM, but that isn't required as we do giant sets of
// matching below. The value shouldn't be directly passed to LLVM.
enum class LLVMRustDISPFlags : uint32_t {
SPFlagZero = 0,
SPFlagVirtual = 1,
SPFlagPureVirtual = 2,
SPFlagLocalToUnit = (1 << 2),
SPFlagDefinition = (1 << 3),
SPFlagOptimized = (1 << 4),
// Do not add values that are not supported by the minimum LLVM
// version we support! see llvm/include/llvm/IR/DebugInfoFlags.def
// (In LLVM < 8, createFunction supported these as separate bool arguments.)
};
inline LLVMRustDISPFlags operator&(LLVMRustDISPFlags A, LLVMRustDISPFlags B) {
return static_cast<LLVMRustDISPFlags>(static_cast<uint32_t>(A) &
static_cast<uint32_t>(B));
}
inline LLVMRustDISPFlags operator|(LLVMRustDISPFlags A, LLVMRustDISPFlags B) {
return static_cast<LLVMRustDISPFlags>(static_cast<uint32_t>(A) |
static_cast<uint32_t>(B));
}
inline LLVMRustDISPFlags &operator|=(LLVMRustDISPFlags &A, LLVMRustDISPFlags B) {
return A = A | B;
}
inline bool isSet(LLVMRustDISPFlags F) { return F != LLVMRustDISPFlags::SPFlagZero; }
inline LLVMRustDISPFlags virtuality(LLVMRustDISPFlags F) {
return static_cast<LLVMRustDISPFlags>(static_cast<uint32_t>(F) & 0x3);
}
#if LLVM_VERSION_GE(8, 0)
static DISubprogram::DISPFlags fromRust(LLVMRustDISPFlags SPFlags) {
DISubprogram::DISPFlags Result = DISubprogram::DISPFlags::SPFlagZero;
switch (virtuality(SPFlags)) {
case LLVMRustDISPFlags::SPFlagVirtual:
Result |= DISubprogram::DISPFlags::SPFlagVirtual;
break;
case LLVMRustDISPFlags::SPFlagPureVirtual:
Result |= DISubprogram::DISPFlags::SPFlagPureVirtual;
break;
default:
// The rest are handled below
break;
}
if (isSet(SPFlags & LLVMRustDISPFlags::SPFlagLocalToUnit)) {
Result |= DISubprogram::DISPFlags::SPFlagLocalToUnit;
}
if (isSet(SPFlags & LLVMRustDISPFlags::SPFlagDefinition)) {
Result |= DISubprogram::DISPFlags::SPFlagDefinition;
}
if (isSet(SPFlags & LLVMRustDISPFlags::SPFlagOptimized)) {
Result |= DISubprogram::DISPFlags::SPFlagOptimized;
}
return Result;
}
#endif
extern "C" uint32_t LLVMRustDebugMetadataVersion() {
return DEBUG_METADATA_VERSION;
}
@ -575,16 +640,26 @@ LLVMRustDIBuilderCreateSubroutineType(LLVMRustDIBuilderRef Builder,
extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateFunction(
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
const char *LinkageName, LLVMMetadataRef File, unsigned LineNo,
LLVMMetadataRef Ty, bool IsLocalToUnit, bool IsDefinition,
unsigned ScopeLine, LLVMRustDIFlags Flags, bool IsOptimized,
LLVMValueRef Fn, LLVMMetadataRef TParam, LLVMMetadataRef Decl) {
LLVMMetadataRef Ty, unsigned ScopeLine, LLVMRustDIFlags Flags,
LLVMRustDISPFlags SPFlags, LLVMValueRef Fn, LLVMMetadataRef TParam,
LLVMMetadataRef Decl) {
DITemplateParameterArray TParams =
DITemplateParameterArray(unwrap<MDTuple>(TParam));
#if LLVM_VERSION_GE(8, 0)
DISubprogram *Sub = Builder->createFunction(
unwrapDI<DIScope>(Scope), Name, LinkageName, unwrapDI<DIFile>(File),
LineNo, unwrapDI<DISubroutineType>(Ty), ScopeLine, fromRust(Flags),
fromRust(SPFlags), TParams, unwrapDIPtr<DISubprogram>(Decl));
#else
bool IsLocalToUnit = isSet(SPFlags & LLVMRustDISPFlags::SPFlagLocalToUnit);
bool IsDefinition = isSet(SPFlags & LLVMRustDISPFlags::SPFlagDefinition);
bool IsOptimized = isSet(SPFlags & LLVMRustDISPFlags::SPFlagOptimized);
DISubprogram *Sub = Builder->createFunction(
unwrapDI<DIScope>(Scope), Name, LinkageName, unwrapDI<DIFile>(File),
LineNo, unwrapDI<DISubroutineType>(Ty), IsLocalToUnit, IsDefinition,
ScopeLine, fromRust(Flags), IsOptimized, TParams,
unwrapDIPtr<DISubprogram>(Decl));
#endif
unwrap<Function>(Fn)->setSubprogram(Sub);
return wrap(Sub);
}
@ -773,14 +848,14 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateEnumerationType(
LLVMRustDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name,
LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits,
uint32_t AlignInBits, LLVMMetadataRef Elements,
LLVMMetadataRef ClassTy, bool IsFixed) {
LLVMMetadataRef ClassTy, bool IsScoped) {
#if LLVM_VERSION_GE(7, 0)
return wrap(Builder->createEnumerationType(
unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), LineNumber,
SizeInBits, AlignInBits, DINodeArray(unwrapDI<MDTuple>(Elements)),
unwrapDI<DIType>(ClassTy), "", IsFixed));
unwrapDI<DIType>(ClassTy), "", IsScoped));
#else
// Ignore IsFixed on older LLVM.
// Ignore IsScoped on older LLVM.
return wrap(Builder->createEnumerationType(
unwrapDI<DIDescriptor>(Scope), Name, unwrapDI<DIFile>(File), LineNumber,
SizeInBits, AlignInBits, DINodeArray(unwrapDI<MDTuple>(Elements)),
@ -920,7 +995,11 @@ extern "C" void LLVMRustUnpackOptimizationDiagnostic(
if (loc.isValid()) {
*Line = loc.getLine();
*Column = loc.getColumn();
#if LLVM_VERSION_GE(8, 0)
FilenameOS << loc.getAbsolutePath();
#else
FilenameOS << loc.getFilename();
#endif
}
RawRustStringOstream MessageOS(MessageOut);

View File

@ -1,4 +1,4 @@
# If this file is modified, then llvm will be (optionally) cleaned and then rebuilt.
# The actual contents of this file do not matter, but to trigger a change on the
# build bots then the contents should be changed so git updates the mtime.
2018-12-13
2019-01-16

View File

@ -8,8 +8,11 @@
// compile-flags: -g -C no-prepopulate-passes
// DIFlagFixedEnum was deprecated in 8.0, renamed to DIFlagEnumClass.
// We match either for compatibility.
// CHECK-LABEL: @main
// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_enumeration_type,{{.*}}name: "E",{{.*}}flags: DIFlagFixedEnum,{{.*}}
// CHECK: {{.*}}DICompositeType{{.*}}tag: DW_TAG_enumeration_type,{{.*}}name: "E",{{.*}}flags: {{(DIFlagEnumClass|DIFlagFixedEnum)}},{{.*}}
// CHECK: {{.*}}DIEnumerator{{.*}}name: "A",{{.*}}value: {{[0-9].*}}
// CHECK: {{.*}}DIEnumerator{{.*}}name: "B",{{.*}}value: {{[0-9].*}}
// CHECK: {{.*}}DIEnumerator{{.*}}name: "C",{{.*}}value: {{[0-9].*}}

@ -1 +0,0 @@
Subproject commit 032312dd0140a7074c9b89d305fe44eb0e44e407

@ -1 +0,0 @@
Subproject commit 1928c5eeb613a4c6d232fc47ae91914bbfd92a79

@ -1 +0,0 @@
Subproject commit 8ad0817ce45b0eef9d374691b23f2bd69c164254

View File

@ -47,6 +47,7 @@ macro_rules! tidy_error {
fn filter_dirs(path: &Path) -> bool {
let skip = [
"src/llvm",
"src/llvm-project",
"src/llvm-emscripten",
"src/libbacktrace",
"src/librustc_data_structures/owning_ref",