Revert to previous base llvm-353983
Change-Id: Id0e43521b22a940633d483eb1a8a2a840db286e5
diff --git a/OWNERS b/OWNERS
deleted file mode 100644
index e5b5f6f..0000000
--- a/OWNERS
+++ /dev/null
@@ -1 +0,0 @@
-include toolchain/llvm_android:/OWNERS
diff --git a/clang/include/clang/AST/APValue.h b/clang/include/clang/AST/APValue.h
index de5546f..5d26a11 100644
--- a/clang/include/clang/AST/APValue.h
+++ b/clang/include/clang/AST/APValue.h
@@ -262,12 +262,6 @@
return const_cast<APValue*>(this)->getInt();
}
- /// Try to convert this value to an integral constant. This works if it's an
- /// integer, null pointer, or offset from a null pointer. Returns true on
- /// success.
- bool toIntegralConstant(APSInt &Result, QualType SrcTy,
- const ASTContext &Ctx) const;
-
APFloat &getFloat() {
assert(isFloat() && "Invalid accessor");
return *(APFloat*)(char*)Data.buffer;
diff --git a/clang/include/clang/Basic/CodeGenOptions.def b/clang/include/clang/Basic/CodeGenOptions.def
index 2a8574e..a7aafcf 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -111,7 +111,7 @@
///< be generated.
CODEGENOPT(PrepareForLTO , 1, 0) ///< Set when -flto is enabled on the
///< compile step.
-CODEGENOPT(EmitSummaryIndex, 1, 0) ///< Set when -flto=thin is enabled on the
+CODEGENOPT(PrepareForThinLTO , 1, 0) ///< Set when -flto=thin is enabled on the
///< compile step.
CODEGENOPT(LTOUnit, 1, 0) ///< Emit IR to support LTO unit features (CFI, whole
///< program vtable opt).
diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h
index d41f4c6..7a3dc3f 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -816,7 +816,6 @@
struct {
int Min;
int Max;
- bool isConstrained;
} ImmRange;
llvm::SmallSet<int, 4> ImmSet;
@@ -827,7 +826,6 @@
: Flags(0), TiedOperand(-1), ConstraintStr(ConstraintStr.str()),
Name(Name.str()) {
ImmRange.Min = ImmRange.Max = 0;
- ImmRange.isConstrained = false;
}
const std::string &getConstraintStr() const { return ConstraintStr; }
@@ -856,9 +854,8 @@
return (Flags & CI_ImmediateConstant) != 0;
}
bool isValidAsmImmediate(const llvm::APInt &Value) const {
- if (!ImmSet.empty())
- return ImmSet.count(Value.getZExtValue()) != 0;
- return !ImmRange.isConstrained || (Value.sge(ImmRange.Min) && Value.sle(ImmRange.Max));
+ return (Value.sge(ImmRange.Min) && Value.sle(ImmRange.Max)) ||
+ ImmSet.count(Value.getZExtValue()) != 0;
}
void setIsReadWrite() { Flags |= CI_ReadWrite; }
@@ -870,7 +867,6 @@
Flags |= CI_ImmediateConstant;
ImmRange.Min = Min;
ImmRange.Max = Max;
- ImmRange.isConstrained = true;
}
void setRequiresImmediate(llvm::ArrayRef<int> Exacts) {
Flags |= CI_ImmediateConstant;
@@ -883,6 +879,8 @@
}
void setRequiresImmediate() {
Flags |= CI_ImmediateConstant;
+ ImmRange.Min = INT_MIN;
+ ImmRange.Max = INT_MAX;
}
/// Indicate that this is an input operand that is tied to
diff --git a/clang/lib/AST/APValue.cpp b/clang/lib/AST/APValue.cpp
index f9cbf33..e1876a9 100644
--- a/clang/lib/AST/APValue.cpp
+++ b/clang/lib/AST/APValue.cpp
@@ -614,26 +614,6 @@
return Result;
}
-bool APValue::toIntegralConstant(APSInt &Result, QualType SrcTy,
- const ASTContext &Ctx) const {
- if (isInt()) {
- Result = getInt();
- return true;
- }
-
- if (isLValue() && isNullPointer()) {
- Result = Ctx.MakeIntValue(Ctx.getTargetNullPointerValue(SrcTy), SrcTy);
- return true;
- }
-
- if (isLValue() && !getLValueBase()) {
- Result = Ctx.MakeIntValue(getLValueOffset().getQuantity(), SrcTy);
- return true;
- }
-
- return false;
-}
-
const APValue::LValueBase APValue::getLValueBase() const {
assert(isLValue() && "Invalid accessor");
return ((const LV*)(const void*)Data.buffer)->Base;
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 168a568..19e6b53 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -9836,12 +9836,13 @@
return true;
}
- APSInt AsInt;
- APValue V;
- LV.moveInto(V);
- if (!V.toIntegralConstant(AsInt, SrcType, Info.Ctx))
- llvm_unreachable("Can't cast this!");
+ uint64_t V;
+ if (LV.isNullPointer())
+ V = Info.Ctx.getTargetNullPointerValue(SrcType);
+ else
+ V = LV.getLValueOffset().getQuantity();
+ APSInt AsInt = Info.Ctx.MakeIntValue(V, SrcType);
return Success(HandleIntToIntCast(Info, E, DestType, SrcType, AsInt), E);
}
@@ -11075,7 +11076,6 @@
const ASTContext &Ctx) const {
EvalInfo::EvaluationMode EM = EvalInfo::EM_ConstantExpression;
EvalInfo Info(Ctx, Result, EM);
- Info.InConstantContext = true;
if (!::Evaluate(Result.Val, Info, this))
return false;
@@ -11716,7 +11716,6 @@
const Expr *This) const {
Expr::EvalStatus Status;
EvalInfo Info(Ctx, Status, EvalInfo::EM_ConstantExpressionUnevaluated);
- Info.InConstantContext = true;
LValue ThisVal;
const LValue *ThisPtr = nullptr;
@@ -11800,7 +11799,6 @@
EvalInfo Info(FD->getASTContext(), Status,
EvalInfo::EM_PotentialConstantExpressionUnevaluated);
- Info.InConstantContext = true;
// Fabricate a call stack frame to give the arguments a plausible cover story.
ArrayRef<const Expr*> Args;
diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index 923e706..5a75b85 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -34,12 +34,7 @@
NoAsmVariants = false;
HasLegalHalfType = false;
HasFloat128 = false;
-
- // Android-changed: Make HasFloat16 available by default
- // http://b/127391056
- // HasFloat16 = false;
- HasFloat16 = true;
-
+ HasFloat16 = false;
PointerWidth = PointerAlign = 32;
BoolWidth = BoolAlign = 8;
IntWidth = IntAlign = 32;
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index efb41b2..e020187 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -55,7 +55,6 @@
#include "llvm/Transforms/Instrumentation.h"
#include "llvm/Transforms/Instrumentation/BoundsChecking.h"
#include "llvm/Transforms/Instrumentation/GCOVProfiler.h"
-#include "llvm/Transforms/Instrumentation/InstrProfiling.h"
#include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
#include "llvm/Transforms/Instrumentation/ThreadSanitizer.h"
#include "llvm/Transforms/ObjCARC.h"
@@ -517,21 +516,6 @@
return Options;
}
-static Optional<InstrProfOptions>
-getInstrProfOptions(const CodeGenOptions &CodeGenOpts,
- const LangOptions &LangOpts) {
- if (!CodeGenOpts.hasProfileClangInstr())
- return None;
- InstrProfOptions Options;
- Options.NoRedZone = CodeGenOpts.DisableRedZone;
- Options.InstrProfileOutput = CodeGenOpts.InstrProfileOutput;
-
- // TODO: Surface the option to emit atomic profile counter increments at
- // the driver level.
- Options.Atomic = LangOpts.Sanitize.has(SanitizerKind::Thread);
- return Options;
-}
-
void EmitAssemblyHelper::CreatePasses(legacy::PassManager &MPM,
legacy::FunctionPassManager &FPM) {
// Handle disabling of all LLVM passes, where we want to preserve the
@@ -562,7 +546,7 @@
PMBuilder.Inliner = createFunctionInliningPass(
CodeGenOpts.OptimizationLevel, CodeGenOpts.OptimizeSize,
(!CodeGenOpts.SampleProfileFile.empty() &&
- CodeGenOpts.EmitSummaryIndex));
+ CodeGenOpts.PrepareForThinLTO));
}
PMBuilder.OptLevel = CodeGenOpts.OptimizationLevel;
@@ -572,7 +556,7 @@
PMBuilder.DisableUnrollLoops = !CodeGenOpts.UnrollLoops;
PMBuilder.MergeFunctions = CodeGenOpts.MergeFunctions;
- PMBuilder.PrepareForThinLTO = CodeGenOpts.EmitSummaryIndex;
+ PMBuilder.PrepareForThinLTO = CodeGenOpts.PrepareForThinLTO;
PMBuilder.PrepareForLTO = CodeGenOpts.PrepareForLTO;
PMBuilder.RerollLoops = CodeGenOpts.RerollLoops;
@@ -693,10 +677,17 @@
MPM.add(createStripSymbolsPass(true));
}
- if (Optional<InstrProfOptions> Options =
- getInstrProfOptions(CodeGenOpts, LangOpts))
- MPM.add(createInstrProfilingLegacyPass(*Options));
+ if (CodeGenOpts.hasProfileClangInstr()) {
+ InstrProfOptions Options;
+ Options.NoRedZone = CodeGenOpts.DisableRedZone;
+ Options.InstrProfileOutput = CodeGenOpts.InstrProfileOutput;
+ // TODO: Surface the option to emit atomic profile counter increments at
+ // the driver level.
+ Options.Atomic = LangOpts.Sanitize.has(SanitizerKind::Thread);
+
+ MPM.add(createInstrProfilingLegacyPass(Options));
+ }
if (CodeGenOpts.hasProfileIRInstr()) {
PMBuilder.EnablePGOInstrGen = true;
if (!CodeGenOpts.InstrProfileOutput.empty())
@@ -819,7 +810,7 @@
break;
case Backend_EmitBC:
- if (CodeGenOpts.EmitSummaryIndex && !CodeGenOpts.DisableLLVMPasses) {
+ if (CodeGenOpts.PrepareForThinLTO && !CodeGenOpts.DisableLLVMPasses) {
if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
ThinLinkOS = openOutputFile(CodeGenOpts.ThinLinkBitcodeFile);
if (!ThinLinkOS)
@@ -829,10 +820,24 @@
CodeGenOpts.EnableSplitLTOUnit);
PerModulePasses.add(createWriteThinLTOBitcodePass(
*OS, ThinLinkOS ? &ThinLinkOS->os() : nullptr));
+ } else {
+ // Emit a module summary by default for Regular LTO except for ld64
+ // targets
+ bool EmitLTOSummary =
+ (CodeGenOpts.PrepareForLTO &&
+ !CodeGenOpts.DisableLLVMPasses &&
+ llvm::Triple(TheModule->getTargetTriple()).getVendor() !=
+ llvm::Triple::Apple);
+ if (EmitLTOSummary) {
+ if (!TheModule->getModuleFlag("ThinLTO"))
+ TheModule->addModuleFlag(Module::Error, "ThinLTO", uint32_t(0));
+ TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit",
+ CodeGenOpts.EnableSplitLTOUnit);
+ }
+
+ PerModulePasses.add(createBitcodeWriterPass(
+ *OS, CodeGenOpts.EmitLLVMUseLists, EmitLTOSummary));
}
- else
- PerModulePasses.add(
- createBitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists));
break;
case Backend_EmitLL:
@@ -995,15 +1000,12 @@
ModulePassManager MPM(CodeGenOpts.DebugPassManager);
if (!CodeGenOpts.DisableLLVMPasses) {
- bool IsThinLTO = CodeGenOpts.EmitSummaryIndex;
+ bool IsThinLTO = CodeGenOpts.PrepareForThinLTO;
bool IsLTO = CodeGenOpts.PrepareForLTO;
if (CodeGenOpts.OptimizationLevel == 0) {
if (Optional<GCOVOptions> Options = getGCOVOptions(CodeGenOpts))
MPM.addPass(GCOVProfilerPass(*Options));
- if (Optional<InstrProfOptions> Options =
- getInstrProfOptions(CodeGenOpts, LangOpts))
- MPM.addPass(InstrProfiling(*Options));
// Build a minimal pipeline based on the semantics required by Clang,
// which is just that always inlining occurs.
@@ -1013,9 +1015,11 @@
if (LangOpts.Sanitize.has(SanitizerKind::LocalBounds))
MPM.addPass(createModuleToFunctionPassAdaptor(BoundsCheckingPass()));
- // Lastly, add a semantically necessary pass for ThinLTO.
- if (IsThinLTO)
+ // Lastly, add semantically necessary passes for LTO.
+ if (IsLTO || IsThinLTO) {
+ MPM.addPass(CanonicalizeAliasesPass());
MPM.addPass(NameAnonGlobalPass());
+ }
} else {
// Map our optimization levels into one of the distinct levels used to
// configure the pipeline.
@@ -1043,11 +1047,6 @@
PB.registerPipelineStartEPCallback([Options](ModulePassManager &MPM) {
MPM.addPass(GCOVProfilerPass(*Options));
});
- if (Optional<InstrProfOptions> Options =
- getInstrProfOptions(CodeGenOpts, LangOpts))
- PB.registerPipelineStartEPCallback([Options](ModulePassManager &MPM) {
- MPM.addPass(InstrProfiling(*Options));
- });
if (IsThinLTO) {
MPM = PB.buildThinLTOPreLinkDefaultPipeline(
@@ -1058,6 +1057,7 @@
MPM = PB.buildLTOPreLinkDefaultPipeline(Level,
CodeGenOpts.DebugPassManager);
MPM.addPass(CanonicalizeAliasesPass());
+ MPM.addPass(NameAnonGlobalPass());
} else {
MPM = PB.buildPerModuleDefaultPipeline(Level,
CodeGenOpts.DebugPassManager);
@@ -1077,7 +1077,7 @@
break;
case Backend_EmitBC:
- if (CodeGenOpts.EmitSummaryIndex && !CodeGenOpts.DisableLLVMPasses) {
+ if (CodeGenOpts.PrepareForThinLTO && !CodeGenOpts.DisableLLVMPasses) {
if (!CodeGenOpts.ThinLinkBitcodeFile.empty()) {
ThinLinkOS = openOutputFile(CodeGenOpts.ThinLinkBitcodeFile);
if (!ThinLinkOS)
@@ -1088,9 +1088,21 @@
MPM.addPass(ThinLTOBitcodeWriterPass(*OS, ThinLinkOS ? &ThinLinkOS->os()
: nullptr));
} else {
- MPM.addPass(BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists,
- CodeGenOpts.EmitSummaryIndex,
- CodeGenOpts.EmitSummaryIndex));
+ // Emit a module summary by default for Regular LTO except for ld64
+ // targets
+ bool EmitLTOSummary =
+ (CodeGenOpts.PrepareForLTO &&
+ !CodeGenOpts.DisableLLVMPasses &&
+ llvm::Triple(TheModule->getTargetTriple()).getVendor() !=
+ llvm::Triple::Apple);
+ if (EmitLTOSummary) {
+ if (!TheModule->getModuleFlag("ThinLTO"))
+ TheModule->addModuleFlag(Module::Error, "ThinLTO", uint32_t(0));
+ TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit",
+ CodeGenOpts.EnableSplitLTOUnit);
+ }
+ MPM.addPass(
+ BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists, EmitLTOSummary));
}
break;
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 5e17f5dc..ce48f8b 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -608,7 +608,7 @@
// Create new compile unit.
TheCU = DBuilder.createCompileUnit(
LangTag, CUFile, CGOpts.EmitVersionIdentMetadata ? Producer : "",
- LO.Optimize || CGOpts.PrepareForLTO || CGOpts.EmitSummaryIndex,
+ LO.Optimize || CGOpts.PrepareForLTO || CGOpts.PrepareForThinLTO,
CGOpts.DwarfDebugFlags, RuntimeVers,
(CGOpts.getSplitDwarfMode() != CodeGenOptions::NoFission)
? ""
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 328e6d9..db3f4f1 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -1829,15 +1829,8 @@
// (immediate or symbolic), try to emit it as such.
if (!Info.allowsRegister() && !Info.allowsMemory()) {
if (Info.requiresImmediateConstant()) {
- Expr::EvalResult EVResult;
- InputExpr->EvaluateAsRValue(EVResult, getContext(), true);
-
- llvm::APSInt IntResult;
- if (!EVResult.Val.toIntegralConstant(IntResult, InputExpr->getType(),
- getContext()))
- llvm_unreachable("Invalid immediate constant!");
-
- return llvm::ConstantInt::get(getLLVMContext(), IntResult);
+ llvm::APSInt AsmConst = InputExpr->EvaluateKnownConstInt(getContext());
+ return llvm::ConstantInt::get(getLLVMContext(), AsmConst);
}
Expr::EvalResult Result;
diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index 06a23f7..1a6636a 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -248,7 +248,7 @@
ABI = FloatABI::SoftFP;
break;
case llvm::Triple::Android:
- ABI = (SubArch >= 7) ? FloatABI::SoftFP : FloatABI::Soft;
+ ABI = (SubArch == 7) ? FloatABI::SoftFP : FloatABI::Soft;
break;
default:
// Assume "soft", but warn the user we are guessing.
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 41a01f3..bda8427 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -898,11 +898,11 @@
Opts.ProfileSampleAccurate = Args.hasArg(OPT_fprofile_sample_accurate);
Opts.PrepareForLTO = Args.hasArg(OPT_flto, OPT_flto_EQ);
- Opts.EmitSummaryIndex = false;
+ Opts.PrepareForThinLTO = false;
if (Arg *A = Args.getLastArg(OPT_flto_EQ)) {
StringRef S = A->getValue();
if (S == "thin")
- Opts.EmitSummaryIndex = true;
+ Opts.PrepareForThinLTO = true;
else if (S != "full")
Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << S;
}
diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp
index ee487e9..d9b39e8 100644
--- a/clang/lib/Sema/SemaStmtAsm.cpp
+++ b/clang/lib/Sema/SemaStmtAsm.cpp
@@ -382,20 +382,11 @@
return StmtError(
Diag(InputExpr->getBeginLoc(), diag::err_asm_immediate_expected)
<< Info.getConstraintStr() << InputExpr->getSourceRange());
-
- // For compatibility with GCC, we also allow pointers that would be
- // integral constant expressions if they were cast to int.
- llvm::APSInt IntResult;
- if (!EVResult.Val.toIntegralConstant(IntResult, InputExpr->getType(),
- Context))
- return StmtError(
- Diag(InputExpr->getBeginLoc(), diag::err_asm_immediate_expected)
- << Info.getConstraintStr() << InputExpr->getSourceRange());
-
- if (!Info.isValidAsmImmediate(IntResult))
+ llvm::APSInt Result = EVResult.Val.getInt();
+ if (!Info.isValidAsmImmediate(Result))
return StmtError(Diag(InputExpr->getBeginLoc(),
diag::err_invalid_asm_value_for_constraint)
- << IntResult.toString(10) << Info.getConstraintStr()
+ << Result.toString(10) << Info.getConstraintStr()
<< InputExpr->getSourceRange());
}
diff --git a/clang/test/CodeGen/emit-summary-index.c b/clang/test/CodeGen/emit-summary-index.c
new file mode 100644
index 0000000..6126410
--- /dev/null
+++ b/clang/test/CodeGen/emit-summary-index.c
@@ -0,0 +1,17 @@
+// ; Check that the -flto=thin option emits a ThinLTO summary
+// RUN: %clang_cc1 -flto=thin -emit-llvm-bc < %s | llvm-bcanalyzer -dump | FileCheck %s
+// CHECK: <GLOBALVAL_SUMMARY_BLOCK
+//
+// ; Check that we do not emit a summary for regular LTO on Apple platforms
+// RUN: %clang_cc1 -flto -triple x86_64-apple-darwin -emit-llvm-bc < %s | llvm-bcanalyzer -dump | FileCheck --check-prefix=LTO %s
+// LTO-NOT: GLOBALVAL_SUMMARY_BLOCK
+//
+// ; Check that we emit a summary for regular LTO by default elsewhere
+// RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc < %s | llvm-bcanalyzer -dump | FileCheck --check-prefix=LTOINDEX %s
+// LTOINDEX: <FULL_LTO_GLOBALVAL_SUMMARY_BLOCK
+//
+// ; Simulate -save-temps and check that it works (!"ThinLTO" module flag not added multiple times)
+// RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc -disable-llvm-passes < %s -o %t.bc
+// RUN: %clang_cc1 -flto -triple x86_64-pc-linux-gnu -emit-llvm-bc -x ir < %t.bc | llvm-bcanalyzer -dump | FileCheck --check-prefix=LTOINDEX %s
+
+int main() {}
diff --git a/clang/test/CodeGen/pgo-instrumentation.c b/clang/test/CodeGen/pgo-instrumentation.c
index 35b6f8b..1dac36f 100644
--- a/clang/test/CodeGen/pgo-instrumentation.c
+++ b/clang/test/CodeGen/pgo-instrumentation.c
@@ -1,36 +1,20 @@
// Test if PGO instrumentation and use pass are invoked.
//
// Ensure Pass PGOInstrumentationGenPass is invoked.
-// RUN: %clang_cc1 -O2 -fprofile-instrument=llvm %s -mllvm -debug-pass=Structure -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=CHECK-PGOGENPASS-INVOKED-INSTR-GEN --check-prefix=CHECK-INSTRPROF
-// RUN: %clang_cc1 -O2 -fprofile-instrument=llvm %s -fexperimental-new-pass-manager -fdebug-pass-manager -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=CHECK-PGOGENPASS-INVOKED-INSTR-GEN-NEWPM --check-prefix=CHECK-INSTRPROF-NEWPM
+// RUN: %clang_cc1 -O2 -fprofile-instrument=llvm %s -mllvm -debug-pass=Structure -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=CHECK-PGOGENPASS-INVOKED-INSTR-GEN
// CHECK-PGOGENPASS-INVOKED-INSTR-GEN: PGOInstrumentationGenPass
-// CHECK-INSTRPROF: Frontend instrumentation-based coverage lowering
-// CHECK-PGOGENPASS-INVOKED-INSTR-GEN-NEWPM: Running pass: PGOInstrumentationGen on
-// CHECK-INSTRPROF-NEWPM: Running pass: InstrProfiling on
//
// Ensure Pass PGOInstrumentationGenPass is not invoked.
// RUN: %clang_cc1 -O2 -fprofile-instrument=clang %s -mllvm -debug-pass=Structure -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=CHECK-PGOGENPASS-INVOKED-INSTR-GEN-CLANG
-// RUN: %clang_cc1 -O2 -fprofile-instrument=clang %s -fexperimental-new-pass-manager -fdebug-pass-manager -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=CHECK-PGOGENPASS-INVOKED-INSTR-GEN-CLANG-NEWPM
// CHECK-PGOGENPASS-INVOKED-INSTR-GEN-CLANG-NOT: PGOInstrumentationGenPass
-// CHECK-PGOGENPASS-INVOKED-INSTR-GEN-CLANG-NEWPM-NOT: Running pass: PGOInstrumentationGen on
-
-// RUN: %clang_cc1 -O2 -fprofile-instrument=clang %s -mllvm -debug-pass=Structure -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-CLANG-INSTRPROF
-// RUN: %clang_cc1 -O2 -fprofile-instrument=clang %s -fexperimental-new-pass-manager -fdebug-pass-manager -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-CLANG-INSTRPROF-NEWPM
-// RUN: %clang_cc1 -O0 -fprofile-instrument=clang %s -mllvm -debug-pass=Structure -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-CLANG-INSTRPROF
-// RUN: %clang_cc1 -O0 -fprofile-instrument=clang %s -fexperimental-new-pass-manager -fdebug-pass-manager -emit-llvm -o - 2>&1 | FileCheck %s --check-prefix=CHECK-CLANG-INSTRPROF-NEWPM
-// CHECK-CLANG-INSTRPROF: Frontend instrumentation-based coverage lowering
-// CHECK-CLANG-INSTRPROF-NEWPM: Running pass: InstrProfiling on
// Ensure Pass PGOInstrumentationUsePass is invoked.
// RUN: llvm-profdata merge -o %t.profdata %S/Inputs/pgotestir.profraw
// RUN: %clang_cc1 -O2 -fprofile-instrument-use-path=%t.profdata %s -mllvm -debug-pass=Structure -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=CHECK-PGOUSEPASS-INVOKED-INSTR-USE
-// RUN: %clang_cc1 -O2 -fprofile-instrument-use-path=%t.profdata %s -fexperimental-new-pass-manager -fdebug-pass-manager -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=CHECK-PGOUSEPASS-INVOKED-INSTR-USE-NEWPM
// CHECK-PGOUSEPASS-INVOKED-INSTR-USE: PGOInstrumentationUsePass
-// CHECK-PGOUSEPASS-INVOKED-INSTR-USE-NEWPM: Running pass: PGOInstrumentationUse on
//
// Ensure Pass PGOInstrumentationUsePass is not invoked.
// RUN: llvm-profdata merge -o %t.profdata %S/Inputs/pgotestclang.profraw
// RUN: %clang_cc1 -O2 -fprofile-instrument-use-path=%t.profdata %s -mllvm -debug-pass=Structure -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=CHECK-PGOUSEPASS-INVOKED-USE-CLANG
-// RUN: %clang_cc1 -O2 -fprofile-instrument-use-path=%t.profdata %s -fexperimental-new-pass-manager -fdebug-pass-manager -emit-llvm -o - 2>&1 | FileCheck %s -check-prefix=CHECK-PGOUSEPASS-INVOKED-USE-CLANG-NEWPM
// CHECK-PGOUSEPASS-INVOKED-USE-CLANG-NOT: PGOInstrumentationUsePass
-// CHECK-PGOUSEPASS-INVOKED-USE-CLANG-NEWPM-NOT: Running pass: PGOInstrumentationUse on
+
diff --git a/clang/test/CodeGen/x86-64-inline-asm.c b/clang/test/CodeGen/x86-64-inline-asm.c
index 79c1bd9..bb46eda 100644
--- a/clang/test/CodeGen/x86-64-inline-asm.c
+++ b/clang/test/CodeGen/x86-64-inline-asm.c
@@ -1,7 +1,6 @@
// REQUIRES: x86-registered-target
// RUN: %clang_cc1 -triple x86_64 %s -S -o /dev/null -DWARN -verify
// RUN: %clang_cc1 -triple x86_64 %s -S -o /dev/null -Werror -verify
-// RUN: %clang_cc1 -triple x86_64-linux-gnu %s -S -o - | FileCheck %s
void f() {
asm("movaps %xmm3, (%esi, 2)");
// expected-note@1 {{instantiated into assembly here}}
@@ -16,17 +15,3 @@
void g(void) { asm volatile("movd %%xmm0, %0"
:
: "m"(var)); }
-
-void pr40890(void) {
- struct s {
- int a, b;
- } s;
- __asm__ __volatile__("\n#define S_A abcd%0\n" : : "n"(&((struct s*)0)->a));
- __asm__ __volatile__("\n#define S_B abcd%0\n" : : "n"(&((struct s*)0)->b));
- __asm__ __volatile__("\n#define BEEF abcd%0\n" : : "n"((int*)0xdeadbeeeeeef));
-
-// CHECK-LABEL: pr40890
-// CHECK: #define S_A abcd$0
-// CHECK: #define S_B abcd$4
-// CHECK: #define BEEF abcd$244837814038255
-}
diff --git a/clang/test/Driver/arm-float-abi.c b/clang/test/Driver/arm-float-abi.c
index 9a76d1e..e5b42c9 100644
--- a/clang/test/Driver/arm-float-abi.c
+++ b/clang/test/Driver/arm-float-abi.c
@@ -4,13 +4,3 @@
// ARMV7-ERROR: unsupported option '-mfloat-abi=hard' for target 'thumbv7'
// NOERROR-NOT: unsupported option
-
-// RUN: %clang -target armv7-linux-androideabi21 %s -### -c 2>&1 \
-// RUN: | FileCheck --check-prefix=CHECK-ARM7-ANDROID %s
-// CHECK-ARM7-ANDROID-NOT: "-target-feature" "+soft-float"
-// CHECK-ARM7-ANDROID: "-target-feature" "+soft-float-abi"
-
-// RUN: %clang -target armv8-linux-androideabi21 %s -### -c 2>&1 \
-// RUN: | FileCheck --check-prefix=CHECK-ARM8-ANDROID %s
-// CHECK-ARM8-ANDROID-NOT: "-target-feature" "+soft-float"
-// CHECK-ARM8-ANDROID: "-target-feature" "+soft-float-abi"
diff --git a/clang/test/Profile/c-general.c b/clang/test/Profile/c-general.c
index 4e8eb5e..22b4288 100644
--- a/clang/test/Profile/c-general.c
+++ b/clang/test/Profile/c-general.c
@@ -1,12 +1,10 @@
// Test instrumentation of general constructs in C.
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-general.c %s -o - -emit-llvm -fprofile-instrument=clang | FileCheck -allow-deprecated-dag-overlap -check-prefix=PGOGEN %s
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-general.c %s -o - -emit-llvm -fprofile-instrument=clang -fexperimental-new-pass-manager | FileCheck -allow-deprecated-dag-overlap -check-prefix=PGOGEN %s
// RUN: llvm-profdata merge %S/Inputs/c-general.proftext -o %t.profdata
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-general.c %s -o - -emit-llvm -fprofile-instrument-use-path=%t.profdata | FileCheck -allow-deprecated-dag-overlap -check-prefix=PGOUSE %s
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-general.c %s -o - -emit-llvm -fprofile-instrument-use-path=%S/Inputs/c-general.profdata.v3 | FileCheck -allow-deprecated-dag-overlap -check-prefix=PGOUSE %s
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-general.c %s -o - -emit-llvm -fprofile-instrument-use-path=%S/Inputs/c-general.profdata.v3 -fexperimental-new-pass-manager | FileCheck -allow-deprecated-dag-overlap -check-prefix=PGOUSE %s
// Also check compatibility with older profiles.
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-general.c %s -o - -emit-llvm -fprofile-instrument-use-path=%S/Inputs/c-general.profdata.v1 | FileCheck -allow-deprecated-dag-overlap -check-prefix=PGOUSE %s
diff --git a/clang/test/Sema/inline-asm-validate-x86.c b/clang/test/Sema/inline-asm-validate-x86.c
index 5ea20eec..f21ef69 100644
--- a/clang/test/Sema/inline-asm-validate-x86.c
+++ b/clang/test/Sema/inline-asm-validate-x86.c
@@ -1,5 +1,5 @@
// RUN: %clang_cc1 -triple i686 -fsyntax-only -verify %s
-// RUN: %clang_cc1 -triple x86_64 -fsyntax-only -verify -DAMD64 %s
+// RUN: %clang_cc1 -triple x86_64 -fsyntax-only -verify %s
void I(int i, int j) {
static const int BelowMin = -1;
@@ -55,7 +55,6 @@
void L(int i, int j) {
static const int Invalid1 = 1;
static const int Invalid2 = 42;
- static const int Invalid3 = 0;
static const int Valid1 = 0xff;
static const int Valid2 = 0xffff;
static const int Valid3 = 0xffffffff;
@@ -70,9 +69,6 @@
: "0"(i), "L"(Invalid2)); // expected-error{{value '42' out of range for constraint 'L'}}
__asm__("xorl %0,%2"
: "=r"(i)
- : "0"(i), "L"(Invalid3)); // expected-error{{value '0' out of range for constraint 'L'}}
- __asm__("xorl %0,%2"
- : "=r"(i)
: "0"(i), "L"(Valid1)); // expected-no-error
__asm__("xorl %0,%2"
: "=r"(i)
@@ -133,21 +129,3 @@
: "0"(i), "O"(64)); // expected-no-error
}
-void pr40890(void) {
- struct s {
- int a, b;
- };
- static struct s s;
- // This null pointer can be used as an integer constant expression.
- __asm__ __volatile__("\n#define S_A abcd%0\n" : : "n"(&((struct s*)0)->a));
- // This offset-from-null pointer can be used as an integer constant expression.
- __asm__ __volatile__("\n#define S_B abcd%0\n" : : "n"(&((struct s*)0)->b));
- // This pointer cannot be used as an integer constant expression.
- __asm__ __volatile__("\n#define GLOBAL_A abcd%0\n" : : "n"(&s.a)); // expected-error{{constraint 'n' expects an integer constant expression}}
- // Floating-point is also not okay.
- __asm__ __volatile__("\n#define PI abcd%0\n" : : "n"(3.14f)); // expected-error{{constraint 'n' expects an integer constant expression}}
-#ifdef AMD64
- // This arbitrary pointer is fine.
- __asm__ __volatile__("\n#define BEEF abcd%0\n" : : "n"((int*)0xdeadbeeeeeef));
-#endif
-}
diff --git a/clang/test/SemaCXX/constant-expression-cxx1y.cpp b/clang/test/SemaCXX/constant-expression-cxx1y.cpp
index ed51cca..3c57ac5 100644
--- a/clang/test/SemaCXX/constant-expression-cxx1y.cpp
+++ b/clang/test/SemaCXX/constant-expression-cxx1y.cpp
@@ -1135,27 +1135,3 @@
return __builtin_constant_p(*__s);
}
constexpr bool n = indirect_builtin_constant_p("a");
-
-__attribute__((enable_if(indirect_builtin_constant_p("a") == n, "OK")))
-int test_in_enable_if() { return 0; }
-int n2 = test_in_enable_if();
-
-template <bool n = indirect_builtin_constant_p("a")>
-int test_in_template_param() { return 0; }
-int n3 = test_in_template_param();
-
-void test_in_case(int n) {
- switch (n) {
- case indirect_builtin_constant_p("abc"):
- break;
- }
-}
-enum InEnum1 {
- ONE = indirect_builtin_constant_p("abc")
-};
-enum InEnum2 : int {
- TWO = indirect_builtin_constant_p("abc")
-};
-enum class InEnum3 {
- THREE = indirect_builtin_constant_p("abc")
-};
diff --git a/clang/test/SemaCXX/enable_if.cpp b/clang/test/SemaCXX/enable_if.cpp
index 4bc974d..ba520b0 100644
--- a/clang/test/SemaCXX/enable_if.cpp
+++ b/clang/test/SemaCXX/enable_if.cpp
@@ -514,11 +514,3 @@
static_assert(is_same<__typeof__(foo)*, decltype(&foo)>::value, "");
}
-
-namespace InConstantContext {
-void foo(const char *s) __attribute__((enable_if(((void)__builtin_constant_p(*s), true), "trap"))) {}
-
-void test() {
- InConstantContext::foo("abc");
-}
-} // namespace InConstantContext
diff --git a/clang/tools/CMakeLists.txt b/clang/tools/CMakeLists.txt
index 02ac9b9..43dfffe 100644
--- a/clang/tools/CMakeLists.txt
+++ b/clang/tools/CMakeLists.txt
@@ -35,4 +35,3 @@
# libclang may require clang-tidy in clang-tools-extra.
add_clang_subdirectory(libclang)
-add_clang_subdirectory(libclang-cxx)
diff --git a/clang/tools/libclang-cxx/CMakeLists.txt b/clang/tools/libclang-cxx/CMakeLists.txt
deleted file mode 100644
index 04cf404..0000000
--- a/clang/tools/libclang-cxx/CMakeLists.txt
+++ /dev/null
@@ -1,88 +0,0 @@
-set(SOURCES
- libclang_cxx.cpp
- )
-
-set(LIBS
- clangBasic
- clangCodeGen
- clangDriver
- clangFrontend
- clangFrontendTool
- clangIndex
- clangTooling
-)
-
-if (CLANG_ENABLE_ARCMT)
- list(APPEND LIBS clangARCMigrate)
-endif ()
-
-if (TARGET clangTidyPlugin)
- add_definitions(-DCLANG_TOOL_EXTRA_BUILD)
- list(APPEND LIBS clangTidyPlugin)
- list(APPEND LIBS clangIncludeFixerPlugin)
- if(LLVM_ENABLE_MODULES)
- list(APPEND LLVM_COMPILE_FLAGS "-fmodules-ignore-macro=CLANG_TOOL_EXTRA_BUILD")
- endif()
-endif ()
-
-find_library(DL_LIBRARY_PATH dl)
-if (DL_LIBRARY_PATH)
- list(APPEND LIBS dl)
-endif()
-
-if(NOT WIN32)
- set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/libclang_cxx.exports)
-endif()
-
-if( LLVM_ENABLE_PIC )
- set(ENABLE_SHARED SHARED)
-endif()
-
-if(NOT LLVM_ENABLE_PIC AND NOT WIN32)
- set(ENABLE_STATIC STATIC)
-endif()
-
-if(WIN32)
- set(output_name "libclang_cxx")
-else()
- set(output_name "clang_cxx")
-endif()
-
-if(("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") OR (MINGW))
- set(LIBS -Wl,--whole-archive ${LIBS} -Wl,--no-whole-archive)
-elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
- set(LIBS -Wl,-all_load ${LIBS})
-endif()
-
-add_clang_library(libclang_cxx ${ENABLE_SHARED} ${ENABLE_STATIC}
- OUTPUT_NAME ${output_name}
- ${SOURCES}
- LINK_LIBS
- ${LIBS}
- )
-
-if(ENABLE_SHARED)
- if(WIN32)
- set_target_properties(libclang_cxx
- PROPERTIES
- VERSION ${LIBCLANG_LIBRARY_VERSION}
- DEFINE_SYMBOL _CINDEX_LIB_)
- elseif(APPLE)
- set(LIBCLANG_CXX_LINK_FLAGS " -Wl,-compatibility_version -Wl,1")
- set(LIBCLANG_CXX_LINK_FLAGS "${LIBCLANG_CXX_LINK_FLAGS} -Wl,-current_version -Wl,${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}")
-
- set_property(TARGET libclang_cxx APPEND_STRING PROPERTY
- LINK_FLAGS ${LIBCLANG_CXX_LINK_FLAGS})
- else()
- set_target_properties(libclang_cxx
- PROPERTIES
- VERSION ${LIBCLANG_LIBRARY_VERSION}
- DEFINE_SYMBOL _CINDEX_LIB_)
- # FIXME: _CINDEX_LIB_ affects dllexport/dllimport on Win32.
- if(LLVM_ENABLE_MODULES AND NOT WIN32)
- target_compile_options(libclang_cxx PRIVATE
- "-fmodules-ignore-macro=_CINDEX_LIB_"
- )
- endif()
- endif()
-endif()
diff --git a/clang/tools/libclang-cxx/libclang_cxx.cpp b/clang/tools/libclang-cxx/libclang_cxx.cpp
deleted file mode 100644
index ef6a015..0000000
--- a/clang/tools/libclang-cxx/libclang_cxx.cpp
+++ /dev/null
@@ -1,7 +0,0 @@
-//===- libclang_cxx.cpp - libclang_cxx Shared Library -----------------------------------===//
-//===----------------------------------------------------------------------===//
-//
-// This file is empty and serves only the purpose of making CMake happy because
-// you can't define a target with no sources.
-//
-//===----------------------------------------------------------------------===//
diff --git a/clang/tools/libclang-cxx/libclang_cxx.exports b/clang/tools/libclang-cxx/libclang_cxx.exports
deleted file mode 100644
index 3ffc064..0000000
--- a/clang/tools/libclang-cxx/libclang_cxx.exports
+++ /dev/null
@@ -1 +0,0 @@
-_Z*clang*
diff --git a/compiler-rt/cmake/config-ix.cmake b/compiler-rt/cmake/config-ix.cmake
index f08975b..90192f7 100644
--- a/compiler-rt/cmake/config-ix.cmake
+++ b/compiler-rt/cmake/config-ix.cmake
@@ -228,7 +228,7 @@
set(ALL_ASAN_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64}
${MIPS32} ${MIPS64} ${PPC64} ${S390X})
set(ALL_DFSAN_SUPPORTED_ARCH ${X86_64} ${MIPS64} ${ARM64})
-set(ALL_FUZZER_SUPPORTED_ARCH ${X86} ${X86_64} ${ARM32} ${ARM64} ${MIPS32} ${MIPS64})
+set(ALL_FUZZER_SUPPORTED_ARCH ${X86_64} ${ARM64})
if(APPLE)
set(ALL_LSAN_SUPPORTED_ARCH ${X86} ${X86_64} ${MIPS64} ${ARM64})
diff --git a/compiler-rt/include/sanitizer/hwasan_interface.h b/compiler-rt/include/sanitizer/hwasan_interface.h
index 104af4c..731ffc4 100644
--- a/compiler-rt/include/sanitizer/hwasan_interface.h
+++ b/compiler-rt/include/sanitizer/hwasan_interface.h
@@ -50,10 +50,6 @@
// does would cause false reports.
void __hwasan_handle_longjmp(const void *sp_dst);
- // Set memory tag for the part of the current thread stack below sp_dst to
- // zero. Call this in vfork() before returning in the parent process.
- void __hwasan_handle_vfork(const void *sp_dst);
-
// Libc hook for thread creation. Should be called in the child thread before
// any instrumented code.
void __hwasan_thread_enter();
@@ -69,10 +65,6 @@
// Print one-line report about the memory usage of the current process.
void __hwasan_print_memory_usage();
- /* Returns the offset of the first byte in the memory range that can not be
- * accessed through the pointer in x, or -1 if the whole range is good. */
- intptr_t __hwasan_test_shadow(const volatile void *x, size_t size);
-
int __sanitizer_posix_memalign(void **memptr, size_t alignment, size_t size);
void * __sanitizer_memalign(size_t alignment, size_t size);
void * __sanitizer_aligned_alloc(size_t alignment, size_t size);
diff --git a/compiler-rt/lib/asan/CMakeLists.txt b/compiler-rt/lib/asan/CMakeLists.txt
index a80f5c6..726da27 100644
--- a/compiler-rt/lib/asan/CMakeLists.txt
+++ b/compiler-rt/lib/asan/CMakeLists.txt
@@ -32,10 +32,6 @@
asan_thread.cc
asan_win.cc)
-if (NOT WIN32 AND NOT APPLE)
- list(APPEND ASAN_SOURCES asan_interceptors_vfork.S)
-endif()
-
set(ASAN_CXX_SOURCES
asan_new_delete.cc)
diff --git a/compiler-rt/lib/asan/asan_interceptors.cc b/compiler-rt/lib/asan/asan_interceptors.cc
index 234cabc..7f2660d 100644
--- a/compiler-rt/lib/asan/asan_interceptors.cc
+++ b/compiler-rt/lib/asan/asan_interceptors.cc
@@ -579,11 +579,6 @@
}
#endif // ASAN_INTERCEPT___CXA_ATEXIT
-#if ASAN_INTERCEPT_VFORK
-DEFINE_REAL(int, vfork);
-DECLARE_EXTERN_INTERCEPTOR_AND_WRAPPER(int, vfork);
-#endif
-
// ---------------------- InitializeAsanInterceptors ---------------- {{{1
namespace __asan {
void InitializeAsanInterceptors() {
@@ -661,10 +656,6 @@
ASAN_INTERCEPT_FUNC(__cxa_atexit);
#endif
-#if ASAN_INTERCEPT_VFORK
- ASAN_INTERCEPT_FUNC(vfork);
-#endif
-
InitializePlatformInterceptors();
VReport(1, "AddressSanitizer: libc interceptors initialized\n");
diff --git a/compiler-rt/lib/asan/asan_interceptors.h b/compiler-rt/lib/asan/asan_interceptors.h
index 903ab59..271f373 100644
--- a/compiler-rt/lib/asan/asan_interceptors.h
+++ b/compiler-rt/lib/asan/asan_interceptors.h
@@ -105,13 +105,6 @@
# define ASAN_INTERCEPT___STRDUP 0
#endif
-#if SANITIZER_LINUX && (defined(__arm__) || defined(__aarch64__) || \
- defined(__i386__) || defined(__x86_64__))
-# define ASAN_INTERCEPT_VFORK 1
-#else
-# define ASAN_INTERCEPT_VFORK 0
-#endif
-
DECLARE_REAL(int, memcmp, const void *a1, const void *a2, uptr size)
DECLARE_REAL(char*, strchr, const char *str, int c)
DECLARE_REAL(SIZE_T, strlen, const char *s)
diff --git a/compiler-rt/lib/asan/asan_interceptors_vfork.S b/compiler-rt/lib/asan/asan_interceptors_vfork.S
deleted file mode 100644
index 90a169d..0000000
--- a/compiler-rt/lib/asan/asan_interceptors_vfork.S
+++ /dev/null
@@ -1,12 +0,0 @@
-#include "sanitizer_common/sanitizer_asm.h"
-
-#if defined(__linux__)
-#define COMMON_INTERCEPTOR_SPILL_AREA __asan_extra_spill_area
-#define COMMON_INTERCEPTOR_HANDLE_VFORK __asan_handle_vfork
-#include "sanitizer_common/sanitizer_common_interceptors_vfork_aarch64.inc.S"
-#include "sanitizer_common/sanitizer_common_interceptors_vfork_arm.inc.S"
-#include "sanitizer_common/sanitizer_common_interceptors_vfork_x86_64.inc.S"
-#include "sanitizer_common/sanitizer_common_interceptors_vfork_i386.inc.S"
-#endif
-
-NO_EXEC_STACK_DIRECTIVE
diff --git a/compiler-rt/lib/asan/asan_interface.inc b/compiler-rt/lib/asan/asan_interface.inc
index 7c341f2..1dd9c63 100644
--- a/compiler-rt/lib/asan/asan_interface.inc
+++ b/compiler-rt/lib/asan/asan_interface.inc
@@ -38,7 +38,6 @@
INTERFACE_FUNCTION(__asan_get_report_sp)
INTERFACE_FUNCTION(__asan_get_shadow_mapping)
INTERFACE_FUNCTION(__asan_handle_no_return)
-INTERFACE_FUNCTION(__asan_handle_vfork)
INTERFACE_FUNCTION(__asan_init)
INTERFACE_FUNCTION(__asan_load_cxx_array_cookie)
INTERFACE_FUNCTION(__asan_load1)
diff --git a/compiler-rt/lib/asan/asan_interface_internal.h b/compiler-rt/lib/asan/asan_interface_internal.h
index c83aa11..ea8750e 100644
--- a/compiler-rt/lib/asan/asan_interface_internal.h
+++ b/compiler-rt/lib/asan/asan_interface_internal.h
@@ -249,8 +249,6 @@
SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
const char* __asan_default_suppressions();
-
- SANITIZER_INTERFACE_ATTRIBUTE void __asan_handle_vfork(void *sp);
} // extern "C"
#endif // ASAN_INTERFACE_INTERNAL_H
diff --git a/compiler-rt/lib/asan/asan_rtl.cc b/compiler-rt/lib/asan/asan_rtl.cc
index db8dcd0..67eb1a7 100644
--- a/compiler-rt/lib/asan/asan_rtl.cc
+++ b/compiler-rt/lib/asan/asan_rtl.cc
@@ -597,19 +597,6 @@
curr_thread->fake_stack()->HandleNoReturn();
}
-extern "C" void *__asan_extra_spill_area() {
- AsanThread *t = GetCurrentThread();
- CHECK(t);
- return t->extra_spill_area();
-}
-
-void __asan_handle_vfork(void *sp) {
- AsanThread *t = GetCurrentThread();
- CHECK(t);
- uptr bottom = t->stack_bottom();
- PoisonShadow(bottom, (uptr)sp - bottom, 0);
-}
-
void NOINLINE __asan_set_death_callback(void (*callback)(void)) {
SetUserDieCallback(callback);
}
diff --git a/compiler-rt/lib/asan/asan_thread.h b/compiler-rt/lib/asan/asan_thread.h
index 5a6010e..1e08d57 100644
--- a/compiler-rt/lib/asan/asan_thread.h
+++ b/compiler-rt/lib/asan/asan_thread.h
@@ -130,8 +130,6 @@
AsanThreadLocalMallocStorage &malloc_storage() { return malloc_storage_; }
AsanStats &stats() { return stats_; }
- void *extra_spill_area() { return &extra_spill_area_; }
-
private:
// NOTE: There is no AsanThread constructor. It is allocated
// via mmap() and *must* be valid in zero-initialized state.
@@ -167,7 +165,6 @@
AsanThreadLocalMallocStorage malloc_storage_;
AsanStats stats_;
bool unwinding_;
- uptr extra_spill_area_;
};
// ScopedUnwinding is a scope for stacktracing member of a context
diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt
index bc3e876..1669ea8 100644
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -94,7 +94,6 @@
floatunsisf.c
floatuntidf.c
floatuntisf.c
- fp_mode.c
int_util.c
lshrdi3.c
lshrti3.c
@@ -151,8 +150,7 @@
udivti3.c
umoddi3.c
umodsi3.c
- umodti3.c
-)
+ umodti3.c)
set(GENERIC_TF_SOURCES
comparetf2.c
@@ -172,8 +170,7 @@
floatuntitf.c
multc3.c
trunctfdf2.c
- trunctfsf2.c
-)
+ trunctfsf2.c)
option(COMPILER_RT_EXCLUDE_ATOMIC_BUILTIN
"Skip the atomic builtin (these should normally be provided by a shared library)"
@@ -182,17 +179,15 @@
if(NOT FUCHSIA AND NOT COMPILER_RT_BAREMETAL_BUILD)
set(GENERIC_SOURCES
${GENERIC_SOURCES}
- emutls.c
+ emutls.c
enable_execute_stack.c
- eprintf.c
- )
+ eprintf.c)
endif()
if(COMPILER_RT_HAS_ATOMIC_KEYWORD AND NOT COMPILER_RT_EXCLUDE_ATOMIC_BUILTIN)
set(GENERIC_SOURCES
${GENERIC_SOURCES}
- atomic.c
- )
+ atomic.c)
endif()
if(APPLE)
@@ -203,22 +198,19 @@
atomic_flag_test_and_set.c
atomic_flag_test_and_set_explicit.c
atomic_signal_fence.c
- atomic_thread_fence.c
- )
+ atomic_thread_fence.c)
endif()
if (HAVE_UNWIND_H)
set(GENERIC_SOURCES
- ${GENERIC_SOURCES}
- gcc_personality_v0.c
- )
+ ${GENERIC_SOURCES}
+ gcc_personality_v0.c)
endif ()
if (NOT FUCHSIA)
set(GENERIC_SOURCES
${GENERIC_SOURCES}
- clear_cache.c
- )
+ clear_cache.c)
endif()
# These sources work on all x86 variants, but only x86 variants.
@@ -240,60 +232,54 @@
if (NOT MSVC)
set(x86_64_SOURCES
- ${GENERIC_TF_SOURCES}
- x86_64/floatdidf.c
- x86_64/floatdisf.c
- x86_64/floatdixf.c
- x86_64/floatundidf.S
- x86_64/floatundisf.S
- x86_64/floatundixf.S
- )
+ x86_64/floatdidf.c
+ x86_64/floatdisf.c
+ x86_64/floatdixf.c
+ x86_64/floatundidf.S
+ x86_64/floatundisf.S
+ x86_64/floatundixf.S)
filter_builtin_sources(x86_64_SOURCES EXCLUDE x86_64_SOURCES "${x86_64_SOURCES};${GENERIC_SOURCES}")
set(x86_64h_SOURCES ${x86_64_SOURCES})
if (WIN32)
set(x86_64_SOURCES
- ${x86_64_SOURCES}
- x86_64/chkstk.S
- x86_64/chkstk2.S
- )
+ ${x86_64_SOURCES}
+ x86_64/chkstk.S
+ x86_64/chkstk2.S)
endif()
set(i386_SOURCES
- i386/ashldi3.S
- i386/ashrdi3.S
- i386/divdi3.S
- i386/floatdidf.S
- i386/floatdisf.S
- i386/floatdixf.S
- i386/floatundidf.S
- i386/floatundisf.S
- i386/floatundixf.S
- i386/lshrdi3.S
- i386/moddi3.S
- i386/muldi3.S
- i386/udivdi3.S
- i386/umoddi3.S
- )
+ i386/ashldi3.S
+ i386/ashrdi3.S
+ i386/divdi3.S
+ i386/floatdidf.S
+ i386/floatdisf.S
+ i386/floatdixf.S
+ i386/floatundidf.S
+ i386/floatundisf.S
+ i386/floatundixf.S
+ i386/lshrdi3.S
+ i386/moddi3.S
+ i386/muldi3.S
+ i386/udivdi3.S
+ i386/umoddi3.S)
filter_builtin_sources(i386_SOURCES EXCLUDE i386_SOURCES "${i386_SOURCES};${GENERIC_SOURCES}")
if (WIN32)
set(i386_SOURCES
- ${i386_SOURCES}
- i386/chkstk.S
- i386/chkstk2.S
- )
+ ${i386_SOURCES}
+ i386/chkstk.S
+ i386/chkstk2.S)
endif()
else () # MSVC
# Use C versions of functions when building on MSVC
# MSVC's assembler takes Intel syntax, not AT&T syntax.
# Also use only MSVC compilable builtin implementations.
set(x86_64_SOURCES
- x86_64/floatdidf.c
- x86_64/floatdisf.c
- x86_64/floatdixf.c
- ${GENERIC_SOURCES}
- )
+ x86_64/floatdidf.c
+ x86_64/floatdisf.c
+ x86_64/floatdixf.c
+ ${GENERIC_SOURCES})
set(x86_64h_SOURCES ${x86_64_SOURCES})
set(i386_SOURCES ${GENERIC_SOURCES})
endif () # if (NOT MSVC)
@@ -304,7 +290,6 @@
set(i686_SOURCES ${i686_SOURCES} ${x86_ARCH_SOURCES})
set(arm_SOURCES
- arm/fp_mode.c
arm/bswapdi2.S
arm/bswapsi2.S
arm/clzdi2.S
@@ -335,8 +320,7 @@
arm/sync_fetch_and_xor_8.S
arm/udivmodsi4.S
arm/udivsi3.S
- arm/umodsi3.S
-)
+ arm/umodsi3.S)
filter_builtin_sources(arm_SOURCES EXCLUDE arm_SOURCES "${arm_SOURCES};${GENERIC_SOURCES}")
set(thumb1_SOURCES
@@ -344,8 +328,7 @@
arm/udivsi3.S
arm/comparesf2.S
arm/addsf3.S
- ${GENERIC_SOURCES}
-)
+ ${GENERIC_SOURCES})
set(arm_EABI_SOURCES
arm/aeabi_cdcmp.S
@@ -364,19 +347,16 @@
arm/aeabi_memmove.S
arm/aeabi_memset.S
arm/aeabi_uidivmod.S
- arm/aeabi_uldivmod.S
-)
+ arm/aeabi_uldivmod.S)
set(arm_Thumb1_JT_SOURCES
arm/switch16.S
arm/switch32.S
arm/switch8.S
- arm/switchu8.S
-)
+ arm/switchu8.S)
set(arm_Thumb1_SjLj_EH_SOURCES
arm/restore_vfp_d8_d15_regs.S
- arm/save_vfp_d8_d15_regs.S
-)
+ arm/save_vfp_d8_d15_regs.S)
set(arm_Thumb1_VFPv2_SOURCES
arm/adddf3vfp.S
arm/addsf3vfp.S
@@ -411,71 +391,62 @@
arm/subsf3vfp.S
arm/truncdfsf2vfp.S
arm/unorddf2vfp.S
- arm/unordsf2vfp.S
-)
+ arm/unordsf2vfp.S)
set(arm_Thumb1_icache_SOURCES
- arm/sync_synchronize.S
-)
+ arm/sync_synchronize.S)
set(arm_Thumb1_SOURCES
${arm_Thumb1_JT_SOURCES}
${arm_Thumb1_SjLj_EH_SOURCES}
${arm_Thumb1_VFPv2_SOURCES}
- ${arm_Thumb1_icache_SOURCES}
-)
+ ${arm_Thumb1_icache_SOURCES})
if(MINGW)
set(arm_SOURCES
- arm/aeabi_idivmod.S
- arm/aeabi_ldivmod.S
- arm/aeabi_uidivmod.S
- arm/aeabi_uldivmod.S
- arm/chkstk.S
- divmoddi4.c
- divmodsi4.c
- divdi3.c
- divsi3.c
- fixdfdi.c
- fixsfdi.c
- fixunsdfdi.c
- fixunssfdi.c
- floatdidf.c
- floatdisf.c
- floatundidf.c
- floatundisf.c
- mingw_fixfloat.c
- moddi3.c
- udivmoddi4.c
- udivmodsi4.c
- udivsi3.c
- umoddi3.c
- emutls.c
- )
+ arm/aeabi_idivmod.S
+ arm/aeabi_ldivmod.S
+ arm/aeabi_uidivmod.S
+ arm/aeabi_uldivmod.S
+ arm/chkstk.S
+ divmoddi4.c
+ divmodsi4.c
+ divdi3.c
+ divsi3.c
+ fixdfdi.c
+ fixsfdi.c
+ fixunsdfdi.c
+ fixunssfdi.c
+ floatdidf.c
+ floatdisf.c
+ floatundidf.c
+ floatundisf.c
+ mingw_fixfloat.c
+ moddi3.c
+ udivmoddi4.c
+ udivmodsi4.c
+ udivsi3.c
+ umoddi3.c
+ emutls.c)
filter_builtin_sources(arm_SOURCES EXCLUDE arm_SOURCES "${arm_SOURCES};${GENERIC_SOURCES}")
elseif(NOT WIN32)
# TODO the EABI sources should only be added to EABI targets
set(arm_SOURCES
${arm_SOURCES}
${arm_EABI_SOURCES}
- ${arm_Thumb1_SOURCES}
- )
+ ${arm_Thumb1_SOURCES})
set(thumb1_SOURCES
${thumb1_SOURCES}
- ${arm_EABI_SOURCES}
- )
+ ${arm_EABI_SOURCES})
endif()
set(aarch64_SOURCES
${GENERIC_TF_SOURCES}
- ${GENERIC_SOURCES}
- aarch64/fp_mode.c
-)
+ ${GENERIC_SOURCES})
if (MINGW)
set(aarch64_SOURCES
- ${aarch64_SOURCES}
- aarch64/chkstk.S
- )
+ ${aarch64_SOURCES}
+ aarch64/chkstk.S)
endif()
set(armhf_SOURCES ${arm_SOURCES})
@@ -521,8 +492,7 @@
hexagon/udivmodsi4.S
hexagon/udivsi3.S
hexagon/umoddi3.S
- hexagon/umodsi3.S
-)
+ hexagon/umodsi3.S)
set(mips_SOURCES ${GENERIC_SOURCES})
@@ -545,25 +515,21 @@
ppc/gcc_qmul.c
ppc/gcc_qsub.c
ppc/multc3.c
- ${GENERIC_SOURCES}
-)
+ ${GENERIC_SOURCES})
set(powerpc64le_SOURCES ${powerpc64_SOURCES})
set(riscv_SOURCES ${GENERIC_SOURCES} ${GENERIC_TF_SOURCES})
set(riscv32_SOURCES
riscv/mulsi3.S
- ${riscv_SOURCES}
-)
+ ${riscv_SOURCES})
set(riscv64_SOURCES ${riscv_SOURCES})
set(wasm32_SOURCES
${GENERIC_TF_SOURCES}
- ${GENERIC_SOURCES}
-)
+ ${GENERIC_SOURCES})
set(wasm64_SOURCES
${GENERIC_TF_SOURCES}
- ${GENERIC_SOURCES}
-)
+ ${GENERIC_SOURCES})
add_custom_target(builtins)
set_target_properties(builtins PROPERTIES FOLDER "Compiler-RT Misc")
diff --git a/compiler-rt/lib/builtins/aarch64/fp_mode.c b/compiler-rt/lib/builtins/aarch64/fp_mode.c
deleted file mode 100644
index aa81fbc..0000000
--- a/compiler-rt/lib/builtins/aarch64/fp_mode.c
+++ /dev/null
@@ -1,53 +0,0 @@
-//===----- lib/aarch64/fp_mode.c - Floaing-point mode utilities ---*- C -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include <stdint.h>
-
-#include "../fp_mode.h"
-
-#define AARCH64_TONEAREST 0x0
-#define AARCH64_UPWARD 0x1
-#define AARCH64_DOWNWARD 0x2
-#define AARCH64_TOWARDZERO 0x3
-#define AARCH64_RMODE_MASK (AARCH64_TONEAREST | AARCH64_UPWARD | \
- AARCH64_DOWNWARD | AARCH64_TOWARDZERO)
-#define AARCH64_RMODE_SHIFT 22
-
-#define AARCH64_INEXACT 0x10
-
-FE_ROUND_MODE __fe_getround() {
-#ifdef __ARM_FP
- uint64_t fpcr;
- __asm__ __volatile__("mrs %0, fpcr" : "=r" (fpcr));
- fpcr = fpcr >> AARCH64_RMODE_SHIFT & AARCH64_RMODE_MASK;
- switch (fpcr) {
- case AARCH64_UPWARD:
- return FE_UPWARD;
- case AARCH64_DOWNWARD:
- return FE_DOWNWARD;
- case AARCH64_TOWARDZERO:
- return FE_TOWARDZERO;
- case AARCH64_TONEAREST:
- default:
- return FE_TONEAREST;
- }
-#else
- return FE_TONEAREST;
-#endif
-}
-
-int __fe_raise_inexact() {
-#ifdef __ARM_FP
- uint64_t fpsr;
- __asm__ __volatile__("mrs %0, fpsr" : "=r" (fpsr));
- __asm__ __volatile__("msr fpsr, %0" : : "ri" (fpsr | AARCH64_INEXACT));
- return 0;
-#else
- return 0;
-#endif
-}
diff --git a/compiler-rt/lib/builtins/adddf3.c b/compiler-rt/lib/builtins/adddf3.c
index d5c5e98..73ad615 100644
--- a/compiler-rt/lib/builtins/adddf3.c
+++ b/compiler-rt/lib/builtins/adddf3.c
@@ -6,7 +6,8 @@
//
//===----------------------------------------------------------------------===//
//
-// This file implements double-precision soft-float addition.
+// This file implements double-precision soft-float addition with the IEEE-754
+// default rounding (to nearest, ties to even).
//
//===----------------------------------------------------------------------===//
diff --git a/compiler-rt/lib/builtins/addsf3.c b/compiler-rt/lib/builtins/addsf3.c
index 95985b1..a48d537 100644
--- a/compiler-rt/lib/builtins/addsf3.c
+++ b/compiler-rt/lib/builtins/addsf3.c
@@ -6,7 +6,8 @@
//
//===----------------------------------------------------------------------===//
//
-// This file implements single-precision soft-float addition.
+// This file implements single-precision soft-float addition with the IEEE-754
+// default rounding (to nearest, ties to even).
//
//===----------------------------------------------------------------------===//
diff --git a/compiler-rt/lib/builtins/addtf3.c b/compiler-rt/lib/builtins/addtf3.c
index 156c251..1dc303b 100644
--- a/compiler-rt/lib/builtins/addtf3.c
+++ b/compiler-rt/lib/builtins/addtf3.c
@@ -6,7 +6,8 @@
//
//===----------------------------------------------------------------------===//
//
-// This file implements quad-precision soft-float addition.
+// This file implements quad-precision soft-float addition with the IEEE-754
+// default rounding (to nearest, ties to even).
//
//===----------------------------------------------------------------------===//
diff --git a/compiler-rt/lib/builtins/arm/comparesf2.S b/compiler-rt/lib/builtins/arm/comparesf2.S
index d5cc922..5f76b6f 100644
--- a/compiler-rt/lib/builtins/arm/comparesf2.S
+++ b/compiler-rt/lib/builtins/arm/comparesf2.S
@@ -175,11 +175,6 @@
DEFINE_COMPILERRT_FUNCTION_ALIAS(__ltsf2, __eqsf2)
DEFINE_COMPILERRT_FUNCTION_ALIAS(__nesf2, __eqsf2)
-#if defined(__ELF__)
-// Alias for libgcc compatibility
-DEFINE_COMPILERRT_FUNCTION_ALIAS(__cmpsf2, __lesf2)
-#endif
-
@ int __gtsf2(float a, float b)
.p2align 2
diff --git a/compiler-rt/lib/builtins/arm/fp_mode.c b/compiler-rt/lib/builtins/arm/fp_mode.c
deleted file mode 100644
index 8fecee8..0000000
--- a/compiler-rt/lib/builtins/arm/fp_mode.c
+++ /dev/null
@@ -1,53 +0,0 @@
-//===----- lib/arm/fp_mode.c - Floaing-point mode utilities -------*- C -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include <stdint.h>
-
-#include "../fp_mode.h"
-
-#define ARM_TONEAREST 0x0
-#define ARM_UPWARD 0x1
-#define ARM_DOWNWARD 0x2
-#define ARM_TOWARDZERO 0x3
-#define ARM_RMODE_MASK (ARM_TONEAREST | ARM_UPWARD | \
- ARM_DOWNWARD | ARM_TOWARDZERO)
-#define ARM_RMODE_SHIFT 22
-
-#define ARM_INEXACT 0x1000
-
-FE_ROUND_MODE __fe_getround() {
-#ifdef __ARM_FP
- uint32_t fpscr;
- __asm__ __volatile__("vmrs %0, fpscr" : "=r" (fpscr));
- fpscr = fpscr >> ARM_RMODE_SHIFT & ARM_RMODE_MASK;
- switch (fpscr) {
- case ARM_UPWARD:
- return FE_UPWARD;
- case ARM_DOWNWARD:
- return FE_DOWNWARD;
- case ARM_TOWARDZERO:
- return FE_TOWARDZERO;
- case ARM_TONEAREST:
- default:
- return FE_TONEAREST;
- }
-#else
- return FE_TONEAREST;
-#endif
-}
-
-int __fe_raise_inexact() {
-#ifdef __ARM_FP
- uint32_t fpscr;
- __asm__ __volatile__("vmrs %0, fpscr" : "=r" (fpscr));
- __asm__ __volatile__("vmsr fpscr, %0" : : "ri" (fpscr | ARM_INEXACT));
- return 0;
-#else
- return 0;
-#endif
-}
diff --git a/compiler-rt/lib/builtins/cpu_model.c b/compiler-rt/lib/builtins/cpu_model.c
index 6213b71..b6be55a 100644
--- a/compiler-rt/lib/builtins/cpu_model.c
+++ b/compiler-rt/lib/builtins/cpu_model.c
@@ -579,24 +579,14 @@
#define CONSTRUCTOR_ATTRIBUTE
#endif
-#ifndef _WIN32
-__attribute__((visibility("hidden")))
-#endif
int __cpu_indicator_init(void) CONSTRUCTOR_ATTRIBUTE;
-#ifndef _WIN32
-__attribute__((visibility("hidden")))
-#endif
struct __processor_model {
unsigned int __cpu_vendor;
unsigned int __cpu_type;
unsigned int __cpu_subtype;
unsigned int __cpu_features[1];
} __cpu_model = {0, 0, 0, {0}};
-
-#ifndef _WIN32
-__attribute__((visibility("hidden")))
-#endif
unsigned int __cpu_features2;
/* A constructor function that is sets __cpu_model and __cpu_features2 with
diff --git a/compiler-rt/lib/builtins/fp_add_impl.inc b/compiler-rt/lib/builtins/fp_add_impl.inc
index 828efea..f9a32ce 100644
--- a/compiler-rt/lib/builtins/fp_add_impl.inc
+++ b/compiler-rt/lib/builtins/fp_add_impl.inc
@@ -12,7 +12,6 @@
//===----------------------------------------------------------------------===//
#include "fp_lib.h"
-#include "fp_mode.h"
static __inline fp_t __addXf3__(fp_t a, fp_t b) {
rep_t aRep = toRep(a);
@@ -138,21 +137,7 @@
// Final rounding. The result may overflow to infinity, but that is the
// correct result in that case.
- switch (__fe_getround()){
- case FE_TONEAREST:
- if (roundGuardSticky > 0x4) result++;
- if (roundGuardSticky == 0x4) result += result & 1;
- break;
- case FE_DOWNWARD:
- if (resultSign && roundGuardSticky) result++;
- break;
- case FE_UPWARD:
- if (!resultSign && roundGuardSticky) result++;
- break;
- case FE_TOWARDZERO:
- break;
- }
- if (roundGuardSticky)
- __fe_raise_inexact();
+ if (roundGuardSticky > 0x4) result++;
+ if (roundGuardSticky == 0x4) result += result & 1;
return fromRep(result);
}
diff --git a/compiler-rt/lib/builtins/fp_mode.c b/compiler-rt/lib/builtins/fp_mode.c
deleted file mode 100644
index 9b82830..0000000
--- a/compiler-rt/lib/builtins/fp_mode.c
+++ /dev/null
@@ -1,24 +0,0 @@
-//===----- lib/fp_mode.c - Floaing-point environment mode utilities --C -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// This file provides a default implementaion of fp_mode.h for architectures
-// that does not support or does not have an implementation of floating point
-// environment mode.
-//
-//===----------------------------------------------------------------------===//
-
-#include "fp_mode.h"
-
-// IEEE-754 default rounding (to nearest, ties to even).
-FE_ROUND_MODE __fe_getround() {
- return FE_TONEAREST;
-}
-
-int __fe_raise_inexact() {
- return 0;
-}
diff --git a/compiler-rt/lib/builtins/fp_mode.h b/compiler-rt/lib/builtins/fp_mode.h
deleted file mode 100644
index 51bec04..0000000
--- a/compiler-rt/lib/builtins/fp_mode.h
+++ /dev/null
@@ -1,29 +0,0 @@
-//===----- lib/fp_mode.h - Floaing-point environment mode utilities --C -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// This file is not part of the interface of this library.
-//
-// This file defines an interface for accessing hardware floating point
-// environment mode.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef FP_MODE
-#define FP_MODE
-
-typedef enum {
- FE_TONEAREST,
- FE_DOWNWARD,
- FE_UPWARD,
- FE_TOWARDZERO
-} FE_ROUND_MODE;
-
-FE_ROUND_MODE __fe_getround();
-int __fe_raise_inexact();
-
-#endif // FP_MODE_H
diff --git a/compiler-rt/lib/builtins/subdf3.c b/compiler-rt/lib/builtins/subdf3.c
index 292aec6..013c60e 100644
--- a/compiler-rt/lib/builtins/subdf3.c
+++ b/compiler-rt/lib/builtins/subdf3.c
@@ -6,7 +6,8 @@
//
//===----------------------------------------------------------------------===//
//
-// This file implements double-precision soft-float subtraction.
+// This file implements double-precision soft-float subtraction with the
+// IEEE-754 default rounding (to nearest, ties to even).
//
//===----------------------------------------------------------------------===//
diff --git a/compiler-rt/lib/builtins/subsf3.c b/compiler-rt/lib/builtins/subsf3.c
index 760db36..90b0e11 100644
--- a/compiler-rt/lib/builtins/subsf3.c
+++ b/compiler-rt/lib/builtins/subsf3.c
@@ -6,7 +6,8 @@
//
//===----------------------------------------------------------------------===//
//
-// This file implements single-precision soft-float subtraction.
+// This file implements single-precision soft-float subtraction with the
+// IEEE-754 default rounding (to nearest, ties to even).
//
//===----------------------------------------------------------------------===//
diff --git a/compiler-rt/lib/builtins/subtf3.c b/compiler-rt/lib/builtins/subtf3.c
index f1b3e29..871cf86 100644
--- a/compiler-rt/lib/builtins/subtf3.c
+++ b/compiler-rt/lib/builtins/subtf3.c
@@ -6,7 +6,8 @@
//
//===----------------------------------------------------------------------===//
//
-// This file implements quad-precision soft-float subtraction.
+// This file implements quad-precision soft-float subtraction with the
+// IEEE-754 default rounding (to nearest, ties to even).
//
//===----------------------------------------------------------------------===//
diff --git a/compiler-rt/lib/hwasan/CMakeLists.txt b/compiler-rt/lib/hwasan/CMakeLists.txt
index cc00ed2..20ab94d 100644
--- a/compiler-rt/lib/hwasan/CMakeLists.txt
+++ b/compiler-rt/lib/hwasan/CMakeLists.txt
@@ -2,23 +2,20 @@
# Runtime library sources and build flags.
set(HWASAN_RTL_SOURCES
- hwasan.cpp
- hwasan_allocator.cpp
- hwasan_dynamic_shadow.cpp
- hwasan_interceptors.cpp
- hwasan_interceptors_vfork.S
- hwasan_linux.cpp
- hwasan_memintrinsics.cpp
- hwasan_poisoning.cpp
- hwasan_report.cpp
- hwasan_tag_mismatch_aarch64.S
- hwasan_thread.cpp
- hwasan_thread_list.cpp
+ hwasan.cc
+ hwasan_allocator.cc
+ hwasan_dynamic_shadow.cc
+ hwasan_interceptors.cc
+ hwasan_linux.cc
+ hwasan_memintrinsics.cc
+ hwasan_poisoning.cc
+ hwasan_report.cc
+ hwasan_thread.cc
+ hwasan_thread_list.cc
)
set(HWASAN_RTL_CXX_SOURCES
- hwasan_new_delete.cpp
- )
+ hwasan_new_delete.cc)
set(HWASAN_RTL_HEADERS
hwasan.h
@@ -27,7 +24,6 @@
hwasan_flags.h
hwasan_flags.inc
hwasan_interface_internal.h
- hwasan_malloc_bisect.h
hwasan_mapping.h
hwasan_poisoning.h
hwasan_report.h
diff --git a/compiler-rt/lib/hwasan/hwasan.cpp b/compiler-rt/lib/hwasan/hwasan.cc
similarity index 94%
rename from compiler-rt/lib/hwasan/hwasan.cpp
rename to compiler-rt/lib/hwasan/hwasan.cc
index 3b3d254..9c83f73 100644
--- a/compiler-rt/lib/hwasan/hwasan.cpp
+++ b/compiler-rt/lib/hwasan/hwasan.cc
@@ -1,4 +1,4 @@
-//===-- hwasan.cpp --------------------------------------------------------===//
+//===-- hwasan.cc ---------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -477,28 +477,6 @@
TagMemory(sp, dst - sp, 0);
}
-void __hwasan_handle_vfork(const void *sp_dst) {
- uptr sp = (uptr)sp_dst;
- Thread *t = GetCurrentThread();
- CHECK(t);
- uptr top = t->stack_top();
- uptr bottom = t->stack_bottom();
- if (top == 0 || bottom == 0 || sp < bottom || sp >= top) {
- Report(
- "WARNING: HWASan is ignoring requested __hwasan_handle_vfork: "
- "stack top: %zx; current %zx; bottom: %zx \n"
- "False positive error reports may follow\n",
- top, sp, bottom);
- return;
- }
- TagMemory(bottom, sp - bottom, 0);
-}
-
-extern "C" void *__hwasan_extra_spill_area() {
- Thread *t = GetCurrentThread();
- return &t->vfork_spill();
-}
-
void __hwasan_print_memory_usage() {
InternalScopedString s(kMemoryUsageBufferSize);
HwasanFormatMemoryUsage(s);
diff --git a/compiler-rt/lib/hwasan/hwasan_allocator.cpp b/compiler-rt/lib/hwasan/hwasan_allocator.cc
similarity index 95%
rename from compiler-rt/lib/hwasan/hwasan_allocator.cpp
rename to compiler-rt/lib/hwasan/hwasan_allocator.cc
index 19f1baf..dc56bd7 100644
--- a/compiler-rt/lib/hwasan/hwasan_allocator.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_allocator.cc
@@ -1,4 +1,4 @@
-//===-- hwasan_allocator.cpp ------------------------ ---------------------===//
+//===-- hwasan_allocator.cc ------------------------- ---------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -17,7 +17,6 @@
#include "hwasan.h"
#include "hwasan_allocator.h"
#include "hwasan_mapping.h"
-#include "hwasan_malloc_bisect.h"
#include "hwasan_thread.h"
#include "hwasan_report.h"
@@ -177,16 +176,10 @@
size - orig_size);
void *user_ptr = allocated;
- // Tagging can only be skipped when both tag_in_malloc and tag_in_free are
- // false. When tag_in_malloc = false and tag_in_free = true malloc needs to
- // retag to 0.
- if ((flags()->tag_in_malloc || flags()->tag_in_free) &&
- atomic_load_relaxed(&hwasan_allocator_tagging_enabled)) {
- tag_t tag = flags()->tag_in_malloc && malloc_bisect(stack, orig_size)
- ? (t ? t->GenerateRandomTag() : kFallbackAllocTag)
- : 0;
- user_ptr = (void *)TagMemoryAligned((uptr)user_ptr, size, tag);
- }
+ if (flags()->tag_in_malloc &&
+ atomic_load_relaxed(&hwasan_allocator_tagging_enabled))
+ user_ptr = (void *)TagMemoryAligned(
+ (uptr)user_ptr, size, t ? t->GenerateRandomTag() : kFallbackAllocTag);
if ((orig_size % kShadowAlignment) && (alignment <= kShadowAlignment) &&
right_align_mode) {
@@ -248,7 +241,7 @@
Min(TaggedSize(orig_size), (uptr)flags()->max_free_fill_size);
internal_memset(aligned_ptr, flags()->free_fill_byte, fill_size);
}
- if (flags()->tag_in_free && malloc_bisect(stack, 0) &&
+ if (flags()->tag_in_free &&
atomic_load_relaxed(&hwasan_allocator_tagging_enabled))
TagMemoryAligned(reinterpret_cast<uptr>(aligned_ptr), TaggedSize(orig_size),
t ? t->GenerateRandomTag() : kFallbackFreeTag);
diff --git a/compiler-rt/lib/hwasan/hwasan_dynamic_shadow.cpp b/compiler-rt/lib/hwasan/hwasan_dynamic_shadow.cc
similarity index 98%
rename from compiler-rt/lib/hwasan/hwasan_dynamic_shadow.cpp
rename to compiler-rt/lib/hwasan/hwasan_dynamic_shadow.cc
index a04751f..e2dbe05 100644
--- a/compiler-rt/lib/hwasan/hwasan_dynamic_shadow.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_dynamic_shadow.cc
@@ -1,4 +1,4 @@
-//===-- hwasan_dynamic_shadow.cpp -------------------------------*- C++ -*-===//
+//===-- hwasan_dynamic_shadow.cc --------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/compiler-rt/lib/hwasan/hwasan_flags.inc b/compiler-rt/lib/hwasan/hwasan_flags.inc
index 01fdad8..f0cf151 100644
--- a/compiler-rt/lib/hwasan/hwasan_flags.inc
+++ b/compiler-rt/lib/hwasan/hwasan_flags.inc
@@ -85,16 +85,3 @@
"The number of stack frames remembered per thread. "
"Affects the quality of stack-related reports, but not the ability "
"to find bugs.")
-
-// Malloc / free bisection. Only tag malloc and free calls when a hash of
-// allocation size and stack trace is between malloc_bisect_left and
-// malloc_bisect_right (both inclusive). [0, 0] range is special and disables
-// bisection (i.e. everything is tagged). Once the range is narrowed down
-// enough, use malloc_bisect_dump to see interesting allocations.
-HWASAN_FLAG(uptr, malloc_bisect_left, 0,
- "Left bound of malloc bisection, inclusive.")
-HWASAN_FLAG(uptr, malloc_bisect_right, 0,
- "Right bound of malloc bisection, inclusive.")
-HWASAN_FLAG(bool, malloc_bisect_dump, false,
- "Print all allocations within [malloc_bisect_left, "
- "malloc_bisect_right] range ")
diff --git a/compiler-rt/lib/hwasan/hwasan_interceptors.cpp b/compiler-rt/lib/hwasan/hwasan_interceptors.cc
similarity index 96%
rename from compiler-rt/lib/hwasan/hwasan_interceptors.cpp
rename to compiler-rt/lib/hwasan/hwasan_interceptors.cc
index 3263097..baecb1e 100644
--- a/compiler-rt/lib/hwasan/hwasan_interceptors.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_interceptors.cc
@@ -1,4 +1,4 @@
-//===-- hwasan_interceptors.cpp -------------------------------------------===//
+//===-- hwasan_interceptors.cc --------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -227,11 +227,6 @@
}
#endif
-#if HWASAN_WITH_INTERCEPTORS
-DEFINE_REAL(int, vfork);
-DECLARE_EXTERN_INTERCEPTOR_AND_WRAPPER(int, vfork);
-#endif
-
static void BeforeFork() {
StackDepotLockAll();
}
@@ -271,12 +266,9 @@
INTERCEPT_FUNCTION(fork);
#if HWASAN_WITH_INTERCEPTORS
-#if defined(__linux__)
- INTERCEPT_FUNCTION(vfork);
-#endif // __linux__
#if !defined(__aarch64__)
INTERCEPT_FUNCTION(pthread_create);
-#endif // __aarch64__
+#endif
INTERCEPT_FUNCTION(realloc);
INTERCEPT_FUNCTION(free);
#endif
diff --git a/compiler-rt/lib/hwasan/hwasan_interceptors_vfork.S b/compiler-rt/lib/hwasan/hwasan_interceptors_vfork.S
deleted file mode 100644
index 13d0829..0000000
--- a/compiler-rt/lib/hwasan/hwasan_interceptors_vfork.S
+++ /dev/null
@@ -1,10 +0,0 @@
-#include "sanitizer_common/sanitizer_asm.h"
-
-#if defined(__linux__) && HWASAN_WITH_INTERCEPTORS
-#define COMMON_INTERCEPTOR_SPILL_AREA __hwasan_extra_spill_area
-#define COMMON_INTERCEPTOR_HANDLE_VFORK __hwasan_handle_vfork
-#include "sanitizer_common/sanitizer_common_interceptors_vfork_aarch64.inc.S"
-#include "sanitizer_common/sanitizer_common_interceptors_vfork_x86_64.inc.S"
-#endif
-
-NO_EXEC_STACK_DIRECTIVE
diff --git a/compiler-rt/lib/hwasan/hwasan_interface_internal.h b/compiler-rt/lib/hwasan/hwasan_interface_internal.h
index 3e5ac90..c2ae666 100644
--- a/compiler-rt/lib/hwasan/hwasan_interface_internal.h
+++ b/compiler-rt/lib/hwasan/hwasan_interface_internal.h
@@ -100,9 +100,6 @@
uptr __hwasan_tag_pointer(uptr p, u8 tag);
SANITIZER_INTERFACE_ATTRIBUTE
-void __hwasan_tag_mismatch(uptr addr, u8 ts);
-
-SANITIZER_INTERFACE_ATTRIBUTE
u8 __hwasan_generate_tag();
// Returns the offset of the first tag mismatch or -1 if the whole range is
@@ -120,9 +117,6 @@
void __hwasan_handle_longjmp(const void *sp_dst);
SANITIZER_INTERFACE_ATTRIBUTE
-void __hwasan_handle_vfork(const void *sp_dst);
-
-SANITIZER_INTERFACE_ATTRIBUTE
u16 __sanitizer_unaligned_load16(const uu16 *p);
SANITIZER_INTERFACE_ATTRIBUTE
diff --git a/compiler-rt/lib/hwasan/hwasan_linux.cpp b/compiler-rt/lib/hwasan/hwasan_linux.cc
similarity index 92%
rename from compiler-rt/lib/hwasan/hwasan_linux.cpp
rename to compiler-rt/lib/hwasan/hwasan_linux.cc
index 6a071d8..c922c11 100644
--- a/compiler-rt/lib/hwasan/hwasan_linux.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_linux.cc
@@ -1,4 +1,4 @@
-//===-- hwasan_linux.cpp ----------------------------------------*- C++ -*-===//
+//===-- hwasan_linux.cc -----------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -374,26 +374,15 @@
}
static void HandleTagMismatch(AccessInfo ai, uptr pc, uptr frame,
- ucontext_t *uc, uptr *registers_frame = nullptr) {
+ ucontext_t *uc) {
InternalMmapVector<BufferedStackTrace> stack_buffer(1);
BufferedStackTrace *stack = stack_buffer.data();
stack->Reset();
GetStackTrace(stack, kStackTraceMax, pc, frame, uc,
common_flags()->fast_unwind_on_fatal);
- // The second stack frame contains the failure __hwasan_check function, as
- // we have a stack frame for the registers saved in __hwasan_tag_mismatch that
- // we wish to ignore. This (currently) only occurs on AArch64, as x64
- // implementations use SIGTRAP to implement the failure, and thus do not go
- // through the stack saver.
- if (registers_frame && stack->trace && stack->size > 0) {
- stack->trace++;
- stack->size--;
- }
-
bool fatal = flags()->halt_on_error || !ai.recover;
- ReportTagMismatch(stack, ai.addr, ai.size, ai.is_store, fatal,
- registers_frame);
+ ReportTagMismatch(stack, ai.addr, ai.size, ai.is_store, fatal);
}
static bool HwasanOnSIGTRAP(int signo, siginfo_t *info, ucontext_t *uc) {
@@ -413,10 +402,8 @@
return true;
}
-// Entry point stub for interoperability between __hwasan_tag_mismatch (ASM) and
-// the rest of the mismatch handling code (C++).
-extern "C" void __hwasan_tag_mismatch_stub(uptr addr, uptr access_info,
- uptr *registers_frame) {
+extern "C" SANITIZER_INTERFACE_ATTRIBUTE void __hwasan_tag_mismatch(
+ uptr addr, uptr access_info) {
AccessInfo ai;
ai.is_store = access_info & 0x10;
ai.recover = false;
@@ -424,7 +411,7 @@
ai.size = 1 << (access_info & 0xf);
HandleTagMismatch(ai, (uptr)__builtin_return_address(0),
- (uptr)__builtin_frame_address(0), nullptr, registers_frame);
+ (uptr)__builtin_frame_address(0), nullptr);
__builtin_unreachable();
}
diff --git a/compiler-rt/lib/hwasan/hwasan_malloc_bisect.h b/compiler-rt/lib/hwasan/hwasan_malloc_bisect.h
deleted file mode 100644
index eaf124a..0000000
--- a/compiler-rt/lib/hwasan/hwasan_malloc_bisect.h
+++ /dev/null
@@ -1,50 +0,0 @@
-//===-- hwasan_malloc_bisect.h ----------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// This file is a part of HWAddressSanitizer.
-//
-//===----------------------------------------------------------------------===//
-
-#include "sanitizer_common/sanitizer_hash.h"
-#include "hwasan.h"
-
-namespace __hwasan {
-
-static u32 malloc_hash(StackTrace *stack, uptr orig_size) {
- uptr len = Min(stack->size, (unsigned)7);
- MurMur2HashBuilder H(len);
- H.add(orig_size);
- // Start with frame #1 to skip __sanitizer_malloc frame, which is
- // (a) almost always the same (well, could be operator new or new[])
- // (b) can change hashes when compiler-rt is rebuilt, invalidating previous
- // bisection results.
- // Because of ASLR, use only offset inside the page.
- for (uptr i = 1; i < len; ++i) H.add(((u32)stack->trace[i]) & 0xFFF);
- return H.get();
-}
-
-static INLINE bool malloc_bisect(StackTrace *stack, uptr orig_size) {
- uptr left = flags()->malloc_bisect_left;
- uptr right = flags()->malloc_bisect_right;
- if (LIKELY(left == 0 && right == 0))
- return true;
- if (!stack)
- return true;
- // Allow malloc_bisect_right > (u32)(-1) to avoid spelling the latter in
- // decimal.
- uptr h = (uptr)malloc_hash(stack, orig_size);
- if (h < left || h > right)
- return false;
- if (flags()->malloc_bisect_dump) {
- Printf("[alloc] %u %zu\n", h, orig_size);
- stack->Print();
- }
- return true;
-}
-
-} // namespace __hwasan
diff --git a/compiler-rt/lib/hwasan/hwasan_memintrinsics.cpp b/compiler-rt/lib/hwasan/hwasan_memintrinsics.cc
similarity index 95%
rename from compiler-rt/lib/hwasan/hwasan_memintrinsics.cpp
rename to compiler-rt/lib/hwasan/hwasan_memintrinsics.cc
index e82d77a..1bfc6c3 100644
--- a/compiler-rt/lib/hwasan/hwasan_memintrinsics.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_memintrinsics.cc
@@ -1,4 +1,4 @@
-//===-- hwasan_memintrinsics.cpp --------------------------------*- C++ -*-===//
+//===-- hwasan_memintrinsics.cc ---------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/compiler-rt/lib/hwasan/hwasan_new_delete.cpp b/compiler-rt/lib/hwasan/hwasan_new_delete.cc
similarity index 96%
rename from compiler-rt/lib/hwasan/hwasan_new_delete.cpp
rename to compiler-rt/lib/hwasan/hwasan_new_delete.cc
index 438a369..9ecc350 100644
--- a/compiler-rt/lib/hwasan/hwasan_new_delete.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_new_delete.cc
@@ -1,4 +1,4 @@
-//===-- hwasan_new_delete.cpp ---------------------------------------------===//
+//===-- hwasan_new_delete.cc ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/compiler-rt/lib/hwasan/hwasan_poisoning.cpp b/compiler-rt/lib/hwasan/hwasan_poisoning.cc
similarity index 96%
rename from compiler-rt/lib/hwasan/hwasan_poisoning.cpp
rename to compiler-rt/lib/hwasan/hwasan_poisoning.cc
index 2a08164..9404c52 100644
--- a/compiler-rt/lib/hwasan/hwasan_poisoning.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_poisoning.cc
@@ -1,4 +1,4 @@
-//===-- hwasan_poisoning.cpp ------------------------------------*- C++ -*-===//
+//===-- hwasan_poisoning.cc -------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/compiler-rt/lib/hwasan/hwasan_report.cpp b/compiler-rt/lib/hwasan/hwasan_report.cc
similarity index 89%
rename from compiler-rt/lib/hwasan/hwasan_report.cpp
rename to compiler-rt/lib/hwasan/hwasan_report.cc
index fa2fff7..aad5e40 100644
--- a/compiler-rt/lib/hwasan/hwasan_report.cpp
+++ b/compiler-rt/lib/hwasan/hwasan_report.cc
@@ -1,4 +1,4 @@
-//===-- hwasan_report.cpp -------------------------------------------------===//
+//===-- hwasan_report.cc --------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -14,7 +14,6 @@
#include "hwasan.h"
#include "hwasan_allocator.h"
#include "hwasan_mapping.h"
-#include "hwasan_report.h"
#include "hwasan_thread.h"
#include "hwasan_thread_list.h"
#include "sanitizer_common/sanitizer_allocator_internal.h"
@@ -253,8 +252,8 @@
uptr pc_mask = (1ULL << 48) - 1;
uptr pc = record & pc_mask;
if (SymbolizedStack *frame = Symbolizer::GetOrInit()->SymbolizePC(pc)) {
- frame_desc.append(" sp: 0x%zx ", sp);
- RenderFrame(&frame_desc, "#%n %p %F %L\n", 0, frame->info,
+ frame_desc.append(" sp: 0x%zx pc: %p ", sp, pc);
+ RenderFrame(&frame_desc, "in %f %s:%l\n", 0, frame->info,
common_flags()->symbolize_vs_style,
common_flags()->strip_path_prefix);
frame->ClearAll();
@@ -390,7 +389,7 @@
}
void ReportTagMismatch(StackTrace *stack, uptr tagged_addr, uptr access_size,
- bool is_store, bool fatal, uptr *registers_frame) {
+ bool is_store, bool fatal) {
ScopedReport R(fatal);
SavedStackAllocations current_stack_allocations(
GetCurrentThread()->stack_allocations());
@@ -431,37 +430,7 @@
PrintTagsAroundAddr(tag_ptr);
- if (registers_frame)
- ReportRegisters(registers_frame, pc);
-
ReportErrorSummary(bug_type, stack);
}
-// See the frame breakdown defined in __hwasan_tag_mismatch (from
-// hwasan_tag_mismatch_aarch64.S).
-void ReportRegisters(uptr *frame, uptr pc) {
- Printf("Registers where the failure occurred (pc %p):\n", pc);
-
- // We explicitly print a single line (4 registers/line) each iteration to
- // reduce the amount of logcat error messages printed. Each Printf() will
- // result in a new logcat line, irrespective of whether a newline is present,
- // and so we wish to reduce the number of Printf() calls we have to make.
- Printf(" x0 %016llx x1 %016llx x2 %016llx x3 %016llx\n",
- frame[0], frame[1], frame[2], frame[3]);
- Printf(" x4 %016llx x5 %016llx x6 %016llx x7 %016llx\n",
- frame[4], frame[5], frame[6], frame[7]);
- Printf(" x8 %016llx x9 %016llx x10 %016llx x11 %016llx\n",
- frame[8], frame[9], frame[10], frame[11]);
- Printf(" x12 %016llx x13 %016llx x14 %016llx x15 %016llx\n",
- frame[12], frame[13], frame[14], frame[15]);
- Printf(" x16 %016llx x17 %016llx x18 %016llx x19 %016llx\n",
- frame[16], frame[17], frame[18], frame[19]);
- Printf(" x20 %016llx x21 %016llx x22 %016llx x23 %016llx\n",
- frame[20], frame[21], frame[22], frame[23]);
- Printf(" x24 %016llx x25 %016llx x26 %016llx x27 %016llx\n",
- frame[24], frame[25], frame[26], frame[27]);
- Printf(" x28 %016llx x29 %016llx x30 %016llx\n",
- frame[28], frame[29], frame[30]);
-}
-
} // namespace __hwasan
diff --git a/compiler-rt/lib/hwasan/hwasan_report.h b/compiler-rt/lib/hwasan/hwasan_report.h
index f03eb7a..6fc53ec 100644
--- a/compiler-rt/lib/hwasan/hwasan_report.h
+++ b/compiler-rt/lib/hwasan/hwasan_report.h
@@ -22,11 +22,11 @@
void ReportStats();
void ReportTagMismatch(StackTrace *stack, uptr addr, uptr access_size,
- bool is_store, bool fatal, uptr *registers_frame);
+ bool is_store, bool fatal);
void ReportInvalidFree(StackTrace *stack, uptr addr);
void ReportTailOverwritten(StackTrace *stack, uptr addr, uptr orig_size,
uptr tail_size, const u8 *expected);
-void ReportRegisters(uptr *registers_frame, uptr pc);
+
void ReportAtExitStatistics();
diff --git a/compiler-rt/lib/hwasan/hwasan_tag_mismatch_aarch64.S b/compiler-rt/lib/hwasan/hwasan_tag_mismatch_aarch64.S
deleted file mode 100644
index 8d508f3..0000000
--- a/compiler-rt/lib/hwasan/hwasan_tag_mismatch_aarch64.S
+++ /dev/null
@@ -1,108 +0,0 @@
-#include "sanitizer_common/sanitizer_asm.h"
-
-// The content of this file is AArch64-only:
-#if defined(__aarch64__)
-
-// The responsibility of the HWASan entry point in compiler-rt is to primarily
-// readjust the stack from the callee and save the current register values to
-// the stack.
-// This entry point function should be called from a __hwasan_check_* symbol.
-// These are generated during a lowering pass in the backend, and are found in
-// AArch64AsmPrinter::EmitHwasanMemaccessSymbols(). Please look there for
-// further information.
-// The __hwasan_check_* caller of this function should have expanded the stack
-// and saved the previous values of x0, x1, x29, and x30. This function will
-// "consume" these saved values and treats it as part of its own stack frame.
-// In this sense, the __hwasan_check_* callee and this function "share" a stack
-// frame. This allows us to omit having unwinding information (.cfi_*) present
-// in every __hwasan_check_* function, therefore reducing binary size. This is
-// particularly important as hwasan_check_* instances are duplicated in every
-// translation unit where HWASan is enabled.
-// This function calls HwasanTagMismatch to step back into the C++ code that
-// completes the stack unwinding and error printing. This function is is not
-// permitted to return.
-
-
-// Frame from __hwasan_check_:
-// | ... |
-// | ... |
-// | Previous stack frames... |
-// +=================================+
-// | Unused 8-bytes for maintaining |
-// | 16-byte SP alignment. |
-// +---------------------------------+
-// | Return address (x30) for caller |
-// | of __hwasan_check_*. |
-// +---------------------------------+
-// | Frame address (x29) for caller |
-// | of __hwasan_check_* |
-// +---------------------------------+ <-- [SP + 232]
-// | ... |
-// | |
-// | Stack frame space for x2 - x28. |
-// | |
-// | ... |
-// +---------------------------------+ <-- [SP + 16]
-// | |
-// | Saved x1, as __hwasan_check_* |
-// | clobbers it. |
-// +---------------------------------+
-// | Saved x0, likewise above. |
-// +---------------------------------+ <-- [x30 / SP]
-
-// This function takes two arguments:
-// * x0: The address of read/write instruction that caused HWASan check fail.
-// * x1: The tag size.
-
-.section .text
-.file "hwasan_tag_mismatch_aarch64.S"
-.global __hwasan_tag_mismatch
-.type __hwasan_tag_mismatch, %function
-__hwasan_tag_mismatch:
- CFI_STARTPROC
-
- // Set the CFA to be the return address for caller of __hwasan_check_*. Note
- // that we do not emit CFI predicates to describe the contents of this stack
- // frame, as this proxy entry point should never be debugged. The contents
- // are static and are handled by the unwinder after calling
- // __hwasan_tag_mismatch. The frame pointer is already correctly setup
- // by __hwasan_check_*.
- add x29, sp, #232
- CFI_DEF_CFA(w29, 24)
- CFI_OFFSET(w30, -16)
- CFI_OFFSET(w29, -24)
-
- // Save the rest of the registers into the preallocated space left by
- // __hwasan_check.
- str x28, [sp, #224]
- stp x26, x27, [sp, #208]
- stp x24, x25, [sp, #192]
- stp x22, x23, [sp, #176]
- stp x20, x21, [sp, #160]
- stp x18, x19, [sp, #144]
- stp x16, x17, [sp, #128]
- stp x14, x15, [sp, #112]
- stp x12, x13, [sp, #96]
- stp x10, x11, [sp, #80]
- stp x8, x9, [sp, #64]
- stp x6, x7, [sp, #48]
- stp x4, x5, [sp, #32]
- stp x2, x3, [sp, #16]
-
- // Pass the address of the frame to __hwasan_tag_mismatch_stub, so that it can
- // extract the saved registers from this frame without having to worry about
- // finding this frame.
- mov x2, sp
-
- bl __hwasan_tag_mismatch_stub
- CFI_ENDPROC
-
-.Lfunc_end0:
- .size __hwasan_tag_mismatch, .Lfunc_end0-__hwasan_tag_mismatch
-
-.addrsig
-
-#endif // defined(__aarch64__)
-
-// We do not need executable stack.
-NO_EXEC_STACK_DIRECTIVE
diff --git a/compiler-rt/lib/hwasan/hwasan_thread.cpp b/compiler-rt/lib/hwasan/hwasan_thread.cc
similarity index 100%
rename from compiler-rt/lib/hwasan/hwasan_thread.cpp
rename to compiler-rt/lib/hwasan/hwasan_thread.cc
diff --git a/compiler-rt/lib/hwasan/hwasan_thread.h b/compiler-rt/lib/hwasan/hwasan_thread.h
index 6fa592b..9c45ade 100644
--- a/compiler-rt/lib/hwasan/hwasan_thread.h
+++ b/compiler-rt/lib/hwasan/hwasan_thread.h
@@ -67,14 +67,11 @@
Print("Thread: ");
}
- uptr &vfork_spill() { return vfork_spill_; }
-
private:
// NOTE: There is no Thread constructor. It is allocated
// via mmap() and *must* be valid in zero-initialized state.
void ClearShadowForThreadStackAndTLS();
void Print(const char *prefix);
- uptr vfork_spill_;
uptr stack_top_;
uptr stack_bottom_;
uptr tls_begin_;
diff --git a/compiler-rt/lib/hwasan/hwasan_thread_list.cpp b/compiler-rt/lib/hwasan/hwasan_thread_list.cc
similarity index 100%
rename from compiler-rt/lib/hwasan/hwasan_thread_list.cpp
rename to compiler-rt/lib/hwasan/hwasan_thread_list.cc
diff --git a/compiler-rt/lib/interception/interception.h b/compiler-rt/lib/interception/interception.h
index dacfa5e..8048015 100644
--- a/compiler-rt/lib/interception/interception.h
+++ b/compiler-rt/lib/interception/interception.h
@@ -185,17 +185,11 @@
#endif // SANITIZER_MAC
#if !SANITIZER_FUCHSIA && !SANITIZER_RTEMS
-# define DECLARE_REAL_AND_INTERCEPTOR(ret_type, func, ...) \
+#define DECLARE_REAL_AND_INTERCEPTOR(ret_type, func, ...) \
DECLARE_REAL(ret_type, func, __VA_ARGS__) \
extern "C" ret_type WRAP(func)(__VA_ARGS__);
-// Declare an interceptor and its wrapper defined in a different translation
-// unit (ex. asm).
-# define DECLARE_EXTERN_INTERCEPTOR_AND_WRAPPER(ret_type, func, ...) \
- extern "C" ret_type WRAP(func)(__VA_ARGS__); \
- extern "C" ret_type func(__VA_ARGS__);
#else
-# define DECLARE_REAL_AND_INTERCEPTOR(ret_type, func, ...)
-# define DECLARE_EXTERN_INTERCEPTOR_AND_WRAPPER(ret_type, func, ...)
+#define DECLARE_REAL_AND_INTERCEPTOR(ret_type, func, ...)
#endif
// Generally, you don't need to use DEFINE_REAL by itself, as INTERCEPTOR
diff --git a/compiler-rt/lib/sanitizer_common/CMakeLists.txt b/compiler-rt/lib/sanitizer_common/CMakeLists.txt
index d378045..470ef20 100644
--- a/compiler-rt/lib/sanitizer_common/CMakeLists.txt
+++ b/compiler-rt/lib/sanitizer_common/CMakeLists.txt
@@ -126,7 +126,6 @@
sanitizer_common_interceptors.inc
sanitizer_common_interceptors_format.inc
sanitizer_common_interceptors_ioctl.inc
- sanitizer_common_interceptors_vfork_aarch64.inc.S
sanitizer_common_interface.inc
sanitizer_common_interface_posix.inc
sanitizer_common_syscalls.inc
@@ -143,7 +142,6 @@
sanitizer_freebsd.h
sanitizer_fuchsia.h
sanitizer_getauxval.h
- sanitizer_hash.h
sanitizer_interceptors_ioctl_netbsd.inc
sanitizer_interface_internal.h
sanitizer_internal_defs.h
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_asm.h b/compiler-rt/lib/sanitizer_common/sanitizer_asm.h
index 184d118..5aa36d1 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_asm.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_asm.h
@@ -44,23 +44,14 @@
#if !defined(__APPLE__)
# define ASM_HIDDEN(symbol) .hidden symbol
-# define ASM_TYPE_FUNCTION(symbol) .type symbol, %function
+# define ASM_TYPE_FUNCTION(symbol) .type symbol, @function
# define ASM_SIZE(symbol) .size symbol, .-symbol
# define ASM_SYMBOL(symbol) symbol
# define ASM_SYMBOL_INTERCEPTOR(symbol) symbol
-# define ASM_WRAPPER_NAME(symbol) __interceptor_##symbol
#else
# define ASM_HIDDEN(symbol)
# define ASM_TYPE_FUNCTION(symbol)
# define ASM_SIZE(symbol)
# define ASM_SYMBOL(symbol) _##symbol
# define ASM_SYMBOL_INTERCEPTOR(symbol) _wrap_##symbol
-# define ASM_WRAPPER_NAME(symbol) __interceptor_##symbol
-#endif
-
-#if defined(__ELF__) && (defined(__GNU__) || defined(__FreeBSD__) || \
- defined(__Fuchsia__) || defined(__linux__))
-#define NO_EXEC_STACK_DIRECTIVE .section .note.GNU-stack,"",%progbits // NOLINT
-#else
-#define NO_EXEC_STACK_DIRECTIVE
#endif
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_aarch64.inc.S b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_aarch64.inc.S
deleted file mode 100644
index 20f42f1..0000000
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_aarch64.inc.S
+++ /dev/null
@@ -1,43 +0,0 @@
-#if defined(__aarch64__) && defined(__linux__)
-
-#include "sanitizer_common/sanitizer_asm.h"
-
-ASM_HIDDEN(COMMON_INTERCEPTOR_SPILL_AREA)
-
-.comm _ZN14__interception10real_vforkE,8,8
-.globl ASM_WRAPPER_NAME(vfork)
-ASM_TYPE_FUNCTION(ASM_WRAPPER_NAME(vfork))
-ASM_WRAPPER_NAME(vfork):
- // Save x30 in the off-stack spill area.
- stp xzr, x30, [sp, #-16]!
- bl COMMON_INTERCEPTOR_SPILL_AREA
- ldp xzr, x30, [sp], 16
- str x30, [x0]
-
- // Call real vfork. This may return twice. User code that runs between the first and the second return
- // may clobber the stack frame of the interceptor; that's why it does not have a frame.
- adrp x0, _ZN14__interception10real_vforkE
- ldr x0, [x0, :lo12:_ZN14__interception10real_vforkE]
- blr x0
-
- stp x0, xzr, [sp, #-16]!
- cmp x0, #0
- b.eq .L_exit
-
- // x0 != 0 => parent process. Clear stack shadow.
- add x0, sp, #16
- bl COMMON_INTERCEPTOR_HANDLE_VFORK
-
-.L_exit:
- // Restore x30.
- bl COMMON_INTERCEPTOR_SPILL_AREA
- ldr x30, [x0]
- ldp x0, xzr, [sp], 16
-
- ret
-ASM_SIZE(vfork)
-
-.weak vfork
-.set vfork, ASM_WRAPPER_NAME(vfork)
-
-#endif
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_arm.inc.S b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_arm.inc.S
deleted file mode 100644
index 780a9d4..0000000
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_arm.inc.S
+++ /dev/null
@@ -1,49 +0,0 @@
-#if defined(__arm__) && defined(__linux__)
-
-#include "sanitizer_common/sanitizer_asm.h"
-
-ASM_HIDDEN(COMMON_INTERCEPTOR_SPILL_AREA)
-
-.comm _ZN14__interception10real_vforkE,4,4
-.globl ASM_WRAPPER_NAME(vfork)
-ASM_TYPE_FUNCTION(ASM_WRAPPER_NAME(vfork))
-ASM_WRAPPER_NAME(vfork):
- // Save LR in the off-stack spill area.
- push {r4, lr}
- bl COMMON_INTERCEPTOR_SPILL_AREA
- pop {r4, lr}
- str lr, [r0]
-
- // Call real vfork. This may return twice. User code that runs between the first and the second return
- // may clobber the stack frame of the interceptor; that's why it does not have a frame.
- ldr r0, .LCPI0_0
-.LPC0_0:
- ldr r0, [pc, r0]
- mov lr, pc
- bx r0
-
- push {r0, r4}
- cmp r0, #0
- beq .L_exit
-
- // r0 != 0 => parent process. Clear stack shadow.
- add r0, sp, #8
- bl COMMON_INTERCEPTOR_HANDLE_VFORK
-
-.L_exit:
- // Restore LR.
- bl COMMON_INTERCEPTOR_SPILL_AREA
- ldr lr, [r0]
- pop {r0, r4}
-
- mov pc, lr
-
-.LCPI0_0:
- .long _ZN14__interception10real_vforkE - (.LPC0_0+8)
-
-ASM_SIZE(vfork)
-
-.weak vfork
-.set vfork, ASM_WRAPPER_NAME(vfork)
-
-#endif
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_i386.inc.S b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_i386.inc.S
deleted file mode 100644
index ed69381..0000000
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_i386.inc.S
+++ /dev/null
@@ -1,63 +0,0 @@
-#if defined(__i386__) && defined(__linux__)
-
-#include "sanitizer_common/sanitizer_asm.h"
-
-.comm _ZN14__interception10real_vforkE,4,4
-.globl ASM_WRAPPER_NAME(vfork)
-ASM_TYPE_FUNCTION(ASM_WRAPPER_NAME(vfork))
-ASM_WRAPPER_NAME(vfork):
- // Store return address in the spill area and tear down the stack frame.
- sub $12, %esp
- call COMMON_INTERCEPTOR_SPILL_AREA
- mov 12(%esp), %ecx
- mov %ecx, (%eax)
- add $16, %esp
-
- call .L0$pb
-.L0$pb:
- pop %eax
-.Ltmp0:
- add $_GLOBAL_OFFSET_TABLE_+(.Ltmp0-.L0$pb), %eax
- call *_ZN14__interception10real_vforkE@GOTOFF(%eax)
-
- // Restore the stack frame.
- // 12(%esp) return address
- // 8(%esp) spill %ebx
- // 4(%esp) spill REAL(vfork) return value
- // (%esp) call frame (arg0) for __*_handle_vfork
- sub $16, %esp
- mov %ebx, 8(%esp)
- mov %eax, 4(%esp)
-
- // Form GOT address in %ebx.
- call .L1$pb
-.L1$pb:
- pop %ebx
-.Ltmp1:
- add $_GLOBAL_OFFSET_TABLE_+(.Ltmp1-.L1$pb), %ebx
-
- // Restore original return address.
- call COMMON_INTERCEPTOR_SPILL_AREA
- mov (%eax), %ecx
- mov %ecx, 12(%esp)
- mov 4(%esp), %eax
-
- // Call handle_vfork in the parent process (%rax != 0).
- test %eax, %eax
- je .L_exit
-
- lea 16(%esp), %ecx
- mov %ecx, (%esp)
- call COMMON_INTERCEPTOR_HANDLE_VFORK@PLT
-
-.L_exit:
- mov 4(%esp), %eax
- mov 8(%esp), %ebx
- add $12, %esp
- ret
-ASM_SIZE(vfork)
-
-.weak vfork
-.set vfork, ASM_WRAPPER_NAME(vfork)
-
-#endif
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_x86_64.inc.S b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_x86_64.inc.S
deleted file mode 100644
index 8147cdd..0000000
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors_vfork_x86_64.inc.S
+++ /dev/null
@@ -1,41 +0,0 @@
-#if defined(__x86_64__) && defined(__linux__)
-
-#include "sanitizer_common/sanitizer_asm.h"
-
-.comm _ZN14__interception10real_vforkE,8,8
-.globl ASM_WRAPPER_NAME(vfork)
-ASM_TYPE_FUNCTION(ASM_WRAPPER_NAME(vfork))
-ASM_WRAPPER_NAME(vfork):
- // Store return address in the spill area and tear down the stack frame.
- push %rcx
- call COMMON_INTERCEPTOR_SPILL_AREA
- pop %rcx
- pop %rdi
- mov %rdi, (%rax)
-
- call *_ZN14__interception10real_vforkE(%rip)
-
- // Restore return address from the spill area.
- push %rcx
- push %rax
- call COMMON_INTERCEPTOR_SPILL_AREA
- mov (%rax), %rdx
- mov %rdx, 8(%rsp)
- mov (%rsp), %rax
-
- // Call handle_vfork in the parent process (%rax != 0).
- test %rax, %rax
- je .L_exit
-
- lea 16(%rsp), %rdi
- call COMMON_INTERCEPTOR_HANDLE_VFORK@PLT
-
-.L_exit:
- pop %rax
- ret
-ASM_SIZE(vfork)
-
-.weak vfork
-.set vfork, ASM_WRAPPER_NAME(vfork)
-
-#endif
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_hash.h b/compiler-rt/lib/sanitizer_common/sanitizer_hash.h
deleted file mode 100644
index 3d97dcc..0000000
--- a/compiler-rt/lib/sanitizer_common/sanitizer_hash.h
+++ /dev/null
@@ -1,43 +0,0 @@
-//===-- sanitizer_common.h --------------------------------------*- C++ -*-===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-//
-// This file implements a simple hash function.
-//===----------------------------------------------------------------------===//
-
-#ifndef SANITIZER_HASH_H
-#define SANITIZER_HASH_H
-
-#include "sanitizer_internal_defs.h"
-
-namespace __sanitizer {
-class MurMur2HashBuilder {
- static const u32 m = 0x5bd1e995;
- static const u32 seed = 0x9747b28c;
- static const u32 r = 24;
- u32 h;
-
- public:
- explicit MurMur2HashBuilder(u32 init = 0) { h = seed ^ init; }
- void add(u32 k) {
- k *= m;
- k ^= k >> r;
- k *= m;
- h *= m;
- h ^= k;
- }
- u32 get() {
- u32 x = h;
- x ^= x >> 13;
- x *= m;
- x ^= x >> 15;
- return x;
- }
-};
-} //namespace __sanitizer
-
-#endif // SANITIZER_HASH_H
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_mips64.S b/compiler-rt/lib/sanitizer_common/sanitizer_linux_mips64.S
index ac6ff22..a63b7d1 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_mips64.S
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_mips64.S
@@ -2,10 +2,10 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#include "sanitizer_common/sanitizer_asm.h"
-
// Avoid being marked as needing an executable stack:
-NO_EXEC_STACK_DIRECTIVE
+#if defined(__linux__) && defined(__ELF__)
+.section .note.GNU-stack,"",%progbits
+#endif
// Further contents are mips64 only:
#if defined(__linux__) && defined(__mips64)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_x86_64.S b/compiler-rt/lib/sanitizer_common/sanitizer_linux_x86_64.S
index d22d6d1..2a4f2e4 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_x86_64.S
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_x86_64.S
@@ -2,10 +2,10 @@
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#include "sanitizer_common/sanitizer_asm.h"
-
// Avoid being marked as needing an executable stack:
-NO_EXEC_STACK_DIRECTIVE
+#if defined(__linux__) && defined(__ELF__)
+.section .note.GNU-stack,"",%progbits
+#endif
// Further contents are x86_64-only:
#if defined(__linux__) && defined(__x86_64__)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc b/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc
index bf71274..91e7f0f 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc
@@ -367,7 +367,8 @@
void DecorateMapping(uptr addr, uptr size, const char *name) {
if (!common_flags()->decorate_proc_maps || !name)
return;
- internal_prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, addr, size, (uptr)name);
+ CHECK(internal_prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, addr, size,
+ (uptr)name) == 0);
}
#else
void DecorateMapping(uptr addr, uptr size, const char *name) {
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cc b/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cc
index 1cdedfa..a38cb9d 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stackdepot.cc
@@ -13,7 +13,6 @@
#include "sanitizer_stackdepot.h"
#include "sanitizer_common.h"
-#include "sanitizer_hash.h"
#include "sanitizer_stackdepotbase.h"
namespace __sanitizer {
@@ -50,9 +49,23 @@
return sizeof(StackDepotNode) + (args.size - 1) * sizeof(uptr);
}
static u32 hash(const args_type &args) {
- MurMur2HashBuilder H(args.size * sizeof(uptr));
- for (uptr i = 0; i < args.size; i++) H.add(args.trace[i]);
- return H.get();
+ // murmur2
+ const u32 m = 0x5bd1e995;
+ const u32 seed = 0x9747b28c;
+ const u32 r = 24;
+ u32 h = seed ^ (args.size * sizeof(uptr));
+ for (uptr i = 0; i < args.size; i++) {
+ u32 k = args.trace[i];
+ k *= m;
+ k ^= k >> r;
+ k *= m;
+ h *= m;
+ h ^= k;
+ }
+ h ^= h >> 13;
+ h *= m;
+ h ^= h >> 15;
+ return h;
}
static bool is_valid(const args_type &args) {
return args.size > 0 && args.trace;
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl_aarch64.S b/compiler-rt/lib/tsan/rtl/tsan_rtl_aarch64.S
index 7c3ce13..3d02bf2 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl_aarch64.S
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl_aarch64.S
@@ -335,6 +335,9 @@
ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(__sigsetjmp))
#endif
-NO_EXEC_STACK_DIRECTIVE
+#if defined(__linux__)
+/* We do not need executable stack. */
+.section .note.GNU-stack,"",@progbits
+#endif
#endif
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl_amd64.S b/compiler-rt/lib/tsan/rtl/tsan_rtl_amd64.S
index b5c8cb7..34ef51c 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl_amd64.S
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl_amd64.S
@@ -389,6 +389,10 @@
ASM_SIZE(ASM_SYMBOL_INTERCEPTOR(__sigsetjmp))
#endif // !defined(__APPLE__) && !defined(__NetBSD__)
-NO_EXEC_STACK_DIRECTIVE
+#if defined(__FreeBSD__) || defined(__linux__)
+/* We do not need executable stack. */
+/* This note is not needed on NetBSD. */
+.section .note.GNU-stack,"",@progbits
+#endif
#endif
diff --git a/compiler-rt/test/asan/TestCases/Linux/vfork.cc b/compiler-rt/test/asan/TestCases/Linux/vfork.cc
deleted file mode 100644
index 31a32dc..0000000
--- a/compiler-rt/test/asan/TestCases/Linux/vfork.cc
+++ /dev/null
@@ -1,31 +0,0 @@
-// https://github.com/google/sanitizers/issues/925
-// RUN: %clang_asan -O0 %s -o %t && %run %t 2>&1
-
-// REQUIRES: aarch64-target-arch || x86_64-target-arch || i386-target-arch || arm-target-arch
-
-#include <assert.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <sanitizer/asan_interface.h>
-
-__attribute__((noinline, no_sanitize("address"))) void child() {
- alignas(8) char x[100000];
- __asan_poison_memory_region(x, sizeof(x));
- _exit(0);
-}
-
-__attribute__((noinline, no_sanitize("address"))) void parent() {
- alignas(8) char x[100000];
- assert(__asan_address_is_poisoned(x + 5000) == 0);
-}
-
-int main(int argc, char **argv) {
- if (vfork())
- parent();
- else
- child();
-
- return 0;
-}
diff --git a/compiler-rt/test/builtins/Unit/addtf3_test.c b/compiler-rt/test/builtins/Unit/addtf3_test.c
index d24d0eb..8f00f6d 100644
--- a/compiler-rt/test/builtins/Unit/addtf3_test.c
+++ b/compiler-rt/test/builtins/Unit/addtf3_test.c
@@ -11,12 +11,11 @@
//
//===----------------------------------------------------------------------===//
-#include <fenv.h>
+#include "int_lib.h"
#include <stdio.h>
#if __LDBL_MANT_DIG__ == 113
-#include "int_lib.h"
#include "fp_test.h"
// Returns: a + b
@@ -75,26 +74,6 @@
UINT64_C(0x61e58dd6c51eb77c)))
return 1;
-#if (defined(__arm__) || defined(__aarch64__)) && defined(__ARM_FP)
- // Rounding mode tests on supported architectures
- long double m = 1234.0L, n = 0.01L;
- fesetround(FE_UPWARD);
- if (__addtf3(m, n) != 1235.0L)
- return 1;
-
- fesetround(FE_DOWNWARD);
- if (__addtf3(m, n) != 1234.0L)
- return 1;
-
- fesetround(FE_TOWARDZERO);
- if (__addtf3(m, n) != 1234.0L)
- return 1;
-
- fesetround(FE_TONEAREST);
- if (__addtf3(m, n) != 1234.0L)
- return 1;
-#endif
-
#else
printf("skipped\n");
diff --git a/compiler-rt/test/builtins/Unit/subtf3_test.c b/compiler-rt/test/builtins/Unit/subtf3_test.c
index d1e88ea..bcf82e0c 100644
--- a/compiler-rt/test/builtins/Unit/subtf3_test.c
+++ b/compiler-rt/test/builtins/Unit/subtf3_test.c
@@ -11,7 +11,6 @@
//
//===----------------------------------------------------------------------===//
-#include <fenv.h>
#include <stdio.h>
#if __LDBL_MANT_DIG__ == 113
@@ -68,26 +67,6 @@
UINT64_C(0xa44a7bca780a166c)))
return 1;
-#if (defined(__arm__) || defined(__aarch64__)) && defined(__ARM_FP)
- // Rounding mode tests on supported architectures
- long double m = 1234.0L, n = 0.01L;
- fesetround(FE_UPWARD);
- if (__subtf3(m, n) != 1234.0L)
- return 1;
-
- fesetround(FE_DOWNWARD);
- if (__subtf3(m, n) != 1233.0L)
- return 1;
-
- fesetround(FE_TOWARDZERO);
- if (__subtf3(m, n) != 1233.0L)
- return 1;
-
- fesetround(FE_TONEAREST);
- if (__subtf3(m, n) != 1234.0L)
- return 1;
-#endif
-
#else
printf("skipped\n");
diff --git a/compiler-rt/test/hwasan/TestCases/Linux/vfork.c b/compiler-rt/test/hwasan/TestCases/Linux/vfork.c
deleted file mode 100644
index 84e9602..0000000
--- a/compiler-rt/test/hwasan/TestCases/Linux/vfork.c
+++ /dev/null
@@ -1,32 +0,0 @@
-// https://github.com/google/sanitizers/issues/925
-// RUN: %clang_hwasan -O0 %s -o %t && %run %t 2>&1
-
-// REQUIRES: aarch64-target-arch || x86_64-target-arch
-
-#include <assert.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <sanitizer/hwasan_interface.h>
-
-__attribute__((noinline, no_sanitize("hwaddress"))) void child() {
- char x[10000];
- __hwasan_tag_memory(x, 0xAA, sizeof(x));
- _exit(0);
-}
-
-__attribute__((noinline, no_sanitize("hwaddress"))) void parent() {
- char x[10000];
- __hwasan_print_shadow(&x, sizeof(x));
- assert(__hwasan_test_shadow(x, sizeof(x)) == -1);
-}
-
-int main(int argc, char **argv) {
- if (vfork())
- parent();
- else
- child();
-
- return 0;
-}
diff --git a/compiler-rt/test/hwasan/TestCases/malloc_bisect.c b/compiler-rt/test/hwasan/TestCases/malloc_bisect.c
deleted file mode 100644
index 51cbbfe..0000000
--- a/compiler-rt/test/hwasan/TestCases/malloc_bisect.c
+++ /dev/null
@@ -1,26 +0,0 @@
-// RUN: %clang_hwasan -O0 %s -o %t
-// RUN: %env_hwasan_opts=malloc_bisect_left=0,malloc_bisect_right=0 not %run %t 2>&1 | \
-// RUN: FileCheck %s --check-prefix=CRASH
-// RUN: %env_hwasan_opts=malloc_bisect_left=1000,malloc_bisect_right=999 %run %t 2>&1
-// RUN: %env_hwasan_opts=malloc_bisect_left=0,malloc_bisect_right=4294967295 not %run %t 2>&1 | \
-// RUN: FileCheck %s --check-prefix=CRASH
-// RUN: %env_hwasan_opts=malloc_bisect_left=0,malloc_bisect_right=4294967295,malloc_bisect_dump=1 not %run %t 2>&1 | \
-// RUN: FileCheck %s --check-prefixes=CRASH,DUMP
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <sanitizer/hwasan_interface.h>
-
-int main() {
- __hwasan_enable_allocator_tagging();
- // DUMP: [alloc] {{.*}} 10{{$}}
- // DUMP: in main{{.*}}malloc_bisect.c
- char * volatile p = (char*)malloc(10);
- // CRASH: HWAddressSanitizer: tag-mismatch on address
- // CRASH: in main{{.*}}malloc_bisect.c
- char volatile x = p[16];
- free(p);
- __hwasan_disable_allocator_tagging();
-
- return 0;
-}
diff --git a/compiler-rt/test/hwasan/TestCases/register-dump-read.c b/compiler-rt/test/hwasan/TestCases/register-dump-read.c
deleted file mode 100644
index 19bf03f..0000000
--- a/compiler-rt/test/hwasan/TestCases/register-dump-read.c
+++ /dev/null
@@ -1,43 +0,0 @@
-// RUN: %clang_hwasan -ffixed-x10 -ffixed-x20 -ffixed-x27 -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
-// RUN: %clang_hwasan -ffixed-x10 -ffixed-x20 -ffixed-x27 -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
-// RUN: %clang_hwasan -ffixed-x10 -ffixed-x20 -ffixed-x27 -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
-// RUN: %clang_hwasan -ffixed-x10 -ffixed-x20 -ffixed-x27 -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
-// REQUIRES: aarch64-target-arch
-
-// RUN: %clang_hwasan -ffixed-x10 -ffixed-x20 -ffixed-x27 -O2 %s -o %t && not %env_hwasan_opts=fast_unwind_on_fatal=true %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
-// RUN: %clang_hwasan -ffixed-x10 -ffixed-x20 -ffixed-x27 -O2 %s -o %t && not %env_hwasan_opts=fast_unwind_on_fatal=false %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <sanitizer/hwasan_interface.h>
-
-int main() {
- __hwasan_enable_allocator_tagging();
- char * volatile x = (char*) malloc(10);
- asm volatile("mov x10, #0x2222\n"
- "mov x20, #0x3333\n"
- "mov x27, #0x4444\n");
- return x[16];
-
- // CHECK: ERROR: HWAddressSanitizer:
- // CHECK: #0 {{.*}} in main {{.*}}register-dump-read.c:[[@LINE-3]]
-
- // Developer note: FileCheck really doesn't like when you have a regex that
- // ends with a '}' character, e.g. the regex "[0-9]{10}" will fail, because
- // the closing '}' fails as an "unbalanced regex". We work around this by
- // encasing the trailing space after a register, or the end-of-line specifier.
-
- // CHECK: Registers where the failure occurred
- // CHECK-NEXT: x0{{[ ]+[0-9a-f]{16}[ ]}}x1{{[ ]+[0-9a-f]{16}[ ]}}x2{{[ ]+[0-9a-f]{16}[ ]}}x3{{[ ]+[0-9a-f]{16}$}}
- // CHECK-NEXT: x4{{[ ]+[0-9a-f]{16}[ ]}}x5{{[ ]+[0-9a-f]{16}[ ]}}x6{{[ ]+[0-9a-f]{16}[ ]}}x7{{[ ]+[0-9a-f]{16}$}}
- // CHECK-NEXT: x8{{[ ]+[0-9a-f]{16}[ ]}}x9{{[ ]+[0-9a-f]{16}[ ]}}
- // CHECK-SAME: x10 0000000000002222
- // CHECK-SAME: x11{{[ ]+[0-9a-f]{16}$}}
- // CHECK-NEXT: x12{{[ ]+[0-9a-f]{16}[ ]}}x13{{[ ]+[0-9a-f]{16}[ ]}}x14{{[ ]+[0-9a-f]{16}[ ]}}x15{{[ ]+[0-9a-f]{16}$}}
- // CHECK-NEXT: x16{{[ ]+[0-9a-f]{16}[ ]}}x17{{[ ]+[0-9a-f]{16}[ ]}}x18{{[ ]+[0-9a-f]{16}[ ]}}x19{{[ ]+[0-9a-f]{16}$}}
- // CHECK-NEXT: x20 0000000000003333
- // CHECK-SAME: x21{{[ ]+[0-9a-f]{16}[ ]}}x22{{[ ]+[0-9a-f]{16}[ ]}}x23{{[ ]+[0-9a-f]{16}$}}
- // CHECK-NEXT: x24{{[ ]+[0-9a-f]{16}[ ]}}x25{{[ ]+[0-9a-f]{16}[ ]}}x26{{[ ]+[0-9a-f]{16}[ ]}}
- // CHECK-SAME: x27 0000000000004444
- // CHECK-NEXT: x28{{[ ]+[0-9a-f]{16}[ ]}}x29{{[ ]+[0-9a-f]{16}[ ]}}x30{{[ ]+[0-9a-f]{16}$}}
-}
diff --git a/compiler-rt/test/hwasan/TestCases/stack-uar.c b/compiler-rt/test/hwasan/TestCases/stack-uar.c
index 8b308a5..863a840 100644
--- a/compiler-rt/test/hwasan/TestCases/stack-uar.c
+++ b/compiler-rt/test/hwasan/TestCases/stack-uar.c
@@ -1,6 +1,5 @@
// Tests use-after-return detection and reporting.
// RUN: %clang_hwasan -O0 -fno-discard-value-names %s -o %t && not %run %t 2>&1 | FileCheck %s
-// RUN: %clang_hwasan -O0 -fno-discard-value-names %s -o %t && not %env_hwasan_opts=symbolize=0 %run %t 2>&1 | FileCheck %s --check-prefix=NOSYM
// REQUIRES: stable-runtime
@@ -38,9 +37,5 @@
// CHECK: buggy
// CHECK: 4096 zzz
- // NOSYM: Previously allocated frames:
- // NOSYM-NEXT: sp: 0x{{.*}} #0 0x{{.*}} ({{.*}}/stack-uar.c.tmp+0x{{.*}}){{$}}
- // NOSYM-NEXT: 16 CCC;
-
// CHECK: SUMMARY: HWAddressSanitizer: tag-mismatch {{.*}} in main
}
diff --git a/compiler-rt/test/hwasan/TestCases/tag_in_free.c b/compiler-rt/test/hwasan/TestCases/tag_in_free.c
deleted file mode 100644
index 51e8d01..0000000
--- a/compiler-rt/test/hwasan/TestCases/tag_in_free.c
+++ /dev/null
@@ -1,51 +0,0 @@
-// RUN: %clang_hwasan -O0 %s -DMALLOC -DFREE -o %t.mf
-// RUN: %env_hwasan_opts=tag_in_malloc=0,tag_in_free=1 not %run %t.mf 2>&1 | FileCheck %s --check-prefixes=FREE
-// RUN: %env_hwasan_opts=tag_in_malloc=1,tag_in_free=1 not %run %t.mf 2>&1 | FileCheck %s --check-prefixes=MALLOC
-// RUN: %env_hwasan_opts=tag_in_malloc=1,tag_in_free=0 not %run %t.mf 2>&1 | FileCheck %s --check-prefixes=MALLOC
-// RUN: %env_hwasan_opts=tag_in_malloc=0,tag_in_free=0 %run %t.mf 2>&1
-
-// RUN: %clang_hwasan -O0 %s -DFREE -o %t.f
-// RUN: %env_hwasan_opts=tag_in_malloc=0,tag_in_free=1 not %run %t.f 2>&1 | FileCheck %s --check-prefixes=FREE
-// RUN: %env_hwasan_opts=tag_in_malloc=1,tag_in_free=1 not %run %t.f 2>&1 | FileCheck %s --check-prefixes=FREE
-// RUN: %env_hwasan_opts=tag_in_malloc=1,tag_in_free=0 %run %t.f 2>&1
-// RUN: %env_hwasan_opts=tag_in_malloc=0,tag_in_free=0 %run %t.f 2>&1
-
-// RUN: %clang_hwasan -O0 %s -DMALLOC -o %t.m
-// RUN: %env_hwasan_opts=tag_in_malloc=0,tag_in_free=1 %run %t.m 2>&1
-// RUN: %env_hwasan_opts=tag_in_malloc=1,tag_in_free=1 not %run %t.m 2>&1 | FileCheck %s --check-prefixes=MALLOC
-// RUN: %env_hwasan_opts=tag_in_malloc=1,tag_in_free=0 not %run %t.m 2>&1 | FileCheck %s --check-prefixes=MALLOC
-// RUN: %env_hwasan_opts=tag_in_malloc=0,tag_in_free=0 %run %t.m 2>&1
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <sanitizer/hwasan_interface.h>
-
-int main() {
- __hwasan_enable_allocator_tagging();
- // Loop for a while to make sure that the memory for the test below is reused after an earlier free(),
- // and is potentially tagged (when tag_in_free == 1).
- for (int i = 0; i < 100; ++i) {
- char * volatile p = (char*)malloc(10);
- free(p);
- }
-
- char * volatile p = (char*)malloc(10);
-#ifdef MALLOC
- // MALLOC: READ of size 1 at
- // MALLOC: is located 6 bytes to the right of 10-byte region
- // MALLOC: allocated here:
- char volatile x = p[16];
-#endif
- free(p);
-#ifdef FREE
- // FREE: READ of size 1 at
- // FREE: is located 0 bytes inside of 10-byte region
- // FREE: freed by thread T0 here:
- // FREE: previously allocated here:
- char volatile y = p[0];
-#endif
-
- __hwasan_disable_allocator_tagging();
-
- return 0;
-}
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index ad4d549..e2aa7e9 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -1544,10 +1544,6 @@
// They also might be exported if referenced by DSOs.
Script->declareSymbols();
- // Handle undefined symbols in DSOs.
- if (!Config->Shared)
- Symtab->scanShlibUndefined<ELFT>();
-
// Handle the -exclude-libs option.
if (Args.hasArg(OPT_exclude_libs))
excludeLibs<ELFT>(Args);
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index edeb80c..c3e5b2f 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -1018,7 +1018,10 @@
}
if (Sym.isUndefined()) {
- this->Undefs.insert(Name);
+ Symbol *S = Symtab->addUndefined<ELFT>(Name, Sym.getBinding(),
+ Sym.st_other, Sym.getType(),
+ /*CanOmitFromDynSym=*/false, this);
+ S->ExportDynamic = true;
continue;
}
diff --git a/lld/ELF/InputFiles.h b/lld/ELF/InputFiles.h
index 1d7081b..105e5ec 100644
--- a/lld/ELF/InputFiles.h
+++ b/lld/ELF/InputFiles.h
@@ -93,13 +93,6 @@
return Symbols;
}
- // Returns undefined symbols of a shared library.
- // It is a runtime error to call this function on files of other types.
- const llvm::DenseSet<StringRef> &getUndefinedSymbols() {
- assert(FileKind == SharedKind);
- return Undefs;
- }
-
// Filename of .a which contained this file. If this file was
// not in an archive file, it is the empty string. We use this
// string for creating error messages.
@@ -146,7 +139,6 @@
InputFile(Kind K, MemoryBufferRef M);
std::vector<InputSectionBase *> Sections;
std::vector<Symbol *> Symbols;
- llvm::DenseSet<StringRef> Undefs;
private:
const Kind FileKind;
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 4beb5b2..2341938 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -156,10 +156,6 @@
Symbol *B = Symtab->find(Cmd->Name);
if (B && !B->isDefined())
return true;
- // It might also be referenced by a DSO.
- for (InputFile *F : SharedFiles)
- if (F->getUndefinedSymbols().count(Cmd->Name))
- return true;
return false;
}
diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp
index f5fb41c..e25682f 100644
--- a/lld/ELF/SymbolTable.cpp
+++ b/lld/ELF/SymbolTable.cpp
@@ -599,24 +599,6 @@
addFile<ELFT>(File);
}
-// This function takes care of the case in which shared libraries depend on
-// the user program (not the other way, which is usual). Shared libraries
-// may have undefined symbols, expecting that the user program provides
-// the definitions for them. An example is BSD's __progname symbol.
-// We need to put such symbols to the main program's .dynsym so that
-// shared libraries can find them.
-// Except this, we ignore undefined symbols in DSOs.
-template <class ELFT> void SymbolTable::scanShlibUndefined() {
- for (InputFile *F : SharedFiles) {
- for (StringRef U : F->getUndefinedSymbols()) {
- Symbol *Sym = find(U);
- if (!Sym || !Sym->isDefined())
- continue;
- Sym->ExportDynamic = true;
- }
- }
-}
-
// Initialize DemangledSyms with a map from demangled symbols to symbol
// objects. Used to handle "extern C++" directive in version scripts.
//
@@ -832,9 +814,3 @@
template void SymbolTable::addShared<ELF64BE>(StringRef, SharedFile<ELF64BE> &,
const typename ELF64BE::Sym &,
uint32_t Alignment, uint32_t);
-
-template void SymbolTable::scanShlibUndefined<ELF32LE>();
-template void SymbolTable::scanShlibUndefined<ELF32BE>();
-template void SymbolTable::scanShlibUndefined<ELF64LE>();
-template void SymbolTable::scanShlibUndefined<ELF64BE>();
-
diff --git a/lld/ELF/SymbolTable.h b/lld/ELF/SymbolTable.h
index 654e362..9822ed7 100644
--- a/lld/ELF/SymbolTable.h
+++ b/lld/ELF/SymbolTable.h
@@ -71,7 +71,6 @@
template <class ELFT> void fetchLazy(Symbol *Sym);
- template <class ELFT> void scanShlibUndefined();
void scanVersionScript();
Symbol *find(StringRef Name);
diff --git a/lld/test/ELF/shlib-undefined-archive.s b/lld/test/ELF/shlib-undefined-archive.s
new file mode 100644
index 0000000..940d8d7
--- /dev/null
+++ b/lld/test/ELF/shlib-undefined-archive.s
@@ -0,0 +1,19 @@
+# REQUIRES: x86
+
+# Undefined symbols in a DSO should pull out object files from archives
+# to resolve them.
+
+# RUN: echo '.globl foo' | llvm-mc -filetype=obj -triple=x86_64-linux-gnu -o %t1.o -
+# RUN: ld.lld -shared -o %t.so %t1.o
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-linux-gnu -o %t2.o %s
+# RUN: rm -f %t.a
+# RUN: llvm-ar cru %t.a %t2.o
+# RUN: ld.lld -o %t.exe %t.so %t.a
+# RUN: llvm-nm -D %t.exe | FileCheck %s
+
+# CHECK: T foo
+
+.globl foo
+foo:
+ ret
diff --git a/lld/test/ELF/trace-symbols.s b/lld/test/ELF/trace-symbols.s
index 58aeb5d..63004b7 100644
--- a/lld/test/ELF/trace-symbols.s
+++ b/lld/test/ELF/trace-symbols.s
@@ -72,7 +72,7 @@
# RUN: ld.lld -y foo -y bar %t %t1.so %t2.so -o %t3 | \
# RUN: FileCheck -check-prefix=SHLIBRBAR %s
-# SHLIBRBAR-NOT: trace-symbols.s.tmp1.so: reference to bar
+# SHLIBRBAR: trace-symbols.s.tmp1.so: reference to bar
# RUN: ld.lld -y foo -y bar %t -u bar --start-lib %t1 %t2 --end-lib -o %t3 | \
# RUN: FileCheck -check-prefix=STARTLIB %s
diff --git a/llvm/include/llvm/LTO/LTO.h b/llvm/include/llvm/LTO/LTO.h
index 1f9d764..d3949aa 100644
--- a/llvm/include/llvm/LTO/LTO.h
+++ b/llvm/include/llvm/LTO/LTO.h
@@ -398,8 +398,6 @@
Error runRegularLTO(AddStreamFn AddStream);
Error runThinLTO(AddStreamFn AddStream, NativeObjectCache Cache);
- Error checkPartiallySplit();
-
mutable bool CalledGetMaxTasks = false;
// Use Optional to distinguish false from not yet initialized.
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index b1a7a13..edb05fb 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -1349,7 +1349,7 @@
void SelectionDAGBuilder::resolveOrClearDbgInfo() {
// Try to fixup any remaining dangling debug info -- and drop it if we can't.
for (auto &Pair : DanglingDebugInfoMap)
- for (auto &DDI : Pair.second)
+ for (auto &DDI : Pair.getSecond())
salvageUnresolvedDbgValue(DDI);
clearDanglingDebugInfo();
}
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
index e0d397c..e84214d 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
@@ -17,7 +17,6 @@
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/CodeGen/ISDOpcodes.h"
@@ -122,7 +121,7 @@
/// Keeps track of dbg_values for which we have not yet seen the referent.
/// We defer handling these until we do see it.
- MapVector<const Value*, DanglingDebugInfoVector> DanglingDebugInfoMap;
+ DenseMap<const Value*, DanglingDebugInfoVector> DanglingDebugInfoMap;
public:
/// Loads are not emitted to the program immediately. We bunch them up and
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp
index 8e0d532..23a4a40 100644
--- a/llvm/lib/LTO/LTO.cpp
+++ b/llvm/lib/LTO/LTO.cpp
@@ -20,7 +20,6 @@
#include "llvm/Config/llvm-config.h"
#include "llvm/IR/AutoUpgrade.h"
#include "llvm/IR/DiagnosticPrinter.h"
-#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/Mangler.h"
#include "llvm/IR/Metadata.h"
@@ -809,45 +808,6 @@
return RegularLTO.ParallelCodeGenParallelismLevel + ThinLTO.ModuleMap.size();
}
-// If only some of the modules were split, we cannot correctly handle
-// code that contains type tests or type checked loads.
-Error LTO::checkPartiallySplit() {
- if (!ThinLTO.CombinedIndex.partiallySplitLTOUnits())
- return Error::success();
-
- Function *TypeTestFunc = RegularLTO.CombinedModule->getFunction(
- Intrinsic::getName(Intrinsic::type_test));
- Function *TypeCheckedLoadFunc = RegularLTO.CombinedModule->getFunction(
- Intrinsic::getName(Intrinsic::type_checked_load));
-
- // First check if there are type tests / type checked loads in the
- // merged regular LTO module IR.
- if ((TypeTestFunc && !TypeTestFunc->use_empty()) ||
- (TypeCheckedLoadFunc && !TypeCheckedLoadFunc->use_empty()))
- return make_error<StringError>(
- "inconsistent LTO Unit splitting (recompile with -fsplit-lto-unit)",
- inconvertibleErrorCode());
-
- // Otherwise check if there are any recorded in the combined summary from the
- // ThinLTO modules.
- for (auto &P : ThinLTO.CombinedIndex) {
- for (auto &S : P.second.SummaryList) {
- auto *FS = dyn_cast<FunctionSummary>(S.get());
- if (!FS)
- continue;
- if (!FS->type_test_assume_vcalls().empty() ||
- !FS->type_checked_load_vcalls().empty() ||
- !FS->type_test_assume_const_vcalls().empty() ||
- !FS->type_checked_load_const_vcalls().empty() ||
- !FS->type_tests().empty())
- return make_error<StringError>(
- "inconsistent LTO Unit splitting (recompile with -fsplit-lto-unit)",
- inconvertibleErrorCode());
- }
- }
- return Error::success();
-}
-
Error LTO::run(AddStreamFn AddStream, NativeObjectCache Cache) {
// Compute "dead" symbols, we don't want to import/export these!
DenseSet<GlobalValue::GUID> GUIDPreservedSymbols;
@@ -890,17 +850,6 @@
StatsFile->keep();
}
- // Finalize linking of regular LTO modules containing summaries now that
- // we have computed liveness information.
- for (auto &M : RegularLTO.ModsWithSummaries)
- if (Error Err = linkRegularLTO(std::move(M),
- /*LivenessFromIndex=*/true))
- return Err;
-
- // Ensure we don't have inconsistently split LTO units with type tests.
- if (Error Err = checkPartiallySplit())
- return Err;
-
Error Result = runRegularLTO(AddStream);
if (!Result)
Result = runThinLTO(AddStream, Cache);
@@ -912,6 +861,11 @@
}
Error LTO::runRegularLTO(AddStreamFn AddStream) {
+ for (auto &M : RegularLTO.ModsWithSummaries)
+ if (Error Err = linkRegularLTO(std::move(M),
+ /*LivenessFromIndex=*/true))
+ return Err;
+
// Make sure commons have the right size/alignment: we kept the largest from
// all the prevailing when adding the inputs, and we apply it here.
const DataLayout &DL = RegularLTO.CombinedModule->getDataLayout();
diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp
index 3fbffab..70d5262 100644
--- a/llvm/lib/Linker/IRMover.cpp
+++ b/llvm/lib/Linker/IRMover.cpp
@@ -239,18 +239,27 @@
// These are types that LLVM itself will unique.
bool IsUniqued = !isa<StructType>(Ty) || cast<StructType>(Ty)->isLiteral();
-#ifndef NDEBUG
if (!IsUniqued) {
+ StructType *STy = cast<StructType>(Ty);
+ // This is actually a type from the destination module, this can be reached
+ // when this type is loaded in another module, added to DstStructTypesSet,
+ // and then we reach the same type in another module where it has not been
+ // added to MappedTypes. (PR37684)
+ if (STy->getContext().isODRUniquingDebugTypes() && !STy->isOpaque() &&
+ DstStructTypesSet.hasType(STy))
+ return *Entry = STy;
+
+#ifndef NDEBUG
for (auto &Pair : MappedTypes) {
assert(!(Pair.first != Ty && Pair.second == Ty) &&
"mapping to a source type");
}
- }
#endif
- if (!IsUniqued && !Visited.insert(cast<StructType>(Ty)).second) {
- StructType *DTy = StructType::create(Ty->getContext());
- return *Entry = DTy;
+ if (!Visited.insert(STy).second) {
+ StructType *DTy = StructType::create(Ty->getContext());
+ return *Entry = DTy;
+ }
}
// If this is not a recursive type, then just map all of the elements and
diff --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
index 77a2cdc..61196ba 100644
--- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
@@ -19,7 +19,6 @@
#include "AArch64TargetObjectFile.h"
#include "InstPrinter/AArch64InstPrinter.h"
#include "MCTargetDesc/AArch64AddressingModes.h"
-#include "MCTargetDesc/AArch64MCExpr.h"
#include "MCTargetDesc/AArch64MCTargetDesc.h"
#include "MCTargetDesc/AArch64TargetStreamer.h"
#include "Utils/AArch64BaseInfo.h"
@@ -267,9 +266,6 @@
MCSymbol *HwasanTagMismatchSym =
OutContext.getOrCreateSymbol("__hwasan_tag_mismatch");
- const MCSymbolRefExpr *HwasanTagMismatchRef =
- MCSymbolRefExpr::create(HwasanTagMismatchSym, OutContext);
-
for (auto &P : HwasanMemaccessSymbols) {
unsigned Reg = P.first.first;
uint32_t AccessInfo = P.first.second;
@@ -320,21 +316,6 @@
MCInstBuilder(AArch64::RET).addReg(AArch64::LR), *STI);
OutStreamer->EmitLabel(HandleMismatchSym);
-
- OutStreamer->EmitInstruction(MCInstBuilder(AArch64::STPXpre)
- .addReg(AArch64::SP)
- .addReg(AArch64::X0)
- .addReg(AArch64::X1)
- .addReg(AArch64::SP)
- .addImm(-32),
- *STI);
- OutStreamer->EmitInstruction(MCInstBuilder(AArch64::STPXi)
- .addReg(AArch64::FP)
- .addReg(AArch64::LR)
- .addReg(AArch64::SP)
- .addImm(29),
- *STI);
-
if (Reg != AArch64::X0)
OutStreamer->EmitInstruction(MCInstBuilder(AArch64::ORRXrs)
.addReg(AArch64::X0)
@@ -347,27 +328,10 @@
.addImm(AccessInfo)
.addImm(0),
*STI);
-
- // Intentionally load the GOT entry and branch to it, rather than possibly
- // late binding the function, which may clobber the registers before we have
- // a chance to save them.
OutStreamer->EmitInstruction(
- MCInstBuilder(AArch64::ADRP)
- .addReg(AArch64::X16)
- .addExpr(AArch64MCExpr::create(
- HwasanTagMismatchRef,
- AArch64MCExpr::VariantKind::VK_GOT_PAGE, OutContext)),
+ MCInstBuilder(AArch64::B)
+ .addExpr(MCSymbolRefExpr::create(HwasanTagMismatchSym, OutContext)),
*STI);
- OutStreamer->EmitInstruction(
- MCInstBuilder(AArch64::LDRXui)
- .addReg(AArch64::X16)
- .addReg(AArch64::X16)
- .addExpr(AArch64MCExpr::create(
- HwasanTagMismatchRef,
- AArch64MCExpr::VariantKind::VK_GOT_LO12, OutContext)),
- *STI);
- OutStreamer->EmitInstruction(
- MCInstBuilder(AArch64::BR).addReg(AArch64::X16), *STI);
}
}
diff --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
index 5f051b3..25fb5d7 100644
--- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
+++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
@@ -1137,23 +1137,15 @@
if (AM.hasSymbolicDisplacement())
return true;
- bool IsRIPRelTLS = false;
bool IsRIPRel = N.getOpcode() == X86ISD::WrapperRIP;
- if (IsRIPRel) {
- SDValue Val = N.getOperand(0);
- if (Val.getOpcode() == ISD::TargetGlobalTLSAddress)
- IsRIPRelTLS = true;
- }
- // We can't use an addressing mode in the 64-bit large code model.
- // Global TLS addressing is an exception. In the medium code model,
- // we use can use a mode when RIP wrappers are present.
- // That signifies access to globals that are known to be "near",
- // such as the GOT itself.
+ // We can't use an addressing mode in the 64-bit large code model. In the
+ // medium code model, we use can use an mode when RIP wrappers are present.
+ // That signifies access to globals that are known to be "near", such as the
+ // GOT itself.
CodeModel::Model M = TM.getCodeModel();
if (Subtarget->is64Bit() &&
- ((M == CodeModel::Large && !IsRIPRelTLS) ||
- (M == CodeModel::Medium && !IsRIPRel)))
+ (M == CodeModel::Large || (M == CodeModel::Medium && !IsRIPRel)))
return true;
// Base and index reg must be 0 in order to use %rip as base.
diff --git a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
index 398005d..2f8a96b 100644
--- a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
+++ b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
@@ -1692,14 +1692,6 @@
}
bool LowerTypeTestsModule::lower() {
- // If only some of the modules were split, we cannot correctly perform
- // this transformation. We already checked for the presense of type tests
- // with partially split modules during the thin link, and would have emitted
- // an error if any were found, so here we can simply return.
- if ((ExportSummary && ExportSummary->partiallySplitLTOUnits()) ||
- (ImportSummary && ImportSummary->partiallySplitLTOUnits()))
- return false;
-
Function *TypeTestFunc =
M.getFunction(Intrinsic::getName(Intrinsic::type_test));
Function *ICallBranchFunnelFunc =
@@ -1709,6 +1701,13 @@
!ExportSummary && !ImportSummary)
return false;
+ // If only some of the modules were split, we cannot correctly handle
+ // code that contains type tests.
+ if (TypeTestFunc && !TypeTestFunc->use_empty() &&
+ ((ExportSummary && ExportSummary->partiallySplitLTOUnits()) ||
+ (ImportSummary && ImportSummary->partiallySplitLTOUnits())))
+ report_fatal_error("inconsistent LTO Unit splitting with llvm.type.test");
+
if (ImportSummary) {
if (TypeTestFunc) {
for (auto UI = TypeTestFunc->use_begin(), UE = TypeTestFunc->use_end();
diff --git a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
index 6b6dd61..ab6f0eb 100644
--- a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
+++ b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
@@ -1563,20 +1563,23 @@
}
bool DevirtModule::run() {
- // If only some of the modules were split, we cannot correctly perform
- // this transformation. We already checked for the presense of type tests
- // with partially split modules during the thin link, and would have emitted
- // an error if any were found, so here we can simply return.
- if ((ExportSummary && ExportSummary->partiallySplitLTOUnits()) ||
- (ImportSummary && ImportSummary->partiallySplitLTOUnits()))
- return false;
-
Function *TypeTestFunc =
M.getFunction(Intrinsic::getName(Intrinsic::type_test));
Function *TypeCheckedLoadFunc =
M.getFunction(Intrinsic::getName(Intrinsic::type_checked_load));
Function *AssumeFunc = M.getFunction(Intrinsic::getName(Intrinsic::assume));
+ // If only some of the modules were split, we cannot correctly handle
+ // code that contains type tests or type checked loads.
+ if ((ExportSummary && ExportSummary->partiallySplitLTOUnits()) ||
+ (ImportSummary && ImportSummary->partiallySplitLTOUnits())) {
+ if ((TypeTestFunc && !TypeTestFunc->use_empty()) ||
+ (TypeCheckedLoadFunc && !TypeCheckedLoadFunc->use_empty()))
+ report_fatal_error("inconsistent LTO Unit splitting with llvm.type.test "
+ "or llvm.type.checked.load");
+ return false;
+ }
+
// Normally if there are no users of the devirtualization intrinsics in the
// module, this pass has nothing to do. But if we are exporting, we also need
// to handle any users that appear only in the function summaries.
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index 723bb4c..8cbf57a 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -1375,8 +1375,7 @@
if (match(LHS, m_ShuffleVector(m_Value(L0), m_Value(L1), m_Constant(Mask))) &&
match(RHS, m_ShuffleVector(m_Value(R0), m_Value(R1), m_Specific(Mask))) &&
LHS->hasOneUse() && RHS->hasOneUse() &&
- cast<ShuffleVectorInst>(LHS)->isConcat() &&
- cast<ShuffleVectorInst>(RHS)->isConcat()) {
+ cast<ShuffleVectorInst>(LHS)->isConcat()) {
// This transform does not have the speculative execution constraint as
// below because the shuffle is a concatenation. The new binops are
// operating on exactly the same elements as the existing binop.
diff --git a/llvm/test/CodeGen/AArch64/hwasan-check-memaccess.ll b/llvm/test/CodeGen/AArch64/hwasan-check-memaccess.ll
index 46a6b93..3d5340b 100644
--- a/llvm/test/CodeGen/AArch64/hwasan-check-memaccess.ll
+++ b/llvm/test/CodeGen/AArch64/hwasan-check-memaccess.ll
@@ -43,13 +43,8 @@
; CHECK-NEXT: b.ne .Ltmp0
; CHECK-NEXT: ret
; CHECK-NEXT: .Ltmp0:
-; CHECK-NEXT: stp x0, x1, [sp, #-256]!
-; CHECK-NEXT: stp x29, x30, [sp, #232]
; CHECK-NEXT: mov x1, #456
-; CHECK-NEXT: adrp x16, :got:__hwasan_tag_mismatch
-; CHECK-NEXT: ldr x16, [x16, :got_lo12:__hwasan_tag_mismatch]
-; CHECK-NEXT: br x16
-
+; CHECK-NEXT: b __hwasan_tag_mismatch
; CHECK: .section .text.hot,"axG",@progbits,__hwasan_check_x1_123,comdat
; CHECK-NEXT: .type __hwasan_check_x1_123,@function
@@ -63,10 +58,6 @@
; CHECK-NEXT: b.ne .Ltmp1
; CHECK-NEXT: ret
; CHECK-NEXT: .Ltmp1:
-; CHECK-NEXT: stp x0, x1, [sp, #-256]!
-; CHECK-NEXT: stp x29, x30, [sp, #232]
; CHECK-NEXT: mov x0, x1
; CHECK-NEXT: mov x1, #123
-; CHECK-NEXT: adrp x16, :got:__hwasan_tag_mismatch
-; CHECK-NEXT: ldr x16, [x16, :got_lo12:__hwasan_tag_mismatch]
-; CHECK-NEXT: br x16
+; CHECK-NEXT: b __hwasan_tag_mismatch
diff --git a/llvm/test/CodeGen/Generic/selection-dag-determinism.ll b/llvm/test/CodeGen/Generic/selection-dag-determinism.ll
deleted file mode 100644
index d9bc90f..0000000
--- a/llvm/test/CodeGen/Generic/selection-dag-determinism.ll
+++ /dev/null
@@ -1,49 +0,0 @@
-; RUN: llc -O2 -o %t1.o < %s
-; RUN: llc -O2 -o %t2.o < %s
-; RUN: llc -O2 -o %t3.o < %s
-; RUN: llc -O2 -o %t4.o < %s
-; RUN: llc -O2 -o %t5.o < %s
-; RUN: cmp %t1.o %t2.o
-; RUN: cmp %t1.o %t3.o
-; RUN: cmp %t1.o %t4.o
-; RUN: cmp %t1.o %t5.o
-
-; Regression test for nondeterminism introduced in https://reviews.llvm.org/D57694
-
-define void @test(i32 %x) !dbg !4 {
-entry:
- call void @llvm.dbg.value(metadata void (i32)* @f1, metadata !6, metadata !DIExpression()), !dbg !8
- call void @llvm.dbg.value(metadata void (i32)* @f2, metadata !7, metadata !DIExpression()), !dbg !8
- %cmp = icmp eq i32 %x, 0, !dbg !8
- br i1 %cmp, label %cleanup, label %if.end
-
- if.end:
- %tobool = icmp eq i32 0, 0
- %a = select i1 %tobool, void (i32)* @f1, void (i32)* null, !dbg !8
- %b = select i1 %tobool, void (i32)* @f2, void (i32)* null, !dbg !8
- call void %a(i32 %x)
- call void %b(i32 %x)
- unreachable
-
- cleanup:
- ret void
-}
-
-declare void @f1(i32)
-declare void @f2(i32)
-
-declare void @llvm.dbg.value(metadata, metadata, metadata)
-
-!llvm.dbg.cu = !{!0}
-!llvm.module.flags = !{!3}
-
-!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang", runtimeVersion: 0, emissionKind: FullDebug)
-!1 = !DIFile(filename: "test.cc", directory: "")
-!2 = !{}
-!3 = !{i32 2, !"Debug Info Version", i32 3}
-!4 = distinct !DISubprogram(name: "test", scope: !1, file: !1, type: !5, unit: !0)
-!5 = !DISubroutineType(types: !2)
-!6 = !DILocalVariable(name: "a", scope: !4, file: !1, type: !9)
-!7 = !DILocalVariable(name: "b", scope: !4, file: !1, type: !9)
-!8 = !DILocation(scope: !4)
-!9 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !5, size: 64)
diff --git a/llvm/test/CodeGen/X86/code-model-elf.ll b/llvm/test/CodeGen/X86/code-model-elf.ll
index f7ffd6e..56d3f4c 100644
--- a/llvm/test/CodeGen/X86/code-model-elf.ll
+++ b/llvm/test/CodeGen/X86/code-model-elf.ll
@@ -37,8 +37,6 @@
@global_data = dso_local global [10 x i32] [i32 1, i32 2, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0], align 16
@static_data = internal global [10 x i32] zeroinitializer, align 16
@extern_data = external global [10 x i32], align 16
-@thread_data = external thread_local global i32, align 4
-
define dso_local i32* @lea_static_data() #0 {
; SMALL-STATIC-LABEL: lea_static_data:
@@ -375,70 +373,6 @@
ret void ()* @extern_fn
}
-; FIXME: The result is same for small, medium and large model, because we
-; specify pie option in the test case. And the type of tls is initial exec tls.
-; For pic code. The large model code for pic tls should be emitted as below.
-
-; .L3:
-; leaq .L3(%rip), %rbx
-; movabsq $_GLOBAL_OFFSET_TABLE_-.L3, %r11
-; addq %r11, %rbx
-; leaq thread_data@TLSGD(%rip), %rdi
-; movabsq $__tls_get_addr@PLTOFF, %rax
-; addq %rbx, %rax
-; call *%rax
-; movl (%rax), %eax
-
-; The medium and small model code for pic tls should be emitted as below.
-; data16
-; leaq thread_data@TLSGD(%rip), %rdi
-; data16
-; data16
-; rex64
-; callq __tls_get_addr@PLT
-; movl (%rax), %eax
-
-define dso_local i32 @load_thread_data() #0 {
-; SMALL-STATIC-LABEL: load_thread_data:
-; SMALL-STATIC: # %bb.0:
-; SMALL-STATIC-NEXT: movq thread_data@GOTTPOFF(%rip), %rax
-; SMALL-STATIC-NEXT: movl %fs:(%rax), %eax
-; SMALL-STATIC-NEXT: retq
-;
-; MEDIUM-STATIC-LABEL: load_thread_data:
-; MEDIUM-STATIC: # %bb.0:
-; MEDIUM-STATIC-NEXT: movq thread_data@GOTTPOFF(%rip), %rax
-; MEDIUM-STATIC-NEXT: movl %fs:(%rax), %eax
-; MEDIUM-STATIC-NEXT: retq
-;
-; LARGE-STATIC-LABEL: load_thread_data:
-; LARGE-STATIC: # %bb.0:
-; LARGE-STATIC-NEXT: movq thread_data@GOTTPOFF(%rip), %rax
-; LARGE-STATIC-NEXT: movl %fs:(%rax), %eax
-; LARGE-STATIC-NEXT: retq
-;
-; SMALL-PIC-LABEL: load_thread_data:
-; SMALL-PIC: # %bb.0:
-; SMALL-PIC-NEXT: movq thread_data@GOTTPOFF(%rip), %rax
-; SMALL-PIC-NEXT: movl %fs:(%rax), %eax
-; SMALL-PIC-NEXT: retq
-;
-; MEDIUM-PIC-LABEL: load_thread_data:
-; MEDIUM-PIC: # %bb.0:
-; MEDIUM-PIC-NEXT: movq thread_data@GOTTPOFF(%rip), %rax
-; MEDIUM-PIC-NEXT: movl %fs:(%rax), %eax
-; MEDIUM-PIC-NEXT: retq
-;
-; LARGE-PIC-LABEL: load_thread_data:
-; LARGE-PIC: # %bb.0:
-; LARGE-PIC-NEXT: movq thread_data@GOTTPOFF(%rip), %rax
-; LARGE-PIC-NEXT: movl %fs:(%rax), %eax
-; LARGE-PIC-NEXT: retq
-;
- %1 = load i32, i32* @thread_data, align 4
- ret i32 %1
-}
-
attributes #0 = { noinline nounwind uwtable }
!llvm.module.flags = !{!0, !1, !2}
diff --git a/llvm/test/LTO/X86/Inputs/type-mapping-bug2.ll b/llvm/test/LTO/X86/Inputs/type-mapping-bug2.ll
new file mode 100644
index 0000000..b58a1e9
--- /dev/null
+++ b/llvm/test/LTO/X86/Inputs/type-mapping-bug2.ll
@@ -0,0 +1,16 @@
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @c() !dbg !6 {
+ unreachable
+}
+
+!llvm.module.flags = !{!0, !1}
+!llvm.dbg.cu = !{!2}
+!0 = !{i32 2, !"Debug Info Version", i32 3}
+!1 = !{i32 1, !"ThinLTO", i32 0}
+!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, retainedTypes: !4)
+!3 = !DIFile(filename: "f2", directory: "")
+!4 = !{!5}
+!5 = !DICompositeType(tag: DW_TAG_class_type, file: !3, flags: DIFlagFwdDecl, identifier: "SHARED")
+!6 = distinct !DISubprogram(unit: !2)
diff --git a/llvm/test/LTO/X86/type-mapping-bug2.ll b/llvm/test/LTO/X86/type-mapping-bug2.ll
new file mode 100644
index 0000000..f14183f
--- /dev/null
+++ b/llvm/test/LTO/X86/type-mapping-bug2.ll
@@ -0,0 +1,42 @@
+; RUN: opt -module-summary -o %t0.o %S/Inputs/type-mapping-bug2.ll
+; RUN: opt -module-summary -o %t1.o %s
+; RUN: llvm-lto2 run -o %t2 %t0.o %t1.o -r %t0.o,c,px -r %t1.o,a,px -r %t1.o,b,px
+;
+; Test for the issue described in https://bugs.llvm.org/show_bug.cgi?id=37684
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; T1 will be linked against T2 because T2 was already loaded in %t0.o due to
+; the declaration for @b being imported due to !13
+%"T1" = type {}
+%"T2" = type {}
+
+define %"T1" @a() {
+ unreachable
+}
+
+define i1 @b(%"T2"*) {
+ unreachable
+}
+
+!llvm.module.flags = !{!0, !1}
+!llvm.dbg.cu = !{!2}
+!0 = !{i32 2, !"Debug Info Version", i32 3}
+!1 = !{i32 1, !"ThinLTO", i32 0}
+!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, retainedTypes: !4)
+!3 = !DIFile(filename: "f1", directory: "")
+!4 = !{!5, !9}
+!5 = !DICompositeType(tag: DW_TAG_class_type, file: !3, templateParams: !6, scope: !8)
+!6 = !{!7}
+
+; The reference to @b and T2 that will be loaded in %t0.o
+
+!7 = !DITemplateValueParameter(value: i1 (%"T2"*)* @b)
+!8 = distinct !DISubprogram(unit: !2)
+
+; This DICompositeType is uniqued against !5 in Inputs/type-mapping-bug2.ll,
+; causing !7 and hence %T2 to be loaded into it's module
+
+!9 = !DICompositeType(tag: DW_TAG_array_type, identifier: "SHARED", scope: !8)
+
diff --git a/llvm/test/ThinLTO/X86/cfi-devirt.ll b/llvm/test/ThinLTO/X86/cfi-devirt.ll
index 2ea6fc4..3fd0486 100644
--- a/llvm/test/ThinLTO/X86/cfi-devirt.ll
+++ b/llvm/test/ThinLTO/X86/cfi-devirt.ll
@@ -20,8 +20,8 @@
; RUN: -r=%t.o,_ZN1B1fEi, \
; RUN: -r=%t.o,_ZN1C1fEi, \
; RUN: -r=%t.o,_ZTV1B,px \
-; RUN: -r=%t.o,_ZTV1C,px 2>&1 | FileCheck %s --check-prefix=REMARK
-; RUN: llvm-dis %t3.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR
+; RUN: -r=%t.o,_ZTV1C,px 2>&1 | FileCheck %s --check-prefix=REMARK -dump-input=always
+; RUN: llvm-dis %t3.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR -dump-input=always
; New PM
; FIXME: Fix machine verifier issues and remove -verify-machineinstrs=0. PR39436.
@@ -39,18 +39,17 @@
; RUN: -r=%t.o,_ZN1B1fEi, \
; RUN: -r=%t.o,_ZN1C1fEi, \
; RUN: -r=%t.o,_ZTV1B,px \
-; RUN: -r=%t.o,_ZTV1C,px 2>&1 | FileCheck %s --check-prefix=REMARK
-; RUN: llvm-dis %t3.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR
+; RUN: -r=%t.o,_ZTV1C,px 2>&1 | FileCheck %s --check-prefix=REMARK -dump-input=always
+; RUN: llvm-dis %t3.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR -dump-input=always
; REMARK: single-impl: devirtualized a call to _ZN1A1nEi
; Next check that we emit an error when trying to LTO link this module
; containing an llvm.type.checked.load (with a split LTO Unit) with one
-; that does not have a split LTO Unit. Use -thinlto-distributed-indexes
-; to ensure it is being caught in the thin link.
+; that does not have a split LTO Unit.
; RUN: opt -thinlto-bc -o %t2.o %S/Inputs/empty.ll
-; RUN: not llvm-lto2 run %t.o %t2.o -thinlto-distributed-indexes \
-; RUN: -verify-machineinstrs=0 \
+; RUN: not llvm-lto2 run %t.o %t2.o -save-temps -pass-remarks=. \
+; RUN: -verify-machineinstrs=0 -thinlto-threads=1 \
; RUN: -o %t3 \
; RUN: -r=%t.o,test,px \
; RUN: -r=%t.o,_ZN1A1nEi,p \
@@ -63,8 +62,8 @@
; RUN: -r=%t.o,_ZN1B1fEi, \
; RUN: -r=%t.o,_ZN1C1fEi, \
; RUN: -r=%t.o,_ZTV1B,px \
-; RUN: -r=%t.o,_ZTV1C,px 2>&1 | FileCheck %s --check-prefix=ERROR
-; ERROR: failed: inconsistent LTO Unit splitting (recompile with -fsplit-lto-unit)
+; RUN: -r=%t.o,_ZTV1C,px 2>&1 | FileCheck %s --check-prefix=ERROR -dump-input=always
+; ERROR: LLVM ERROR: inconsistent LTO Unit splitting with llvm.type.test or llvm.type.checked.load
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-grtev4-linux-gnu"
diff --git a/llvm/test/Transforms/InstCombine/vec_shuffle.ll b/llvm/test/Transforms/InstCombine/vec_shuffle.ll
index 354256a..aae337d 100644
--- a/llvm/test/Transforms/InstCombine/vec_shuffle.ll
+++ b/llvm/test/Transforms/InstCombine/vec_shuffle.ll
@@ -1125,18 +1125,3 @@
ret <2 x float> %r
}
-; Equivalent shuffle masks, but only one is a narrowing op.
-
-define <2 x i1> @PR40734(<1 x i1> %x, <4 x i1> %y) {
-; CHECK-LABEL: @PR40734(
-; CHECK-NEXT: [[WIDEN:%.*]] = shufflevector <1 x i1> zeroinitializer, <1 x i1> [[X:%.*]], <2 x i32> <i32 0, i32 1>
-; CHECK-NEXT: [[NARROW:%.*]] = shufflevector <4 x i1> [[Y:%.*]], <4 x i1> undef, <2 x i32> <i32 0, i32 1>
-; CHECK-NEXT: [[R:%.*]] = and <2 x i1> [[WIDEN]], [[NARROW]]
-; CHECK-NEXT: ret <2 x i1> [[R]]
-;
- %widen = shufflevector <1 x i1> zeroinitializer, <1 x i1> %x, <2 x i32> <i32 0, i32 1>
- %narrow = shufflevector <4 x i1> %y, <4 x i1> undef, <2 x i32> <i32 0, i32 1>
- %r = and <2 x i1> %widen, %narrow
- ret <2 x i1> %r
-}
-
diff --git a/llvm/test/tools/llvm-objcopy/ELF/keep-symbol.test b/llvm/test/tools/llvm-objcopy/ELF/keep-symbol.test
index 67b5187..e4e1888 100644
--- a/llvm/test/tools/llvm-objcopy/ELF/keep-symbol.test
+++ b/llvm/test/tools/llvm-objcopy/ELF/keep-symbol.test
@@ -6,13 +6,6 @@
# RUN: llvm-readobj --symbols %t3 | FileCheck %s
# RUN: llvm-readobj --symbols %t4 | FileCheck %s --check-prefix=REGEX
-# RUN: echo 'foo' > %t.symbols
-# RUN: echo 'bar' >> %t.symbols
-# RUN: llvm-objcopy --discard-all --keep-symbols %t.symbols %t %t5
-# RUN: llvm-objcopy -K foo -N foo -N bar --keep-symbols %t.symbols -N baz %t %t6
-# RUN: llvm-readobj --symbols %t5 | FileCheck %s
-# RUN: llvm-readobj --symbols %t6 | FileCheck %s
-
!ELF
FileHeader:
Class: ELFCLASS64
diff --git a/llvm/tools/llvm-objcopy/CopyConfig.cpp b/llvm/tools/llvm-objcopy/CopyConfig.cpp
index 9cc7bee..811f8b7 100644
--- a/llvm/tools/llvm-objcopy/CopyConfig.cpp
+++ b/llvm/tools/llvm-objcopy/CopyConfig.cpp
@@ -475,9 +475,6 @@
Arg->getValue(), UseRegex);
for (auto Arg : InputArgs.filtered(OBJCOPY_keep_symbol))
Config.SymbolsToKeep.emplace_back(Arg->getValue(), UseRegex);
- for (auto Arg : InputArgs.filtered(OBJCOPY_keep_symbols))
- addSymbolsFromFile(Config.SymbolsToKeep, DC.Alloc, Arg->getValue(),
- UseRegex);
Config.DeterministicArchives = InputArgs.hasFlag(
OBJCOPY_enable_deterministic_archives,
diff --git a/llvm/tools/llvm-objcopy/ObjcopyOpts.td b/llvm/tools/llvm-objcopy/ObjcopyOpts.td
index a4ac320..b317219 100644
--- a/llvm/tools/llvm-objcopy/ObjcopyOpts.td
+++ b/llvm/tools/llvm-objcopy/ObjcopyOpts.td
@@ -205,16 +205,6 @@
defm keep_symbol : Eq<"keep-symbol", "Do not remove symbol <symbol>">,
MetaVarName<"symbol">;
def K : JoinedOrSeparate<["-"], "K">, Alias<keep_symbol>;
-
-defm keep_symbols
- : Eq<"keep-symbols",
- "Reads a list of symbols from <filename> and runs as if "
- "--keep-symbol=<symbol> is set for each one. <filename> "
- "contains one symbol per line and may contain comments beginning with "
- "'#'. Leading and trailing whitespace is stripped from each line. May "
- "be repeated to read symbols from many files.">,
- MetaVarName<"filename">;
-
def only_keep_debug
: Flag<["-", "--"], "only-keep-debug">,
HelpText<"Currently ignored. Only for compatibility with GNU objcopy.">;
diff --git a/llvm/tools/llvm-shlib/CMakeLists.txt b/llvm/tools/llvm-shlib/CMakeLists.txt
index 27f93e0..187066e 100644
--- a/llvm/tools/llvm-shlib/CMakeLists.txt
+++ b/llvm/tools/llvm-shlib/CMakeLists.txt
@@ -55,7 +55,7 @@
# GNU ld doesn't resolve symbols in the version script.
set(LIB_NAMES -Wl,--whole-archive ${LIB_NAMES} -Wl,--no-whole-archive)
- if (NOT LLVM_LINKER_IS_SOLARISLD AND NOT MINGW)
+ if (NOT LLVM_LINKER_IS_SOLARISLD)
# Solaris ld does not accept global: *; so there is no way to version *all* global symbols
set(LIB_NAMES -Wl,--version-script,${LLVM_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map ${LIB_NAMES})
endif()
diff --git a/llvm/utils/gn/build/sync_source_lists_from_cmake.py b/llvm/utils/gn/build/sync_source_lists_from_cmake.py
index 09b2c0d..e580f0d 100755
--- a/llvm/utils/gn/build/sync_source_lists_from_cmake.py
+++ b/llvm/utils/gn/build/sync_source_lists_from_cmake.py
@@ -23,9 +23,9 @@
shell=os.name == 'nt').splitlines()
# Matches e.g. | "foo.cpp",|, captures |foo| in group 1.
- gn_cpp_re = re.compile(r'^\s*"([^"]+\.(?:cpp|c|h|S))",$', re.MULTILINE)
+ gn_cpp_re = re.compile(r'^\s*"([^"]+\.(?:cpp|h))",$', re.MULTILINE)
# Matches e.g. | foo.cpp|, captures |foo| in group 1.
- cmake_cpp_re = re.compile(r'^\s*([A-Za-z_0-9/-]+\.(?:cpp|c|h|S))$',
+ cmake_cpp_re = re.compile(r'^\s*([A-Za-z_0-9/-]+\.(?:cpp|h))$',
re.MULTILINE)
for gn_file in gn_files:
diff --git a/llvm/utils/gn/secondary/BUILD.gn b/llvm/utils/gn/secondary/BUILD.gn
index 9d47316..7509f59 100644
--- a/llvm/utils/gn/secondary/BUILD.gn
+++ b/llvm/utils/gn/secondary/BUILD.gn
@@ -10,9 +10,6 @@
"//lld/test",
"//llvm/test",
]
- if (current_os == "linux") {
- deps += [ "//compiler-rt" ]
- }
if (current_os == "linux" || current_os == "android") {
deps += [ "//compiler-rt/test/hwasan" ]
}
diff --git a/llvm/utils/gn/secondary/compiler-rt/BUILD.gn b/llvm/utils/gn/secondary/compiler-rt/BUILD.gn
deleted file mode 100644
index d2bfd1c..0000000
--- a/llvm/utils/gn/secondary/compiler-rt/BUILD.gn
+++ /dev/null
@@ -1,5 +0,0 @@
-group("compiler-rt") {
- deps = [
- "//compiler-rt/lib(//llvm/utils/gn/build/toolchain:stage2_unix)",
- ]
-}
diff --git a/llvm/utils/gn/secondary/compiler-rt/lib/BUILD.gn b/llvm/utils/gn/secondary/compiler-rt/lib/BUILD.gn
deleted file mode 100644
index 16aa0ec..0000000
--- a/llvm/utils/gn/secondary/compiler-rt/lib/BUILD.gn
+++ /dev/null
@@ -1,5 +0,0 @@
-group("lib") {
- deps = [
- "//compiler-rt/lib/builtins",
- ]
-}
diff --git a/llvm/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn b/llvm/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn
deleted file mode 100644
index b3dbd03..0000000
--- a/llvm/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn
+++ /dev/null
@@ -1,476 +0,0 @@
-import("//compiler-rt/target.gni")
-import("//llvm/utils/gn/build/buildflags.gni")
-
-declare_args() {
- # Skip the atomic builtin (these should normally be provided by a shared library)
- compiler_rt_exclude_atomic_builtin = true
-
- # Compile builtins for baremetal.
- compiler_rt_baremetal_build = false
-}
-
-static_library("builtins") {
- output_dir = crt_current_out_dir
- output_name = "clang_rt.builtins-$crt_current_target"
- complete_static_lib = true
- cflags = [
- "-fPIC",
- "-fno-builtin",
- ]
- if (target_os != "android") {
- cflags += [ "-fvisibility=hidden" ]
- }
- if (!is_debug) {
- cflags += [ "-fomit-frame-pointer" ]
- }
- cflags_c = [ "-std=c11" ]
- configs -= [ "//llvm/utils/gn/build:thin_archive" ]
-
- sources = [
- "absvdi2.c",
- "absvsi2.c",
- "absvti2.c",
- "adddf3.c",
- "addsf3.c",
- "addtf3.c",
- "addvdi3.c",
- "addvsi3.c",
- "addvti3.c",
- "apple_versioning.c",
- "ashldi3.c",
- "ashlti3.c",
- "ashrdi3.c",
- "ashrti3.c",
- "bswapdi2.c",
- "bswapsi2.c",
- "clzdi2.c",
- "clzsi2.c",
- "clzti2.c",
- "cmpdi2.c",
- "cmpti2.c",
- "comparedf2.c",
- "comparesf2.c",
- "ctzdi2.c",
- "ctzsi2.c",
- "ctzti2.c",
- "divdc3.c",
- "divdf3.c",
- "divdi3.c",
- "divmoddi4.c",
- "divmodsi4.c",
- "divsc3.c",
- "divsf3.c",
- "divsi3.c",
- "divtc3.c",
- "divtf3.c",
- "divti3.c",
- "extendhfsf2.c",
- "extendsfdf2.c",
- "ffsdi2.c",
- "ffssi2.c",
- "ffsti2.c",
- "fixdfdi.c",
- "fixdfsi.c",
- "fixdfti.c",
- "fixsfdi.c",
- "fixsfsi.c",
- "fixsfti.c",
- "fixunsdfdi.c",
- "fixunsdfsi.c",
- "fixunsdfti.c",
- "fixunssfdi.c",
- "fixunssfsi.c",
- "fixunssfti.c",
- "floatdidf.c",
- "floatdisf.c",
- "floatsidf.c",
- "floatsisf.c",
- "floattidf.c",
- "floattisf.c",
- "floatundidf.c",
- "floatundisf.c",
- "floatunsidf.c",
- "floatunsisf.c",
- "floatuntidf.c",
- "floatuntisf.c",
- "int_util.c",
- "lshrdi3.c",
- "lshrti3.c",
- "moddi3.c",
- "modsi3.c",
- "modti3.c",
- "muldc3.c",
- "muldf3.c",
- "muldi3.c",
- "mulodi4.c",
- "mulosi4.c",
- "muloti4.c",
- "mulsc3.c",
- "mulsf3.c",
- "multf3.c",
- "multi3.c",
- "mulvdi3.c",
- "mulvsi3.c",
- "mulvti3.c",
- "negdf2.c",
- "negdi2.c",
- "negsf2.c",
- "negti2.c",
- "negvdi2.c",
- "negvsi2.c",
- "negvti2.c",
- "os_version_check.c",
- "paritydi2.c",
- "paritysi2.c",
- "parityti2.c",
- "popcountdi2.c",
- "popcountsi2.c",
- "popcountti2.c",
- "powidf2.c",
- "powisf2.c",
- "powitf2.c",
- "subdf3.c",
- "subsf3.c",
- "subtf3.c",
- "subvdi3.c",
- "subvsi3.c",
- "subvti3.c",
- "trampoline_setup.c",
- "truncdfhf2.c",
- "truncdfsf2.c",
- "truncsfhf2.c",
- "ucmpdi2.c",
- "ucmpti2.c",
- "udivdi3.c",
- "udivmoddi4.c",
- "udivmodsi4.c",
- "udivmodti4.c",
- "udivsi3.c",
- "udivti3.c",
- "umoddi3.c",
- "umodsi3.c",
- "umodti3.c",
-
- # This depends on unwind.h which is present in Clang headers. We should
- # reconsider this if we ever decide to support building builtins with
- # other compilers.
- "gcc_personality_v0.c",
- ]
-
- if (target_os != "fuchsia") {
- sources += [
- "emutls.c ",
- "enable_execute_stack.c",
- "eprintf.c",
- ]
- }
-
- if (target_os != "fuchsia" && !compiler_rt_baremetal_build) {
- sources += [
- "clear_cache.c",
- ]
- }
-
- if (target_os == "mac") {
- sources += [
- "atomic_flag_clear.c",
- "atomic_flag_clear_explicit.c",
- "atomic_flag_test_and_set.c",
- "atomic_flag_test_and_set_explicit.c",
- "atomic_signal_fence.c",
- "atomic_thread_fence.c",
- ]
- }
-
- if (target_cpu == "x86" || target_cpu == "x64") {
- sources += [
- "cpu_model.c",
- "divxc3.c",
- "fixunsxfdi.c",
- "fixunsxfsi.c",
- "fixunsxfti.c",
- "fixxfdi.c",
- "fixxfti.c",
- "floatdixf.c",
- "floattixf.c",
- "floatundixf.c",
- "floatuntixf.c",
- "mulxc3.c",
- "powixf2.c",
- ]
- }
- if (target_os == "x86") {
- sources += [
- "i386/ashldi3.S",
- "i386/ashrdi3.S",
- "i386/divdi3.S",
- "i386/floatdidf.S",
- "i386/floatdisf.S",
- "i386/floatdixf.S",
- "i386/floatundidf.S",
- "i386/floatundisf.S",
- "i386/floatundixf.S",
- "i386/lshrdi3.S",
- "i386/moddi3.S",
- "i386/muldi3.S",
- "i386/udivdi3.S",
- "i386/umoddi3.S",
- ]
- if (target_os == "win") {
- sources += [
- "i386/chkstk.S",
- "i386/chkstk2.S",
- ]
- }
- } else if (target_cpu == "x64") {
- sources += [
- "x86_64/floatdidf.c",
- "x86_64/floatdisf.c",
- "x86_64/floatdixf.c",
- "x86_64/floatundidf.S",
- "x86_64/floatundisf.S",
- "x86_64/floatundixf.S",
- ]
- if (target_os == "win") {
- sources += [
- "x86_64/chkstk.S",
- "x86_64/chkstk2.S",
- ]
- }
- }
-
- if (target_cpu == "arm") {
- sources += [
- "arm/bswapdi2.S",
- "arm/bswapsi2.S",
- "arm/clzdi2.S",
- "arm/clzsi2.S",
- "arm/comparesf2.S",
- "arm/divmodsi4.S",
- "arm/divsi3.S",
- "arm/modsi3.S",
- "arm/sync_fetch_and_add_4.S",
- "arm/sync_fetch_and_add_8.S",
- "arm/sync_fetch_and_and_4.S",
- "arm/sync_fetch_and_and_8.S",
- "arm/sync_fetch_and_max_4.S",
- "arm/sync_fetch_and_max_8.S",
- "arm/sync_fetch_and_min_4.S",
- "arm/sync_fetch_and_min_8.S",
- "arm/sync_fetch_and_nand_4.S",
- "arm/sync_fetch_and_nand_8.S",
- "arm/sync_fetch_and_or_4.S",
- "arm/sync_fetch_and_or_8.S",
- "arm/sync_fetch_and_sub_4.S",
- "arm/sync_fetch_and_sub_8.S",
- "arm/sync_fetch_and_umax_4.S",
- "arm/sync_fetch_and_umax_8.S",
- "arm/sync_fetch_and_umin_4.S",
- "arm/sync_fetch_and_umin_8.S",
- "arm/sync_fetch_and_xor_4.S",
- "arm/sync_fetch_and_xor_8.S",
- "arm/udivmodsi4.S",
- "arm/udivsi3.S",
- "arm/umodsi3.S",
- ]
- if (target_os == "mingw") {
- sources += [
- "arm/aeabi_idivmod.S",
- "arm/aeabi_ldivmod.S",
- "arm/aeabi_uidivmod.S",
- "arm/aeabi_uldivmod.S",
- "arm/chkstk.S",
- "divdi3.c",
- "divmoddi4.c",
- "divmodsi4.c",
- "divsi3.c",
- "emutls.c",
- "fixdfdi.c",
- "fixsfdi.c",
- "fixunsdfdi.c",
- "fixunssfdi.c",
- "floatdidf.c",
- "floatdisf.c",
- "floatundidf.c",
- "floatundisf.c",
- "mingw_fixfloat.c",
- "moddi3.c",
- "udivmoddi4.c",
- "udivmodsi4.c",
- "udivsi3.c",
- "umoddi3.c",
- ]
- }
- }
-
- if (target_cpu == "arm64") {
- sources += [
- "comparetf2.c",
- "extenddftf2.c",
- "extendsftf2.c",
- "fixtfdi.c",
- "fixtfsi.c",
- "fixtfti.c",
- "fixunstfdi.c",
- "fixunstfsi.c",
- "fixunstfti.c",
- "floatditf.c",
- "floatsitf.c",
- "floattitf.c",
- "floatunditf.c",
- "floatunsitf.c",
- "floatuntitf.c",
- "multc3.c",
- "trunctfdf2.c",
- "trunctfsf2.c",
- ]
- if (target_os == "mingw") {
- sources += [
- "aarch64/chkstk.S",
- ]
- }
- }
-
- if (target_cpu == "hexagon") {
- sources += [
- "hexagon/common_entry_exit_abi1.S",
- "hexagon/common_entry_exit_abi2.S",
- "hexagon/common_entry_exit_legacy.S",
- "hexagon/dfaddsub.S",
- "hexagon/dfdiv.S",
- "hexagon/dffma.S",
- "hexagon/dfminmax.S",
- "hexagon/dfmul.S",
- "hexagon/dfsqrt.S",
- "hexagon/divdi3.S",
- "hexagon/divsi3.S",
- "hexagon/fabs_opt.S",
- "hexagon/fastmath2_dlib_asm.S",
- "hexagon/fastmath2_ldlib_asm.S",
- "hexagon/fastmath_dlib_asm.S",
- "hexagon/fma_opt.S",
- "hexagon/fmax_opt.S",
- "hexagon/fmin_opt.S",
- "hexagon/memcpy_forward_vp4cp4n2.S",
- "hexagon/memcpy_likely_aligned.S",
- "hexagon/moddi3.S",
- "hexagon/modsi3.S",
- "hexagon/sfdiv_opt.S",
- "hexagon/sfsqrt_opt.S",
- "hexagon/udivdi3.S",
- "hexagon/udivmoddi4.S",
- "hexagon/udivmodsi4.S",
- "hexagon/udivsi3.S",
- "hexagon/umoddi3.S",
- "hexagon/umodsi3.S",
- ]
- }
-
- if (target_cpu == "ppc64") {
- sources += [
- "ppc/divtc3.c",
- "ppc/fixtfdi.c",
- "ppc/fixunstfdi.c",
- "ppc/fixunstfti.c",
- "ppc/floatditf.c",
- "ppc/floattitf.c",
- "ppc/floatunditf.c",
- "ppc/gcc_qadd.c",
- "ppc/gcc_qdiv.c",
- "ppc/gcc_qmul.c",
- "ppc/gcc_qsub.c",
- "ppc/multc3.c",
- ]
- }
-
- if (target_cpu == "riscv") {
- sources += [
- "riscv/mulsi3.S",
- ]
- }
-
- if (!compiler_rt_exclude_atomic_builtin) {
- sources += [
- "atomic.c",
- ]
- }
-}
-
-# Currently unused but necessary to make the sync_source_lists_from_cmake.py happy.
-source_set("_unused") {
- sources = [
- # Thumb1
- "arm/addsf3.S",
- "arm/comparesf2.S",
- "arm/divsi3.S",
- "arm/udivsi3.S",
-
- # EABI
- "arm/aeabi_cdcmp.S",
- "arm/aeabi_cdcmpeq_check_nan.c",
- "arm/aeabi_cfcmp.S",
- "arm/aeabi_cfcmpeq_check_nan.c",
- "arm/aeabi_dcmp.S",
- "arm/aeabi_div0.c",
- "arm/aeabi_drsub.c",
- "arm/aeabi_fcmp.S",
- "arm/aeabi_frsub.c",
- "arm/aeabi_idivmod.S",
- "arm/aeabi_ldivmod.S",
- "arm/aeabi_memcmp.S",
- "arm/aeabi_memcpy.S",
- "arm/aeabi_memmove.S",
- "arm/aeabi_memset.S",
- "arm/aeabi_uidivmod.S",
- "arm/aeabi_uldivmod.S",
-
- # Thumb1 JT
- "arm/switch16.S",
- "arm/switch32.S",
- "arm/switch8.S",
- "arm/switchu8.S",
-
- # Thumb1 SjLj
- "arm/restore_vfp_d8_d15_regs.S",
- "arm/save_vfp_d8_d15_regs.S",
-
- # Thumb1 VFPv2
- "arm/adddf3vfp.S",
- "arm/addsf3vfp.S",
- "arm/divdf3vfp.S",
- "arm/divsf3vfp.S",
- "arm/eqdf2vfp.S",
- "arm/eqsf2vfp.S",
- "arm/extendsfdf2vfp.S",
- "arm/fixdfsivfp.S",
- "arm/fixsfsivfp.S",
- "arm/fixunsdfsivfp.S",
- "arm/fixunssfsivfp.S",
- "arm/floatsidfvfp.S",
- "arm/floatsisfvfp.S",
- "arm/floatunssidfvfp.S",
- "arm/floatunssisfvfp.S",
- "arm/gedf2vfp.S",
- "arm/gesf2vfp.S",
- "arm/gtdf2vfp.S",
- "arm/gtsf2vfp.S",
- "arm/ledf2vfp.S",
- "arm/lesf2vfp.S",
- "arm/ltdf2vfp.S",
- "arm/ltsf2vfp.S",
- "arm/muldf3vfp.S",
- "arm/mulsf3vfp.S",
- "arm/nedf2vfp.S",
- "arm/negdf2vfp.S",
- "arm/negsf2vfp.S",
- "arm/nesf2vfp.S",
- "arm/subdf3vfp.S",
- "arm/subsf3vfp.S",
- "arm/truncdfsf2vfp.S",
- "arm/unorddf2vfp.S",
- "arm/unordsf2vfp.S",
-
- # Thumb1 icache
- "arm/sync_synchronize.S",
- ]
-}
diff --git a/llvm/utils/gn/secondary/compiler-rt/lib/hwasan/BUILD.gn b/llvm/utils/gn/secondary/compiler-rt/lib/hwasan/BUILD.gn
index f5da8ed..fe5870a 100644
--- a/llvm/utils/gn/secondary/compiler-rt/lib/hwasan/BUILD.gn
+++ b/llvm/utils/gn/secondary/compiler-rt/lib/hwasan/BUILD.gn
@@ -36,28 +36,25 @@
"//compiler-rt/lib/ubsan:sources",
]
sources = [
- "hwasan.cpp",
+ "hwasan.cc",
"hwasan.h",
- "hwasan_allocator.cpp",
+ "hwasan_allocator.cc",
"hwasan_allocator.h",
- "hwasan_dynamic_shadow.cpp",
+ "hwasan_dynamic_shadow.cc",
"hwasan_dynamic_shadow.h",
"hwasan_flags.h",
- "hwasan_interceptors.cpp",
- "hwasan_interceptors_vfork.S",
+ "hwasan_interceptors.cc",
"hwasan_interface_internal.h",
- "hwasan_linux.cpp",
- "hwasan_malloc_bisect.h",
+ "hwasan_linux.cc",
"hwasan_mapping.h",
- "hwasan_memintrinsics.cpp",
- "hwasan_poisoning.cpp",
+ "hwasan_memintrinsics.cc",
+ "hwasan_poisoning.cc",
"hwasan_poisoning.h",
- "hwasan_report.cpp",
+ "hwasan_report.cc",
"hwasan_report.h",
- "hwasan_tag_mismatch_aarch64.S",
- "hwasan_thread.cpp",
+ "hwasan_thread.cc",
"hwasan_thread.h",
- "hwasan_thread_list.cpp",
+ "hwasan_thread_list.cc",
"hwasan_thread_list.h",
]
}
@@ -69,7 +66,7 @@
"//compiler-rt/lib/ubsan:cxx_sources",
]
sources = [
- "hwasan_new_delete.cpp",
+ "hwasan_new_delete.cc",
]
}
diff --git a/llvm/utils/gn/secondary/compiler-rt/lib/sanitizer_common/BUILD.gn b/llvm/utils/gn/secondary/compiler-rt/lib/sanitizer_common/BUILD.gn
index 474c3b6..a712ada 100644
--- a/llvm/utils/gn/secondary/compiler-rt/lib/sanitizer_common/BUILD.gn
+++ b/llvm/utils/gn/secondary/compiler-rt/lib/sanitizer_common/BUILD.gn
@@ -64,7 +64,6 @@
"sanitizer_fuchsia.cc",
"sanitizer_fuchsia.h",
"sanitizer_getauxval.h",
- "sanitizer_hash.h",
"sanitizer_interface_internal.h",
"sanitizer_internal_defs.h",
"sanitizer_lfstack.h",
diff --git a/openmp/runtime/src/CMakeLists.txt b/openmp/runtime/src/CMakeLists.txt
index f046f2f..2646679 100644
--- a/openmp/runtime/src/CMakeLists.txt
+++ b/openmp/runtime/src/CMakeLists.txt
@@ -49,9 +49,6 @@
if(${LIBOMP_USE_HWLOC})
include_directories(${LIBOMP_HWLOC_INSTALL_DIR}/include)
endif()
-if(ANDROID)
- include_directories(${LIBOMP_SRC_DIR}/android)
-endif()
# Getting correct source files to build library
set(LIBOMP_CFILES)
@@ -97,9 +94,6 @@
libomp_append(LIBOMP_CXXFILES kmp_gsupport.cpp)
libomp_append(LIBOMP_ASMFILES z_Linux_asm.S) # Unix assembly file
endif()
- if(ANDROID)
- libomp_append(LIBOMP_CXXFILES android/nltypes_stubs.cpp)
- endif()
libomp_append(LIBOMP_CFILES thirdparty/ittnotify/ittnotify_static.c LIBOMP_USE_ITT_NOTIFY)
libomp_append(LIBOMP_CXXFILES kmp_debugger.cpp LIBOMP_USE_DEBUGGER)
libomp_append(LIBOMP_CXXFILES kmp_stats.cpp LIBOMP_STATS)
diff --git a/openmp/runtime/src/android/nl_types.h b/openmp/runtime/src/android/nl_types.h
deleted file mode 100644
index cc27e93..0000000
--- a/openmp/runtime/src/android/nl_types.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-#ifndef ANDROID_NLTYPES_H
-#define ANDROID_NLTYPES_H
-
-#include_next <nl_types.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-nl_catd catopen(const char*, int);
-char* catgets(nl_catd, int, int, const char*);
-int catclose(nl_catd);
-
-#ifdef __cplusplus
-} // extern "C"
-#endif
-
-#endif /* ANDROID_NLTYPES_H */
diff --git a/openmp/runtime/src/android/nltypes_stubs.cpp b/openmp/runtime/src/android/nltypes_stubs.cpp
deleted file mode 100644
index 2882910..0000000
--- a/openmp/runtime/src/android/nltypes_stubs.cpp
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2019 The Android Open Source Project
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <nl_types.h>
-
-#include <errno.h>
-
-__attribute__((weak,visibility("hidden")))
-nl_catd catopen(const char*, int) {
- return reinterpret_cast<nl_catd>(-1);
-}
-
-__attribute__((weak,visibility("hidden")))
-char* catgets(nl_catd, int, int, const char* message) {
- return const_cast<char*>(message);
-}
-
-__attribute__((weak,visibility("hidden")))
-int catclose(nl_catd) {
- // Since we didn't hand out a valid nl_catd, you can't be returning one to us.
- errno = EBADF;
- return -1;
-}
diff --git a/openmp/runtime/src/z_Linux_util.cpp b/openmp/runtime/src/z_Linux_util.cpp
index c5362e0..08b9742 100644
--- a/openmp/runtime/src/z_Linux_util.cpp
+++ b/openmp/runtime/src/z_Linux_util.cpp
@@ -827,13 +827,6 @@
and also gives the user the stack space they requested for all threads */
stack_size += gtid * __kmp_stkoffset * 2;
-#if defined(__ANDROID__) && __ANDROID_API__ < 19
- // Round the stack size to a multiple of the page size. Older versions of
- // Android (until KitKat) would fail pthread_attr_setstacksize with EINVAL
- // if the stack size was not a multiple of the page size.
- stack_size = (stack_size + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
-#endif
-
KA_TRACE(10, ("__kmp_create_worker: T#%d, default stacksize = %lu bytes, "
"__kmp_stksize = %lu bytes, final stacksize = %lu bytes\n",
gtid, KMP_DEFAULT_STKSIZE, __kmp_stksize, stack_size));
diff --git a/pstl/build/Makefile b/pstl/build/Makefile
new file mode 100644
index 0000000..f4ab25c87
--- /dev/null
+++ b/pstl/build/Makefile
@@ -0,0 +1,101 @@
+#===-- Makefile ----------------------------------------------------------===##
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===----------------------------------------------------------------------===##
+
+#------------------------------------------------------------------------------
+# Define rules for making the Parallel STL library.
+#------------------------------------------------------------------------------
+
+
+proj_root ?= $(CURDIR)/..
+
+include $(proj_root)/build/Makefile.common
+CPLUS := $(compiler) $(COMPILER_NOLOGO_KEY) $(USE_SHARED_CPPRUNTIME_KEY)
+
+.SECONDARY:
+.PHONY: clean clean_all clean_pstl bench
+
+VPATH = $(proj_root)/test
+
+CPLUS_FLAGS += -I$(proj_root)
+
+PSTL_MAKEFILE = $(proj_root)/build/Makefile.pstl
+BENCH_MAKEFILE = $(proj_root)/build/Makefile.bench
+
+
+test_hdr = $(wildcard $(proj_root)/test/*.h)
+test_src = $(wildcard $(proj_root)/test/test_*.cpp)
+test_bin = $(notdir $(test_src:.cpp=.exe))
+
+
+all: $(test_bin)
+
+test_%.offload.exe: test_%.offload$(OBJ_SFX) exception_list.offload$(OBJ_SFX)
+ $(CPLUS) $(CPLUS_FLAGS) $^ $(FKEY)o$@ $(LDFLAGS)
+
+$(PSTL_LIB_NAME):
+ $(MAKE) -f $(PSTL_MAKEFILE) backend=$(backend) cfg=$(cfg)
+
+test_%.exe: test_%$(OBJ_SFX) $(PSTL_LIB_NAME)
+ $(LD) $< $(LD_OUT_KEY)$@ $(LDFLAGS) $(DYN_LDFLAGS) $(PSTL_LIB_LINK)
+
+test_%: test_%.exe
+ $(run_cmd) $(RUN_CMD)test_$*.exe
+
+test_%$(OBJ_SFX): test_%.cpp $(test_hdr) $(proj_root)/build/Makefile
+ $(CPLUS) $(CPLUS_FLAGS) -c $< $(FKEY)o$@
+
+# This definition intentionally consists of two blank lines
+define eol
+
+
+endef
+
+test: $(test_bin)
+ $(foreach test, $(test_bin), $(run_cmd) $(RUN_CMD)$(test) $(args) $(eol))
+
+%.s: %.cpp $(proj_root)/build/Makefile
+ $(CPLUS) $(CPLUS_FLAGS) -S $< $(FKEY)o$@
+
+%.E: %.cpp
+ $(CPLUS) $(CPLUS_FLAGS) -E $< >$@
+
+TEMPLATE_FILES=$(wildcard $(proj_root)/bench/*.*tmpl)
+BENCH_COMMON_FILES=$(wildcard $(proj_root)/bench/*.h) $(wildcard $(proj_root)/bench/*.cpp)
+
+$(BENCH_MAKEFILE): $(proj_root)/bench/algorithm.json $(proj_root)/bench/gen.py $(TEMPLATE_FILES)
+ $(PYTHON) $(proj_root)/bench/gen.py $(proj_root)/bench/algorithm.json
+
+bench : $(BENCH_MAKEFILE) $(BENCH_COMMON_FILES) $(PSTL_LIB_NAME)
+ @echo TEMPLATE_FILES=$(TEMPLATE_FILES)
+ @echo proj_root=$(proj_root)
+ ls -la $(proj_root)/bench/gen.py
+ $(MAKE) -f $(BENCH_MAKEFILE)
+
+clean_bench:
+ $(DEL_CMD) $(BENCH_MAKEFILE)
+ $(DEL_CMD) batch.py
+ $(DEL_CMD) $(proj_root)/build/bench/*.*
+
+clean:
+ $(DEL_CMD) *$(OBJ_SFX) *.exe *.E *.s *.asm *.d *.pdb *.pdb *.suo *.ilk
+
+clean_pstl:
+ $(MAKE) -f $(PSTL_MAKEFILE) clean
+
+clean_all: clean clean_pstl clean_bench
+
+info:
+ @echo OS = $(os_name)
+ @echo proj_root = "$(proj_root)"
+ @echo $(CURDIR)
+ @echo VPATH = $(VPATH)
+ @echo LIBRARY_PATH = $(LIBRARY_PATH)
+ @echo backend = $(backend)
+ @echo compiler = $(compiler)
+
+-include *.d
diff --git a/pstl/build/Makefile.common b/pstl/build/Makefile.common
new file mode 100644
index 0000000..66a41d7
--- /dev/null
+++ b/pstl/build/Makefile.common
@@ -0,0 +1,112 @@
+#===-- Makefile.common ---------------------------------------------------===##
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===----------------------------------------------------------------------===##
+
+#------------------------------------------------------------------------------
+# Define common parts for Parallel STL
+#------------------------------------------------------------------------------
+
+.SUFFIXES:
+
+goals = $(or $(MAKECMDGOALS),all)
+ifneq (, $(filter-out clean clean_all,$(goals)))
+ ifeq (, $(filter $(backend), tbb))
+ $(info Threading backend was not specified; using TBB)
+ backend=tbb
+ endif
+endif
+
+ifndef os_name
+ # Windows sets environment variable OS; for other systems, ask uname
+ ifeq ($(OS),)
+ OS:=$(shell uname)
+ ifeq ($(OS),)
+ $(error "Cannot detect operating system")
+ endif
+ os_name=$(OS)
+ endif
+
+ ifeq ($(OS), Windows_NT)
+ os_name=windows
+ endif
+ ifeq ($(OS), Linux)
+ os_name=linux
+ endif
+ ifeq ($(OS), Darwin)
+ os_name=macos
+ endif
+endif # !os_name
+
+cfg ?= release
+stdver ?= c++11
+
+override INCLUDES += -I$(proj_root)/include -I$(proj_root)/test
+
+TEST_MACRO += -D__PSTL_TEST_SUCCESSFUL_KEYWORD=1
+
+ifeq ($(backend), tbb)
+ BACKEND_MACRO += -D__PSTL_PAR_BACKEND_TBB
+endif
+
+target ?= $(os_name)
+#OS specific keys
+ifeq ($(target),windows)
+ ifneq (, $(filter $(compiler), gcc g++))
+ include $(proj_root)/build/mingw.inc
+ else
+ include $(proj_root)/build/windows.inc
+ endif
+else
+ include $(proj_root)/build/unix.inc
+ ifneq (,$(wildcard $(proj_root)/build/$(target).inc))
+ include $(proj_root)/build/$(target).inc
+ $(info included additional file $(proj_root)/build/$(target).inc)
+ endif
+endif
+
+# compiler specific keys
+ifneq (, $(filter $(compiler), gcc g++))
+ include $(proj_root)/build/gcc.inc
+endif
+
+ifneq (, $(filter $(compiler), clang clang++))
+ include $(proj_root)/build/clang.inc
+endif
+
+ifneq (, $(filter $(compiler), icc icpc icx))
+ include $(proj_root)/build/icc.inc
+endif
+
+ifneq (, $(filter $(compiler), icl))
+ include $(proj_root)/build/icl.inc
+endif
+
+
+OPTIMIZATION_ENABLED_FLAGS += $(XHOST_FLAG)
+OPTIMIZATION_DISABLED_FLAGS += $(XHOST_FLAG)
+
+
+ifeq ($(cfg), debug)
+ TBB_LIB_NAME = tbb_debug
+ BACKEND_MACRO += -DTBB_USE_DEBUG=1
+ DEBUG_MACRO += -DPSTL_USE_DEBUG
+ OPTIMIZATION_KEYS = $(OPTIMIZATION_DISABLED_FLAGS)
+else
+ OPTIMIZATION_KEYS = $(OPTIMIZATION_ENABLED_FLAGS)
+endif
+
+DYN_LDFLAGS += $(PSTL_ARCH)
+
+CPLUS_FLAGS += $(TEST_MACRO)
+CPLUS_FLAGS += $(INCLUDES)
+CPLUS_FLAGS += $(BACKEND_MACRO)
+CPLUS_FLAGS += $(DEBUG_MACRO)
+CPLUS_FLAGS += $(CXXFLAGS)
+CPLUS_FLAGS += $(OPTIMIZATION_KEYS)
+
+CPLUS_FLAGS += $(DISABLED_WARNINGS)
+CPLUS_FLAGS += $(PSTL_ARCH)
diff --git a/pstl/build/Makefile.pstl b/pstl/build/Makefile.pstl
new file mode 100644
index 0000000..83c61d2
--- /dev/null
+++ b/pstl/build/Makefile.pstl
@@ -0,0 +1,46 @@
+#===-- Makefile.pstl -----------------------------------------------------===##
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===----------------------------------------------------------------------===##
+
+#------------------------------------------------------------------------------
+# Define rules for making the Parallel STL library.
+#------------------------------------------------------------------------------
+
+proj_root ?= $(CURDIR)/..
+
+include $(proj_root)/build/Makefile.common
+
+.PHONY: clean
+
+VPATH = $(proj_root)/src
+
+lib_src = $(wildcard $(proj_root)/src/*.cpp)
+lib_obj = $(notdir $(lib_src:.cpp=$(OBJ_SFX)))
+
+all: pstl
+
+pstl: $(PSTL_LIB_NAME)
+
+%$(OBJ_SFX): %.cpp $(proj_root)/build/Makefile.pstl
+ $(CPLUS) $(CPLUS_FLAGS) -c $< $(FKEY)o$@
+
+%.s: %.cpp $(proj_root)/build/Makefile
+ $(CPLUS) $(CPLUS_FLAGS) -S $< $(FKEY)o$@
+
+%.E: %.cpp
+ $(CPLUS) $(CPLUS_FLAGS) -E $< >$@
+
+clean:
+ $(DEL_CMD) *$(OBJ_SFX) *.lib *.dll *.so *.exp *$(PSTL_LIB_NAME)*
+
+info:
+ @echo OS = $(os_name)
+ @echo proj_root = "$(proj_root)"
+ @echo $(CURDIR)
+ @echo VPATH=$(VPATH)
+
+-include *.d
diff --git a/pstl/build/android.inc b/pstl/build/android.inc
new file mode 100644
index 0000000..4b0e231
--- /dev/null
+++ b/pstl/build/android.inc
@@ -0,0 +1,47 @@
+#===-- android.inc -------------------------------------------------------===##
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===----------------------------------------------------------------------===##
+
+PSTL_ARCH=
+PIE_FLAGS = -pie -fPIE -fPIC
+SDL_FLAGS = -fstack-protector -Wformat -Wformat-security
+CPLUS_FLAGS += $(TARGET_CFLAGS) $(PIE_FLAGS) $(SDL_FLAGS)
+
+# Paths to the NDK prebuilt tools and libraries
+ifeq (,$(findstring $(ndk_version), $(foreach v, 7 8 9 10 11 12 13 14 15,r$(v) r$(v)b r$(v)c r$(v)d r$(v)e)))
+ ifeq (clang,$(compiler))
+ # Since Android* NDK r16 another sysroot and isystem paths have to be specified
+ CPLUS_FLAGS += --sysroot=$(NDK_ROOT)/sysroot -isystem $(NDK_ROOT)/sysroot/usr/include/$(TRIPLE)
+ # Android* version flag required since r16
+ CPLUS_FLAGS += -D__ANDROID_API__=$(API_LEVEL)
+ else
+ CPLUS_FLAGS += --sysroot=$(SYSROOT)
+ endif
+else
+ CPLUS_FLAGS += --sysroot=$(SYSROOT)
+endif
+
+LDFLAGS += --sysroot=$(SYSROOT) $(TARGET_CFLAGS)
+PSTL_LIB_LINK += -lc++abi -L$(CPLUS_LIB_PATH) -lc++_shared
+
+ifeq (arm,$(arch))
+ PSTL_LIB_LINK += -lunwind
+endif
+
+# TARGET_CXX cames from NDK
+override CPLUS:=$(TARGET_CXX) $(USE_SHARED_CPPRUNTIME_KEY)
+LD = $(CPLUS) $(TARGET_CFLAGS) $(PIE_FLAGS) $(SDL_FLAGS)
+
+run_cmd ?= -sh $(proj_root)/build/android.linux.launcher.sh $(largs)
+
+# TBB_LIBRARIES := $(foreach dir,$(LIBRARY_PATH),$(wildcard $(dir)/libtbb*so))
+TBB_LIBRARIES := $(foreach dir,$(LIBRARY_PATH),$(wildcard $(dir)/*))
+LIB_STL_ANDROID += $(TBB_LIBRARIES)
+
+$(warning LIB_STL_ANDROID=$(LIB_STL_ANDROID))
+$(warning TBB_LIBRARIES=$(TBB_LIBRARIES))
+$(warning LIBRARY_PATH=$(LIBRARY_PATH))
diff --git a/pstl/build/android.linux.launcher.sh b/pstl/build/android.linux.launcher.sh
new file mode 100644
index 0000000..69ad500
--- /dev/null
+++ b/pstl/build/android.linux.launcher.sh
@@ -0,0 +1,148 @@
+#!/bin/sh
+#===-- android.linux.launcher.sh -----------------------------------------===##
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===----------------------------------------------------------------------===##
+#
+#
+
+# Usage:
+# android.linux.launcher.sh [-v] [-q] [-s] [-r <repeats>] [-u] [-l <library>] <executable> <arg1> <arg2> <argN>
+# where: -v enables verbose output
+# where: -q enables quiet mode
+# where: -s runs the test in stress mode (until non-zero exit code or ctrl-c pressed)
+# where: -r <repeats> specifies number of times to repeat execution
+# where: -u is ignored on Android
+# where: -l <library> specifies the library name to be assigned to LD_PRELOAD
+#
+# Libs and executable necessary for testing should be present in the current directory before running.
+# ANDROID_SERIAL must be set to the connected Android target device name for file transfer and test runs.
+# ANDROID_TEST_DIRECTORY may be set to the directory used for testing on the Android target device; otherwise,
+# the default directory used is "/data/local/tmp/$(basename $PWD)".
+# Note: Do not remove the redirections to '/dev/null' in the script, otherwise the nightly test system will fail.
+
+do_cleanup() #
+{ #
+ adb pull $targetdir/events.txt events.txt > /dev/null 2>&1 #
+ # Remove target directory on the device
+ adb shell "rm -r ${targetdir}; mkdir -p ${targetdir}" > /dev/null 2>&1 #
+} #
+do_trap_cleanup() #
+{ #
+ do_cleanup #
+ exit -1 #
+} #
+while getopts "qvsr:ul:" flag #
+do case $flag in #
+ s ) # Stress testing mode
+ echo Doing stress testing. Press Ctrl-C to terminate
+ run_env='stressed() { while $*; do :; done; }; ' #
+ run_prefix="stressed $run_prefix" ;; #
+ r ) # Repeats test n times
+ run_env="repeated() { for i in $(seq -s ' ' 1 $OPTARG) ; do echo \$i of $OPTARG:; \$*; done; }; " #
+ run_prefix="repeated $run_prefix" ;; #
+ l ) # Additional library
+ ldpreload="$OPTARG " ;; #
+ u ) # Stack limit
+ ;; #
+ q ) # Quiet mode, removes 'done' but prepends any other output by test name
+ OUTPUT='2>&1 | sed -e "s/done//;/^[[:space:]]*$/d;s!^!$exename: !"' ;; #
+ v ) # Verbose mode
+ SUPPRESS='' #
+ verbose=1 ;; #
+esac done #
+shift `expr $OPTIND - 1` #
+[ -z "$OUTPUT" ] && OUTPUT='| sed -e "s/\\r$//"' #
+[ $verbose ] || SUPPRESS='>/dev/null' #
+# Collect the executable name
+exename=$(basename $1) #
+shift #
+
+# Prepare the target directory on the device
+currentdir=$(basename $PWD) #
+targetdir=${ANDROID_TEST_DIRECTORY:-/data/local/tmp/$currentdir} #
+do_cleanup #
+trap do_trap_cleanup INT # if someone hits control-c, cleanup the device
+
+# Collect the list of files to transfer to the target device, starting with executable itself.
+fnamelist="$exename" #
+# Add the C++ standard library from the NDK, which is required for all tests on Android.
+if [ ! -z "${LIB_STL_ANDROID}" ]; then #
+ fnamelist="$fnamelist ${LIB_STL_ANDROID}" #
+else #
+ fnamelist="$fnamelist libc++_shared.so" #
+fi #
+
+# Find the TBB libraries and add them to the list.
+
+OLD_SEP=$IFS
+IFS=':'
+for dir in $LD_LIBRARY_PATH; do #
+ found="`ls $dir/lib*.so 2>/dev/null` "||: #
+ fnamelist+="$fnamelist $found"
+done #
+IFS=$OLD_SEP
+
+files="$(ls libtbb* 2> /dev/null)" #
+[ -z "$files" ] || fnamelist="$fnamelist $files" #
+
+# Add any libraries built for specific tests.
+exeroot=${exename%\.*} #
+files="$(ls ${exeroot}*.so ${exeroot}*.so.* 2> /dev/null)" #
+[ -z "$files" ] || fnamelist="$fnamelist $files" #
+
+# Transfer collected executable and library files to the target device.
+transfers_ok=1 #
+for fullname in $fnamelist; do { #
+ if [ -r $fullname ]; then { #
+ # Transfer the executable and libraries to top-level target directory
+ if [ "$OS" = 'Windows_NT' ]; then #
+ fullname=`cygpath -m "$fullname"` #
+ fi #
+ [ $verbose ] && echo -n "Pushing $fullname: " #
+ eval "adb push $fullname ${targetdir}/$(basename $fullname) $SUPPRESS 2>&1" #
+ }; else { #
+ echo "Error: required file ${currentdir}/${fullname} for test $exename not available for transfer." #
+ transfers_ok=0 #
+ }; fi #
+}; done #
+if [ "${transfers_ok}" = "0" ]; then { #
+ do_cleanup #
+ exit -1 #
+}; fi #
+# Transfer input files used by example codes by scanning the executable argument list.
+for fullname in "$@"; do { #
+ if [ -r $fullname ]; then { #
+ directory=$(dirname $fullname) #
+ filename=$(basename $fullname) #
+ # strip leading "." from fullname if present
+ if [ "$directory" = "\." ]; then { #
+ directory="" #
+ fullname=$filename #
+ }; fi #
+ # Create the target directory to hold input file if necessary
+ if [ ! -z $directory ]; then { #
+ eval "adb shell 'mkdir $directory' $SUPPRESS 2>&1" #
+ }; fi #
+ # Transfer the input file to corresponding directory on target device
+ [ $verbose ] && echo -n "Pushing $fullname: " #
+ eval "adb push $fullname ${targetdir}/$fullname $SUPPRESS 2>&1" #
+ }; fi #
+}; done #
+
+# Set LD_PRELOAD if necessary
+[ -z "$ldpreload" ] || run_prefix="LD_PRELOAD='$ldpreload' $run_prefix" #
+[ $verbose ] && echo Running $run_prefix ./$exename $* #
+run_env="$run_env cd $targetdir; export LD_LIBRARY_PATH=." #
+[ -z "$VIRTUAL_MACHINE" ] || run_env="$run_env; export VIRTUAL_MACHINE=$VIRTUAL_MACHINE" #
+# The return_code file is the best way found to return the status of the test execution when using adb shell.
+eval 'adb shell "$run_env; $run_prefix ./$exename $* || echo -n \$? >error_code"' "${OUTPUT}" #
+# Capture the return code string and remove the trailing \r from the return_code file contents
+err=`adb shell "cat $targetdir/error_code 2>/dev/null"` #
+[ -z $err ] || echo $exename: exited with error $err #
+do_cleanup #
+# Return the exit code of the test.
+exit $err #
diff --git a/pstl/build/clang.inc b/pstl/build/clang.inc
new file mode 100644
index 0000000..3a06f4f
--- /dev/null
+++ b/pstl/build/clang.inc
@@ -0,0 +1,21 @@
+#===-- clang.inc ---------------------------------------------------------===##
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===----------------------------------------------------------------------===##
+
+override compiler:=clang++
+
+ifneq ($(target),android)
+ PSTL_ARCH += $(KEY)march=native
+endif
+
+XHOST_FLAG = -fno-vectorize
+CPLUS_FLAGS += $(FQKEY)std=$(stdver)
+# XHOST_FLAG = $(KEY)mavx2 -fno-vectorize
+# XHOST_FLAG = $(KEY)mavx512f -fno-vectorize
+# DYN_LDFLAGS += $(LINK_KEY)c++
+# CPLUS_FLAGS += -stdlib=libc++
+# CPLUS_FLAGS += -fopenmp-simd //it will be supported in he future version
diff --git a/pstl/build/gcc.inc b/pstl/build/gcc.inc
new file mode 100644
index 0000000..a5c61b5
--- /dev/null
+++ b/pstl/build/gcc.inc
@@ -0,0 +1,27 @@
+#===-- gcc.inc -----------------------------------------------------------===##
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===----------------------------------------------------------------------===##
+
+override compiler:=g++
+XHOST_FLAG = $(KEY)march=native -fno-tree-vectorize
+# XHOST_FLAG = $(KEY)mavx2 -fno-tree-vectorize
+# XHOST_FLAG = $(KEY)mavx512f -fno-tree-vectorize
+ DYN_LDFLAGS += $(LINK_KEY)stdc++
+# GCC 4.8.5 and early doesn't support -fopenmp-simd; GCC 4.9 supports OpenMP 4.0 for C/C++
+ifneq (, $(shell gcc -dumpversion | egrep "^4\.9\.[0-9]"))
+ CPLUS_FLAGS += -fopenmp-simd
+endif
+ifneq (, $(shell gcc -dumpversion | egrep "^[5-9]\.[0-9]\.[0-9]"))
+ CPLUS_FLAGS += -fopenmp-simd
+# CPLUS_FLAGS += -fdump-rtl-loop2 #use this option to enable optimization report
+endif
+
+CPLUS_FLAGS += $(FQKEY)std=$(stdver)
+
+ifeq ($(os_name),windows)
+DISABLED_WARNINGS = $(KEY)Wno-attributes #disable MinGW warnings about extended alignment
+endif
diff --git a/pstl/build/icc.inc b/pstl/build/icc.inc
new file mode 100644
index 0000000..d666e5c
--- /dev/null
+++ b/pstl/build/icc.inc
@@ -0,0 +1,23 @@
+#===-- icc.inc -----------------------------------------------------------===##
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===----------------------------------------------------------------------===##
+
+vecreport ?= 0 #may be set to [0..7], see https://software.intel.com/en-us/node/522949 for details
+
+XHOST_FLAG = $(KEY)xHOST -no-vec
+CPLUS_FLAGS += $(QKEY)opt-assume-safe-padding
+
+# XHOST_FLAG = $(KEY)xCORE-AVX2 -no-vec
+# XHOST_FLAG = $(KEY)xSSE4.1 -no-vec
+# XHOST_FLAG = $(KEY)xMIC-AVX512 -no-vec
+
+CPLUS_FLAGS += $(QKEY)openmp-simd
+CPLUS_FLAGS += $(FQKEY)MMD
+CPLUS_FLAGS += $(FQKEY)std=$(stdver)
+CPLUS_FLAGS += $(QKEY)opt-report=$(vecreport) $(QKEY)opt-report-phase vec
+
+OPTIMIZATION_DISABLED_FLAGS += $(KEY)debug inline-debug-info
diff --git a/pstl/build/icl.inc b/pstl/build/icl.inc
new file mode 100644
index 0000000..52fb6eb
--- /dev/null
+++ b/pstl/build/icl.inc
@@ -0,0 +1,22 @@
+#===-- icl.inc -----------------------------------------------------------===##
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===----------------------------------------------------------------------===##
+
+vecreport ?= 0 #may be set to [0..7], see https://software.intel.com/en-us/node/522949 for details
+
+XHOST_FLAG = $(QKEY)xHOST
+XHOST_FLAG = $(QKEY)vec-
+# XHOST_FLAG = $(QKEY)xCORE-AVX2
+# XHOST_FLAG = $(QKEY)xSSE4.1
+# XHOST_FLAG = $(QKEY)xMIC-AVX512
+CPLUS_FLAGS += $(QKEY)opt-assume-safe-padding
+CPLUS_FLAGS += $(QKEY)openmp-simd
+CPLUS_FLAGS += $(FQKEY)MMD
+CPLUS_FLAGS += $(FQKEY)std=$(stdver)
+CPLUS_FLAGS += $(QKEY)opt-report:$(vecreport) $(QKEY)opt-report-phase:vec $(QKEY)opt-report-phase:loop
+
+DISABLED_WARNINGS = $(QKEY)diag-disable:2586 #use comma-separated values to specify multiple entries
diff --git a/pstl/build/jni/Android.mk b/pstl/build/jni/Android.mk
new file mode 100644
index 0000000..86c6650
--- /dev/null
+++ b/pstl/build/jni/Android.mk
@@ -0,0 +1,53 @@
+#===-- Android.mk --------------------------------------------------------===##
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===----------------------------------------------------------------------===##
+
+export proj_root?=$(NDK_PROJECT_PATH)/..
+
+ifeq (armeabi-v7a,$(APP_ABI))
+ export SYSROOT:=$(NDK_ROOT)/platforms/$(APP_PLATFORM)/arch-arm
+else ifeq (arm64-v8a,$(APP_ABI))
+ export SYSROOT:=$(NDK_ROOT)/platforms/$(APP_PLATFORM)/arch-arm64
+else
+ export SYSROOT:=$(NDK_ROOT)/platforms/$(APP_PLATFORM)/arch-$(APP_ABI)
+endif
+
+ifeq (windows,$(os_name))
+ export CPATH_SEPARATOR :=;
+else
+ export CPATH_SEPARATOR :=:
+endif
+
+export ANDROID_NDK_ROOT:=$(NDK_ROOT)
+export ndk_version:=$(lastword $(subst -, ,$(ANDROID_NDK_ROOT)))
+ndk_version:= $(firstword $(subst /, ,$(ndk_version)))
+ndk_version:= $(firstword $(subst \, ,$(ndk_version)))
+
+ifeq (clang,$(compiler))
+ # "TBB_RTL :=llvm-libc++/libcxx" should be used for ndk_version r13 r13b r14.
+ TBB_RTL :=llvm-libc++
+ TBB_RTL_LIB :=llvm-libc++
+ TBB_RTL_FILE :=libc++_shared.so
+else
+ TBB_RTL :=gnu-libstdc++/$(NDK_TOOLCHAIN_VERSION)
+ TBB_RTL_LIB :=$(TBB_RTL)
+ TBB_RTL_FILE :=libgnustl_shared.so
+endif
+
+export CPATH := $(INCLUDE)$(CPATH_SEPARATOR)$(SYSROOT)/usr/include$(CPATH_SEPARATOR)$(NDK_ROOT)/sources/cxx-stl/$(TBB_RTL)/include$(CPATH_SEPARATOR)$(NDK_ROOT)/sources/cxx-stl/$(TBB_RTL)/libs/$(APP_ABI)/include$(CPATH_SEPARATOR)$(NDK_ROOT)/sources/android/support/include
+
+LIB_STL_ANDROID_DIR := $(NDK_ROOT)/sources/cxx-stl/$(TBB_RTL_LIB)/libs/$(APP_ABI)
+#LIB_STL_ANDROID is required to be set up for copying Android specific library to a device next to test
+export LIB_STL_ANDROID := $(LIB_STL_ANDROID_DIR)/$(TBB_RTL_FILE)
+export CPLUS_LIB_PATH := $(SYSROOT)/usr/lib -L$(LIB_STL_ANDROID_DIR)
+export target_os_version:=$(APP_PLATFORM)
+export tbb_tool_prefix:=$(TOOLCHAIN_PREFIX)
+export TARGET_CXX
+export TARGET_CC
+export TARGET_CFLAGS
+
+include $(proj_root)/build/Makefile
diff --git a/pstl/build/jni/Application.mk b/pstl/build/jni/Application.mk
new file mode 100644
index 0000000..66ebc5c
--- /dev/null
+++ b/pstl/build/jni/Application.mk
@@ -0,0 +1,60 @@
+#===-- Application.mk ----------------------------------------------------===##
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===----------------------------------------------------------------------===##
+
+
+ifndef os_name
+ # Windows sets environment variable OS; for other systems, ask uname
+ ifeq ($(OS),)
+ OS:=$(shell uname)
+ ifeq ($(OS),)
+ $(error "Cannot detect operating system")
+ endif
+ export os_name=$(OS)
+ endif
+
+ ifeq ($(OS), Windows_NT)
+ export os_name=windows
+ endif
+ ifeq ($(OS), Linux)
+ export os_name=linux
+ endif
+ ifeq ($(OS), Darwin)
+ export os_name=macos
+ endif
+endif
+
+export compiler?=clang
+export arch?=ia32
+export target?=android
+
+ifeq (ia32,$(arch))
+ APP_ABI:=x86
+ export TRIPLE:=i686-linux-android
+else ifeq (intel64,$(arch))
+ APP_ABI:=x86_64
+ export TRIPLE:=x86_64-linux-android
+else ifeq (arm,$(arch))
+ APP_ABI:=armeabi-v7a
+ export TRIPLE:=arm-linux-androideabi
+else ifeq (arm64,$(arch))
+ APP_ABI:=arm64-v8a
+ export TRIPLE:=aarch64-linux-android
+else
+ APP_ABI:=$(arch)
+endif
+
+api_version?=21
+export API_LEVEL:=$(api_version)
+APP_PLATFORM:=android-$(api_version)
+
+ifeq (clang,$(compiler))
+ NDK_TOOLCHAIN_VERSION:=clang
+ APP_STL:=c++_shared
+else
+ NDK_TOOLCHAIN_VERSION:=4.9
+endif
diff --git a/pstl/build/macos.inc b/pstl/build/macos.inc
new file mode 100644
index 0000000..8e3e4fa
--- /dev/null
+++ b/pstl/build/macos.inc
@@ -0,0 +1,9 @@
+#===-- macos.inc ---------------------------------------------------------===##
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===----------------------------------------------------------------------===##
+
+DYN_LDFLAGS += -Wl,-rpath,$(TBBROOT)/lib
diff --git a/pstl/build/mingw.inc b/pstl/build/mingw.inc
new file mode 100644
index 0000000..f0b3acc
--- /dev/null
+++ b/pstl/build/mingw.inc
@@ -0,0 +1,49 @@
+#===-- mingw.inc ---------------------------------------------------------===##
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===----------------------------------------------------------------------===##
+
+PYTHON = python
+KEY = -
+QKEY = $(KEY)q
+FKEY = $(KEY)
+FQKEY = $(KEY)
+MACHINE_KEY = $(KEY)m
+OBJ_SFX = .o
+DEL_CMD = del /F
+RUN_CMD =
+COMMAND_SEPARATOR = &
+compiler ?= gcc
+COMPILER_NOLOGO_KEY =
+OPTIMIZATION_DISABLED_FLAGS = $(KEY)Og $(KEY)g
+OPTIMIZATION_ENABLED_FLAGS += $(KEY)O2
+TBB_LIB_NAME = tbb
+CPLUS = $(compiler)
+LD = $(CPLUS)
+
+USE_SHARED_CPPRUNTIME_KEY =
+LINK_KEY = $(KEY)l
+
+LD_OUT_KEY = $(KEY)o
+DYN_LDFLAGS += -L. -L$(proj_root)/build
+
+ifneq ($(PSTL_LIB_NAME), )
+ PSTL_LIB_LINK += $(LINK_KEY)$(PSTL_LIB_NAME)$(PSTL_LIB_EXT)
+endif
+
+ifeq ($(backend),tbb)
+ DYN_LDFLAGS += $(LINK_KEY)$(TBB_LIB_NAME)
+endif
+
+ifeq ($(arch),intel64)
+ PSTL_ARCH = $(MACHINE_KEY)64
+else ifeq ($(arch),ia32)
+ PSTL_ARCH = $(MACHINE_KEY)32
+else ifeq ($(arch),)
+ $(info arch=native by default)
+else
+ PSTL_ARCH = $(MACHINE_KEY)$(arch)
+endif
diff --git a/pstl/build/unix.inc b/pstl/build/unix.inc
new file mode 100644
index 0000000..13e1a23
--- /dev/null
+++ b/pstl/build/unix.inc
@@ -0,0 +1,50 @@
+#===-- unix.inc ----------------------------------------------------------===##
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===----------------------------------------------------------------------===##
+
+PYTHON = python
+KEY = -
+QKEY = $(KEY)q
+FKEY = $(KEY)
+FQKEY = $(KEY)
+MACHINE_KEY = $(KEY)m
+OBJ_SFX = .o
+DEL_CMD = rm $(KEY)f
+RUN_CMD = ./
+COMMAND_SEPARATOR = ;
+compiler ?= icc
+COMPILER_NOLOGO_KEY =
+OPTIMIZATION_DISABLED_FLAGS = $(KEY)O0 $(KEY)g
+OPTIMIZATION_ENABLED_FLAGS += $(KEY)O2
+TBB_LIB_NAME = tbb
+CPLUS = $(compiler)
+LD = $(CPLUS)
+
+USE_SHARED_CPPRUNTIME_KEY =
+LINK_KEY = $(KEY)l
+
+LD_OUT_KEY = $(KEY)o
+DYN_LDFLAGS += -L. -L$(proj_root)/build
+
+ifneq ($(PSTL_LIB_NAME), )
+ PSTL_LIB_LINK += $(LINK_KEY)$(PSTL_LIB_NAME)$(PSTL_LIB_EXT)
+endif
+
+ifeq ($(backend), tbb)
+ DYN_LDFLAGS += $(LINK_KEY)$(TBB_LIB_NAME)
+endif
+
+
+ifeq ($(arch),intel64)
+ PSTL_ARCH = $(MACHINE_KEY)64
+else ifeq ($(arch),ia32)
+ PSTL_ARCH = $(MACHINE_KEY)32
+else ifeq ($(arch),)
+ $(info arch=native by default)
+else
+ PSTL_ARCH = $(MACHINE_KEY)$(arch)
+endif
diff --git a/pstl/build/windows.inc b/pstl/build/windows.inc
new file mode 100644
index 0000000..1c6641b
--- /dev/null
+++ b/pstl/build/windows.inc
@@ -0,0 +1,53 @@
+#===-- windows.inc -------------------------------------------------------===##
+#
+# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# See https://llvm.org/LICENSE.txt for license information.
+# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+#
+#===----------------------------------------------------------------------===##
+
+PYTHON = python
+compiler ?= icl
+LD = LINK
+KEY = /
+LINK_KEY =
+QKEY = $(KEY)Q
+FKEY = $(KEY)F
+FQKEY = $(QKEY)
+MACHINE_KEY = $(QKEY)
+OBJ_SFX = .obj
+DEL_CMD = del $(KEY)F
+RUN_CMD =
+COMMAND_SEPARATOR = &
+COMPILER_NOLOGO_KEY = $(KEY)nologo
+OPTIMIZATION_DISABLED_FLAGS = $(KEY)Od $(KEY)Zi $(KEY)DEBUG $(KEY)Fd"$*.pdb"
+OPTIMIZATION_ENABLED_FLAGS = $(KEY)O2 $(KEY)DNDEBUG
+LD_OUT_KEY = $(KEY)OUT:
+
+ifneq ($(PSTL_LIB_NAME), )
+ PSTL_LIB_EXT = .lib
+ PSTL_LIB_LINK += $(LINK_KEY)$(PSTL_LIB_NAME)$(PSTL_LIB_EXT)
+endif
+# Do not update LDFLAGS with corresponding TBB_LIB_NAME here, because of
+# implicit linkage capability of TBB library
+
+ifeq ($(cfg),debug)
+ LINK_KEY += $(KEY)debug
+ USE_SHARED_CPPRUNTIME_KEY += $(KEY)MDd $(KEY)EHsc
+ BACKEND_MACRO += -DTBB_USE_DEBUG=1
+else
+ USE_SHARED_CPPRUNTIME_KEY += $(KEY)MD $(KEY)EHsc
+endif
+
+ifneq (, $(filter $(compiler), cl icl))
+ CPLUS_FLAGS += $(KEY)bigobj
+endif
+
+
+DYN_LDFLAGS += $(LINK_KEY)
+
+ifneq (,$(filter uwp,$(target_app) $(target_ui)))
+ CPLUS_FLAGS += /ZW:nostdlib /D "_UNICODE" /D "UNICODE" /D "WINAPI_FAMILY=WINAPI_FAMILY_APP"
+ _WIN32_WINNT = 0x0A00
+ DYN_LDFLAGS += /NODEFAULTLIB:"kernel32.lib" OneCore.lib
+endif