Skip to content

Commit

Permalink
Merged master:f8454d60b829 into amd-gfx:1fe58ede4cad
Browse files Browse the repository at this point in the history
Local branch amd-gfx 1fe58ed Merged master:0d2fe90063e9 into amd-gfx:43b9ac8878b2
Remote branch master f8454d6 [AIX][compiler-rt][builtins] Don't add ppc builtin implementations that require __int128 on AIX
  • Loading branch information
Sw authored and Sw committed Aug 25, 2020
2 parents 1fe58ed + f8454d6 commit 9ce6257
Show file tree
Hide file tree
Showing 36 changed files with 568 additions and 150 deletions.
3 changes: 3 additions & 0 deletions clang/include/clang/Basic/CodeGenOptions.def
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,9 @@ ENUM_CODEGENOPT(DebuggerTuning, llvm::DebuggerKind, 2,
/// emitted.
VALUE_CODEGENOPT(DwarfVersion, 3, 0)

/// Whether to use experimental new variable location tracking.
CODEGENOPT(ValueTrackingVariableLocations, 1, 0)

/// Whether we should emit CodeView debug information. It's possible to emit
/// CodeView and DWARF into the same object.
CODEGENOPT(EmitCodeView, 1, 0)
Expand Down
3 changes: 3 additions & 0 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -3870,6 +3870,9 @@ def fdebug_pass_manager : Flag<["-"], "fdebug-pass-manager">,
HelpText<"Prints debug information for the new pass manager">;
def fno_debug_pass_manager : Flag<["-"], "fno-debug-pass-manager">,
HelpText<"Disables debug printing for the new pass manager">;
def fexperimental_debug_variable_locations : Flag<["-"],
"fexperimental-debug-variable-locations">,
HelpText<"Use experimental new value-tracking variable locations">;
// The driver option takes the key as a parameter to the -msign-return-address=
// and -mbranch-protection= options, but CC1 has a separate option so we
// don't have to parse the parameter twice.
Expand Down
2 changes: 2 additions & 0 deletions clang/lib/CodeGen/BackendUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,8 @@ static void initTargetOptions(DiagnosticsEngine &Diags,
Options.EmitAddrsig = CodeGenOpts.Addrsig;
Options.ForceDwarfFrameSection = CodeGenOpts.ForceDwarfFrameSection;
Options.EmitCallSiteInfo = CodeGenOpts.EmitCallSiteInfo;
Options.ValueTrackingVariableLocations =
CodeGenOpts.ValueTrackingVariableLocations;
Options.XRayOmitFunctionIndex = CodeGenOpts.XRayOmitFunctionIndex;

Options.MCOptions.SplitDwarfFile = CodeGenOpts.SplitDwarfFile;
Expand Down
3 changes: 3 additions & 0 deletions clang/lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,9 @@ static bool ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, InputKind IK,
llvm::is_contained(DebugEntryValueArchs, T.getArch()))
Opts.EmitCallSiteInfo = true;

Opts.ValueTrackingVariableLocations =
Args.hasArg(OPT_fexperimental_debug_variable_locations);

Opts.DisableO0ImplyOptNone = Args.hasArg(OPT_disable_O0_optnone);
Opts.DisableRedZone = Args.hasArg(OPT_disable_red_zone);
Opts.IndirectTlsSegRefs = Args.hasArg(OPT_mno_tls_direct_seg_refs);
Expand Down
2 changes: 2 additions & 0 deletions clang/test/Driver/debug-var-experimental-switch.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// RUN: %clang -Xclang -fexperimental-debug-variable-locations -fsyntax-only -disable-llvm-passes %s
int main() {}
12 changes: 9 additions & 3 deletions compiler-rt/lib/builtins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -553,11 +553,8 @@ set(mips64el_SOURCES ${GENERIC_TF_SOURCES}

set(powerpc64_SOURCES
ppc/divtc3.c
ppc/fixtfti.c
ppc/fixtfdi.c
ppc/fixunstfti.c
ppc/fixunstfdi.c
ppc/floattitf.c
ppc/floatditf.c
ppc/floatunditf.c
ppc/gcc_qadd.c
Expand All @@ -567,6 +564,15 @@ set(powerpc64_SOURCES
ppc/multc3.c
${GENERIC_SOURCES}
)
# These routines require __int128, which isn't supported on AIX.
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
set(powerpc64_SOURCES
ppc/floattitf.c
ppc/fixtfti.c
ppc/fixunstfti.c
${powerpc64_SOURCES}
)
endif()
set(powerpc64le_SOURCES ${powerpc64_SOURCES})

set(riscv_SOURCES ${GENERIC_SOURCES} ${GENERIC_TF_SOURCES})
Expand Down
5 changes: 4 additions & 1 deletion compiler-rt/lib/scudo/standalone/primary32.h
Original file line number Diff line number Diff line change
Expand Up @@ -483,12 +483,15 @@ class SizeClassAllocator32 {
}
}
uptr TotalReleasedBytes = 0;
auto SkipRegion = [this, First, ClassId](uptr RegionIndex) {
return (PossibleRegions[First + RegionIndex] - 1U) != ClassId;
};
if (First && Last) {
const uptr Base = First * RegionSize;
const uptr NumberOfRegions = Last - First + 1U;
ReleaseRecorder Recorder(Base);
releaseFreeMemoryToOS(Sci->FreeList, Base, RegionSize, NumberOfRegions,
BlockSize, &Recorder);
BlockSize, &Recorder, SkipRegion);
if (Recorder.getReleasedRangesCount() > 0) {
Sci->ReleaseInfo.PushedBlocksAtLastRelease = Sci->Stats.PushedBlocks;
Sci->ReleaseInfo.RangesReleased += Recorder.getReleasedRangesCount();
Expand Down
4 changes: 3 additions & 1 deletion compiler-rt/lib/scudo/standalone/primary64.h
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,11 @@ class SizeClassAllocator64 {
}
}

auto SkipRegion = [](UNUSED uptr RegionIndex) { return false; };
ReleaseRecorder Recorder(Region->RegionBeg, &Region->Data);
releaseFreeMemoryToOS(Region->FreeList, Region->RegionBeg,
Region->AllocatedUser, 1U, BlockSize, &Recorder);
Region->AllocatedUser, 1U, BlockSize, &Recorder,
SkipRegion);

if (Recorder.getReleasedRangesCount() > 0) {
Region->ReleaseInfo.PushedBlocksAtLastRelease =
Expand Down
20 changes: 17 additions & 3 deletions compiler-rt/lib/scudo/standalone/release.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ template <class ReleaseRecorderT> class FreePagesRangeTracker {
CurrentPage++;
}

void skipPages(uptr N) {
closeOpenedRange();
CurrentPage += N;
}

void finish() { closeOpenedRange(); }

private:
Expand All @@ -174,11 +179,11 @@ template <class ReleaseRecorderT> class FreePagesRangeTracker {
uptr CurrentRangeStatePage = 0;
};

template <class TransferBatchT, class ReleaseRecorderT>
template <class TransferBatchT, class ReleaseRecorderT, typename SkipRegionT>
NOINLINE void
releaseFreeMemoryToOS(const IntrusiveList<TransferBatchT> &FreeList, uptr Base,
uptr RegionSize, uptr NumberOfRegions, uptr BlockSize,
ReleaseRecorderT *Recorder) {
ReleaseRecorderT *Recorder, SkipRegionT SkipRegion) {
const uptr PageSize = getPageSizeCached();

// Figure out the number of chunks per page and whether we can take a fast
Expand Down Expand Up @@ -283,10 +288,15 @@ releaseFreeMemoryToOS(const IntrusiveList<TransferBatchT> &FreeList, uptr Base,
FreePagesRangeTracker<ReleaseRecorderT> RangeTracker(Recorder);
if (SameBlockCountPerPage) {
// Fast path, every page has the same number of chunks affecting it.
for (uptr I = 0; I < NumberOfRegions; I++)
for (uptr I = 0; I < NumberOfRegions; I++) {
if (SkipRegion(I)) {
RangeTracker.skipPages(PagesCount);
continue;
}
for (uptr J = 0; J < PagesCount; J++)
RangeTracker.processNextPage(Counters.get(I, J) ==
FullPagesBlockCountMax);
}
} else {
// Slow path, go through the pages keeping count how many chunks affect
// each page.
Expand All @@ -298,6 +308,10 @@ releaseFreeMemoryToOS(const IntrusiveList<TransferBatchT> &FreeList, uptr Base,
// up the number of chunks on the current page and checking on every step
// whether the page boundary was crossed.
for (uptr I = 0; I < NumberOfRegions; I++) {
if (SkipRegion(I)) {
RangeTracker.skipPages(PagesCount);
continue;
}
uptr PrevPageBoundary = 0;
uptr CurrentBoundary = 0;
for (uptr J = 0; J < PagesCount; J++) {
Expand Down
3 changes: 2 additions & 1 deletion compiler-rt/lib/scudo/standalone/tests/release_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,10 @@ template <class SizeClassMap> void testReleaseFreeMemoryToOS() {
}

// Release the memory.
auto SkipRegion = [](UNUSED scudo::uptr RegionIndex) { return false; };
ReleasedPagesRecorder Recorder;
releaseFreeMemoryToOS(FreeList, 0, MaxBlocks * BlockSize, 1U, BlockSize,
&Recorder);
&Recorder, SkipRegion);

// Verify that there are no released pages touched by used chunks and all
// ranges of free chunks big enough to contain the entire memory pages had
Expand Down
41 changes: 21 additions & 20 deletions lld/ELF/InputFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -780,20 +780,21 @@ static void updateSupportedARMFeatures(const ARMAttributeParser &attributes) {
// of zero or more type-length-value fields. We want to find a field of a
// certain type. It seems a bit too much to just store a 32-bit value, perhaps
// the ABI is unnecessarily complicated.
template <class ELFT>
static uint32_t readAndFeatures(ObjFile<ELFT> *obj, ArrayRef<uint8_t> data) {
template <class ELFT> static uint32_t readAndFeatures(const InputSection &sec) {
using Elf_Nhdr = typename ELFT::Nhdr;
using Elf_Note = typename ELFT::Note;

uint32_t featuresSet = 0;
ArrayRef<uint8_t> data = sec.data();
auto reportFatal = [&](const uint8_t *place, const char *msg) {
fatal(toString(sec.file) + ":(" + sec.name + "+0x" +
Twine::utohexstr(place - sec.data().data()) + "): " + msg);
};
while (!data.empty()) {
// Read one NOTE record.
if (data.size() < sizeof(Elf_Nhdr))
fatal(toString(obj) + ": .note.gnu.property: section too short");

auto *nhdr = reinterpret_cast<const Elf_Nhdr *>(data.data());
if (data.size() < nhdr->getSize())
fatal(toString(obj) + ": .note.gnu.property: section too short");
if (data.size() < sizeof(Elf_Nhdr) || data.size() < nhdr->getSize())
reportFatal(data.data(), "data is too short");

Elf_Note note(*nhdr);
if (nhdr->n_type != NT_GNU_PROPERTY_TYPE_0 || note.getName() != "GNU") {
Expand All @@ -808,25 +809,26 @@ static uint32_t readAndFeatures(ObjFile<ELFT> *obj, ArrayRef<uint8_t> data) {
// Read a body of a NOTE record, which consists of type-length-value fields.
ArrayRef<uint8_t> desc = note.getDesc();
while (!desc.empty()) {
const uint8_t *place = desc.data();
if (desc.size() < 8)
fatal(toString(obj) + ": .note.gnu.property: section too short");

uint32_t type = read32le(desc.data());
uint32_t size = read32le(desc.data() + 4);
reportFatal(place, "program property is too short");
uint32_t type = read32<ELFT::TargetEndianness>(desc.data());
uint32_t size = read32<ELFT::TargetEndianness>(desc.data() + 4);
desc = desc.slice(8);
if (desc.size() < size)
reportFatal(place, "program property is too short");

if (type == featureAndType) {
// We found a FEATURE_1_AND field. There may be more than one of these
// in a .note.gnu.property section, for a relocatable object we
// accumulate the bits set.
featuresSet |= read32le(desc.data() + 8);
if (size < 4)
reportFatal(place, "FEATURE_1_AND entry is too short");
featuresSet |= read32<ELFT::TargetEndianness>(desc.data());
}

// On 64-bit, a payload may be followed by a 4-byte padding to make its
// size a multiple of 8.
if (ELFT::Is64Bits)
size = alignTo(size, 8);

desc = desc.slice(size + 8); // +8 for Type and Size
// Padding is present in the note descriptor, if necessary.
desc = desc.slice(alignTo<(ELFT::Is64Bits ? 8 : 4)>(size));
}

// Go to next NOTE record to look for more FEATURE_1_AND descriptions.
Expand Down Expand Up @@ -985,8 +987,7 @@ InputSectionBase *ObjFile<ELFT>::createInputSection(const Elf_Shdr &sec) {
// .note.gnu.property containing a single AND'ed bitmap, we discard an input
// file's .note.gnu.property section.
if (name == ".note.gnu.property") {
ArrayRef<uint8_t> contents = check(this->getObj().getSectionContents(&sec));
this->andFeatures = readAndFeatures(this, contents);
this->andFeatures = readAndFeatures<ELFT>(InputSection(*this, sec, name));
return &InputSection::discarded;
}

Expand Down
55 changes: 55 additions & 0 deletions lld/test/ELF/gnu-property-err.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# REQUIRES: aarch64
# RUN: split-file %s %t

# RUN: llvm-mc -filetype=obj -triple=aarch64 %t/1.s -o %t1.o
# RUN: not ld.lld %t1.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR1

# ERR1: error: {{.*}}.o:(.note.gnu.property+0x0): data is too short

# RUN: llvm-mc -filetype=obj -triple=aarch64 %t/2.s -o %t2.o
# RUN: not ld.lld %t2.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR2
# RUN: llvm-mc -filetype=obj -triple=aarch64_be %t/2.s -o %t2be.o
# RUN: not ld.lld %t2be.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR2

# ERR2: error: {{.*}}.o:(.note.gnu.property+0x10): program property is too short

# RUN: llvm-mc -filetype=obj -triple=aarch64 %t/3.s -o %t3.o
# RUN: not ld.lld %t3.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR3
# RUN: llvm-mc -filetype=obj -triple=aarch64_be %t/3.s -o %t3be.o
# RUN: not ld.lld %t3be.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR3

# ERR3: error: {{.*}}.o:(.note.gnu.property+0x10): FEATURE_1_AND entry is too short

#--- 1.s
.section ".note.gnu.property", "a"
.long 4
.long 17 // n_descsz too long
.long 5 // NT_GNU_PROPERTY_TYPE_0
.asciz "GNU"

.long 0xc0000000 // GNU_PROPERTY_AARCH64_FEATURE_1_AND
.long 4 // pr_datasz
.long 1 // GNU_PROPERTY_AARCH64_FEATURE_1_BTI
.long 0

#--- 2.s
.section ".note.gnu.property", "a"
.long 4
.long 16 // n_descsz
.long 5 // NT_GNU_PROPERTY_TYPE_0
.asciz "GNU"

.long 0xc0000000 // GNU_PROPERTY_AARCH64_FEATURE_1_AND
.long 9 // pr_datasz too long
.long 1 // GNU_PROPERTY_AARCH64_FEATURE_1_BTI
.long 0

#--- 3.s
.section ".note.gnu.property", "a"
.long 4
.long 8 // n_descsz
.long 5 // NT_GNU_PROPERTY_TYPE_0
.asciz "GNU"

.long 0xc0000000 // GNU_PROPERTY_AARCH64_FEATURE_1_AND
.long 0 // pr_datasz too short
27 changes: 14 additions & 13 deletions llvm/docs/LangRef.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16930,27 +16930,28 @@ to:

::

%m[i] = icmp ule (%base + i), %n
%m[i] = icmp ult (%base + i), %n

where ``%m`` is a vector (mask) of active/inactive lanes with its elements
indexed by ``i``, and ``%base``, ``%n`` are the two arguments to
``llvm.get.active.lane.mask.*``, ``%imcp`` is an integer compare and ``ule``
the unsigned less-than-equal comparison operator. Overflow cannot occur in
``(%base + i)`` and its comparison against ``%n`` as it is performed in integer
numbers and not in machine numbers. The above is equivalent to:
``llvm.get.active.lane.mask.*``, ``%icmp`` is an integer compare and ``ult``
the unsigned less-than comparison operator. Overflow cannot occur in
``(%base + i)`` and its comparison against ``%n`` with ``%n > 0``, as it is
performed in integer numbers and not in machine numbers. The above is
equivalent to:

::

%m = @llvm.get.active.lane.mask(%base, %n)

This can, for example, be emitted by the loop vectorizer. Then, ``%base`` is
the first element of the vector induction variable (VIV), and ``%n`` is the
Back-edge Taken Count (BTC). Thus, these intrinsics perform an element-wise
less than or equal comparison of VIV with BTC, producing a mask of true/false
values representing active/inactive vector lanes, except if the VIV overflows
in which case they return false in the lanes where the VIV overflows. The
arguments are scalar types to accommodate scalable vector types, for which it is
unknown what the type of the step vector needs to be that enumerate its
This can, for example, be emitted by the loop vectorizer in which case
``%base`` is the first element of the vector induction variable (VIV) and
``%n`` is the loop tripcount. Thus, these intrinsics perform an element-wise
less than comparison of VIV with the loop tripcount, producing a mask of
true/false values representing active/inactive vector lanes, except if the VIV
overflows in which case they return false in the lanes where the VIV overflows.
The arguments are scalar types to accommodate scalable vector types, for which
it is unknown what the type of the step vector needs to be that enumerate its
lanes without overflow.

This mask ``%m`` can e.g. be used in masked load/store instructions. These
Expand Down
2 changes: 2 additions & 0 deletions llvm/include/llvm/CodeGen/CommandFlags.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ bool getEmitCallSiteInfo();

bool getEnableDebugEntryValues();

bool getValueTrackingVariableLocations();

bool getForceDwarfFrameSection();

bool getXRayOmitFunctionIndex();
Expand Down
9 changes: 7 additions & 2 deletions llvm/include/llvm/Target/TargetOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ namespace llvm {
EmitStackSizeSection(false), EnableMachineOutliner(false),
SupportsDefaultOutlining(false), EmitAddrsig(false),
EmitCallSiteInfo(false), SupportsDebugEntryValues(false),
EnableDebugEntryValues(false), ForceDwarfFrameSection(false),
XRayOmitFunctionIndex(false),
EnableDebugEntryValues(false), ValueTrackingVariableLocations(false),
ForceDwarfFrameSection(false), XRayOmitFunctionIndex(false),
FPDenormalMode(DenormalMode::IEEE, DenormalMode::IEEE) {}

/// DisableFramePointerElim - This returns true if frame pointer elimination
Expand Down Expand Up @@ -285,6 +285,11 @@ namespace llvm {
/// production.
bool ShouldEmitDebugEntryValues() const;

// When set to true, use experimental new debug variable location tracking,
// which seeks to follow the values of variables rather than their location,
// post isel.
unsigned ValueTrackingVariableLocations : 1;

/// Emit DWARF debug frame section.
unsigned ForceDwarfFrameSection : 1;

Expand Down
Loading

0 comments on commit 9ce6257

Please sign in to comment.