Skip to content

Commit

Permalink
Merged master:f753f5b05033 into amd-gfx:e9003c201939
Browse files Browse the repository at this point in the history
Local branch amd-gfx e9003c2 Merged master:78e4aeb7839e into amd-gfx:9ce6257e540b
Remote branch master f753f5b [ValueTracking] Let getGuaranteedNonPoisonOp find multiple non-poison operands
  • Loading branch information
Sw authored and Sw committed Aug 25, 2020
2 parents e9003c2 + f753f5b commit 259ceb5
Show file tree
Hide file tree
Showing 67 changed files with 533 additions and 280 deletions.
2 changes: 2 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ X86 Support in Clang
- The x86 intrinsics ``__rorb``, ``__rorw``, ``__rord``, ``__rorq`, ``_rotr``,
``_rotwr`` and ``_lrotr`` may now be used within constant expressions.

- Support for -march=sapphirerapids was added.

Internal API Changes
--------------------

Expand Down
42 changes: 25 additions & 17 deletions clang/lib/CodeGen/CGDebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2260,6 +2260,25 @@ static bool hasExplicitMemberDefinition(CXXRecordDecl::method_iterator I,
return false;
}

static bool canUseCtorHoming(const CXXRecordDecl *RD) {
// Constructor homing can be used for classes that have at least one
// constructor and have no trivial or constexpr constructors.
// Skip this optimization if the class or any of its methods are marked
// dllimport.
if (RD->isLambda() || RD->hasConstexprNonCopyMoveConstructor() ||
isClassOrMethodDLLImport(RD))
return false;

if (RD->ctors().empty())
return false;

for (const auto *Ctor : RD->ctors())
if (Ctor->isTrivial() && !Ctor->isCopyOrMoveConstructor())
return false;

return true;
}

static bool shouldOmitDefinition(codegenoptions::DebugInfoKind DebugKind,
bool DebugTypeExtRefs, const RecordDecl *RD,
const LangOptions &LangOpts) {
Expand Down Expand Up @@ -2294,23 +2313,6 @@ static bool shouldOmitDefinition(codegenoptions::DebugInfoKind DebugKind,
!isClassOrMethodDLLImport(CXXDecl))
return true;

// In constructor debug mode, only emit debug info for a class when its
// constructor is emitted. Skip this optimization if the class or any of
// its methods are marked dllimport.
//
// This applies to classes that don't have any trivial constructors and have
// at least one constructor.
if (DebugKind == codegenoptions::DebugInfoConstructor &&
!CXXDecl->isLambda() && !CXXDecl->hasConstexprNonCopyMoveConstructor() &&
!isClassOrMethodDLLImport(CXXDecl)) {
if (CXXDecl->ctors().empty())
return false;
for (const auto *Ctor : CXXDecl->ctors())
if (Ctor->isTrivial() && !Ctor->isCopyOrMoveConstructor())
return false;
return true;
}

TemplateSpecializationKind Spec = TSK_Undeclared;
if (const auto *SD = dyn_cast<ClassTemplateSpecializationDecl>(RD))
Spec = SD->getSpecializationKind();
Expand All @@ -2320,6 +2322,12 @@ static bool shouldOmitDefinition(codegenoptions::DebugInfoKind DebugKind,
CXXDecl->method_end()))
return true;

// In constructor homing mode, only emit complete debug info for a class
// when its constructor is emitted.
if ((DebugKind == codegenoptions::DebugInfoConstructor) &&
canUseCtorHoming(CXXDecl))
return true;

return false;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -debug-info-kind=limited %s -o - | FileCheck %s

// Make sure this still works with constructor homing.
// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -debug-info-kind=constructor %s -o - | FileCheck %s

// Run again with -gline-tables-only or -gline-directives-only and verify we don't crash. We won't output
// type info at all.
// RUN: %clang_cc1 -emit-llvm -triple %itanium_abi_triple -debug-info-kind=line-tables-only %s -o - | FileCheck %s -check-prefix LINES-ONLY
Expand Down
2 changes: 2 additions & 0 deletions compiler-rt/lib/sanitizer_common/sanitizer_ptrauth.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@
#define ptrauth_string_discriminator(__string) ((int)0)
#endif

#define STRIP_PC(pc) ((uptr)ptrauth_strip(pc, 0))

#endif // SANITIZER_PTRAUTH_H
11 changes: 6 additions & 5 deletions compiler-rt/lib/tsan/rtl/tsan_external.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//
#include "tsan_rtl.h"
#include "tsan_interceptors.h"
#include "sanitizer_common/sanitizer_ptrauth.h"

namespace __tsan {

Expand Down Expand Up @@ -57,13 +58,13 @@ uptr TagFromShadowStackFrame(uptr pc) {
#if !SANITIZER_GO

typedef void(*AccessFunc)(ThreadState *, uptr, uptr, int);
void ExternalAccess(void *addr, void *caller_pc, void *tag, AccessFunc access) {
void ExternalAccess(void *addr, uptr caller_pc, void *tag, AccessFunc access) {
CHECK_LT(tag, atomic_load(&used_tags, memory_order_relaxed));
ThreadState *thr = cur_thread();
if (caller_pc) FuncEntry(thr, (uptr)caller_pc);
if (caller_pc) FuncEntry(thr, caller_pc);
InsertShadowStackFrameForTag(thr, (uptr)tag);
bool in_ignored_lib;
if (!caller_pc || !libignore()->IsIgnored((uptr)caller_pc, &in_ignored_lib)) {
if (!caller_pc || !libignore()->IsIgnored(caller_pc, &in_ignored_lib)) {
access(thr, CALLERPC, (uptr)addr, kSizeLog1);
}
FuncExit(thr);
Expand Down Expand Up @@ -110,12 +111,12 @@ void __tsan_external_assign_tag(void *addr, void *tag) {

SANITIZER_INTERFACE_ATTRIBUTE
void __tsan_external_read(void *addr, void *caller_pc, void *tag) {
ExternalAccess(addr, caller_pc, tag, MemoryRead);
ExternalAccess(addr, STRIP_PC(caller_pc), tag, MemoryRead);
}

SANITIZER_INTERFACE_ATTRIBUTE
void __tsan_external_write(void *addr, void *caller_pc, void *tag) {
ExternalAccess(addr, caller_pc, tag, MemoryWrite);
ExternalAccess(addr, STRIP_PC(caller_pc), tag, MemoryWrite);
}
} // extern "C"

Expand Down
9 changes: 5 additions & 4 deletions compiler-rt/lib/tsan/rtl/tsan_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "tsan_interface_ann.h"
#include "tsan_rtl.h"
#include "sanitizer_common/sanitizer_internal_defs.h"
#include "sanitizer_common/sanitizer_ptrauth.h"

#define CALLERPC ((uptr)__builtin_return_address(0))

Expand Down Expand Up @@ -43,13 +44,13 @@ void __tsan_write16(void *addr) {
}

void __tsan_read16_pc(void *addr, void *pc) {
MemoryRead(cur_thread(), (uptr)pc, (uptr)addr, kSizeLog8);
MemoryRead(cur_thread(), (uptr)pc, (uptr)addr + 8, kSizeLog8);
MemoryRead(cur_thread(), STRIP_PC(pc), (uptr)addr, kSizeLog8);
MemoryRead(cur_thread(), STRIP_PC(pc), (uptr)addr + 8, kSizeLog8);
}

void __tsan_write16_pc(void *addr, void *pc) {
MemoryWrite(cur_thread(), (uptr)pc, (uptr)addr, kSizeLog8);
MemoryWrite(cur_thread(), (uptr)pc, (uptr)addr + 8, kSizeLog8);
MemoryWrite(cur_thread(), STRIP_PC(pc), (uptr)addr, kSizeLog8);
MemoryWrite(cur_thread(), STRIP_PC(pc), (uptr)addr + 8, kSizeLog8);
}

// __tsan_unaligned_read/write calls are emitted by compiler.
Expand Down
23 changes: 12 additions & 11 deletions compiler-rt/lib/tsan/rtl/tsan_interface_inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "tsan_interface.h"
#include "tsan_rtl.h"
#include "sanitizer_common/sanitizer_ptrauth.h"

#define CALLERPC ((uptr)__builtin_return_address(0))

Expand Down Expand Up @@ -50,35 +51,35 @@ void __tsan_write8(void *addr) {
}

void __tsan_read1_pc(void *addr, void *pc) {
MemoryRead(cur_thread(), (uptr)pc, (uptr)addr, kSizeLog1);
MemoryRead(cur_thread(), STRIP_PC(pc), (uptr)addr, kSizeLog1);
}

void __tsan_read2_pc(void *addr, void *pc) {
MemoryRead(cur_thread(), (uptr)pc, (uptr)addr, kSizeLog2);
MemoryRead(cur_thread(), STRIP_PC(pc), (uptr)addr, kSizeLog2);
}

void __tsan_read4_pc(void *addr, void *pc) {
MemoryRead(cur_thread(), (uptr)pc, (uptr)addr, kSizeLog4);
MemoryRead(cur_thread(), STRIP_PC(pc), (uptr)addr, kSizeLog4);
}

void __tsan_read8_pc(void *addr, void *pc) {
MemoryRead(cur_thread(), (uptr)pc, (uptr)addr, kSizeLog8);
MemoryRead(cur_thread(), STRIP_PC(pc), (uptr)addr, kSizeLog8);
}

void __tsan_write1_pc(void *addr, void *pc) {
MemoryWrite(cur_thread(), (uptr)pc, (uptr)addr, kSizeLog1);
MemoryWrite(cur_thread(), STRIP_PC(pc), (uptr)addr, kSizeLog1);
}

void __tsan_write2_pc(void *addr, void *pc) {
MemoryWrite(cur_thread(), (uptr)pc, (uptr)addr, kSizeLog2);
MemoryWrite(cur_thread(), STRIP_PC(pc), (uptr)addr, kSizeLog2);
}

void __tsan_write4_pc(void *addr, void *pc) {
MemoryWrite(cur_thread(), (uptr)pc, (uptr)addr, kSizeLog4);
MemoryWrite(cur_thread(), STRIP_PC(pc), (uptr)addr, kSizeLog4);
}

void __tsan_write8_pc(void *addr, void *pc) {
MemoryWrite(cur_thread(), (uptr)pc, (uptr)addr, kSizeLog8);
MemoryWrite(cur_thread(), STRIP_PC(pc), (uptr)addr, kSizeLog8);
}

void __tsan_vptr_update(void **vptr_p, void *new_val) {
Expand All @@ -100,7 +101,7 @@ void __tsan_vptr_read(void **vptr_p) {
}

void __tsan_func_entry(void *pc) {
FuncEntry(cur_thread(), (uptr)pc);
FuncEntry(cur_thread(), STRIP_PC(pc));
}

void __tsan_func_exit() {
Expand All @@ -124,9 +125,9 @@ void __tsan_write_range(void *addr, uptr size) {
}

void __tsan_read_range_pc(void *addr, uptr size, void *pc) {
MemoryAccessRange(cur_thread(), (uptr)pc, (uptr)addr, size, false);
MemoryAccessRange(cur_thread(), STRIP_PC(pc), (uptr)addr, size, false);
}

void __tsan_write_range_pc(void *addr, uptr size, void *pc) {
MemoryAccessRange(cur_thread(), (uptr)pc, (uptr)addr, size, true);
MemoryAccessRange(cur_thread(), STRIP_PC(pc), (uptr)addr, size, true);
}
27 changes: 27 additions & 0 deletions flang/include/flang/Parser/characters.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,33 @@ inline constexpr std::optional<char> BackslashEscapeChar(char ch) {
}
}

// Does not include spaces or line ending characters.
inline constexpr bool IsValidFortranTokenCharacter(char ch) {
switch (ch) {
case '"':
case '%':
case '\'':
case '(':
case ')':
case '*':
case '+':
case ',':
case '-':
case '.':
case '/':
case ':':
case ';':
case '<':
case '=':
case '>':
case '[':
case ']':
return true;
default:
return IsLegalIdentifierStart(ch) || IsDecimalDigit(ch);
}
}

struct EncodedCharacter {
static constexpr int maxEncodingBytes{6};
char buffer[maxEncodingBytes];
Expand Down
3 changes: 2 additions & 1 deletion flang/include/flang/Parser/parse-tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,8 @@ struct ProgramUnit {
std::variant<common::Indirection<MainProgram>,
common::Indirection<FunctionSubprogram>,
common::Indirection<SubroutineSubprogram>, common::Indirection<Module>,
common::Indirection<Submodule>, common::Indirection<BlockData>>
common::Indirection<Submodule>, common::Indirection<BlockData>,
common::Indirection<CompilerDirective>>
u;
};

Expand Down
29 changes: 21 additions & 8 deletions flang/lib/Parser/prescan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ void Prescanner::Statement() {
case LineClassification::Kind::PreprocessorDirective:
Say(preprocessed->GetProvenanceRange(),
"Preprocessed line resembles a preprocessor directive"_en_US);
preprocessed->ToLowerCase().Emit(cooked_);
preprocessed->ToLowerCase().CheckBadFortranCharacters(messages_).Emit(
cooked_);
break;
case LineClassification::Kind::CompilerDirective:
if (preprocessed->HasRedundantBlanks()) {
Expand All @@ -193,7 +194,9 @@ void Prescanner::Statement() {
NormalizeCompilerDirectiveCommentMarker(*preprocessed);
preprocessed->ToLowerCase();
SourceFormChange(preprocessed->ToString());
preprocessed->ClipComment(true /* skip first ! */).Emit(cooked_);
preprocessed->ClipComment(true /* skip first ! */)
.CheckBadFortranCharacters(messages_)
.Emit(cooked_);
break;
case LineClassification::Kind::Source:
if (inFixedForm_) {
Expand All @@ -205,15 +208,18 @@ void Prescanner::Statement() {
preprocessed->RemoveRedundantBlanks();
}
}
preprocessed->ToLowerCase().ClipComment().Emit(cooked_);
preprocessed->ToLowerCase()
.ClipComment()
.CheckBadFortranCharacters(messages_)
.Emit(cooked_);
break;
}
} else {
tokens.ToLowerCase();
if (line.kind == LineClassification::Kind::CompilerDirective) {
SourceFormChange(tokens.ToString());
}
tokens.Emit(cooked_);
tokens.CheckBadFortranCharacters(messages_).Emit(cooked_);
}
if (omitNewline_) {
omitNewline_ = false;
Expand Down Expand Up @@ -245,8 +251,9 @@ void Prescanner::NextLine() {
}
}

void Prescanner::LabelField(TokenSequence &token, int outCol) {
void Prescanner::LabelField(TokenSequence &token) {
const char *bad{nullptr};
int outCol{1};
for (; *at_ != '\n' && column_ <= 6; ++at_) {
if (*at_ == '\t') {
++at_;
Expand All @@ -256,20 +263,26 @@ void Prescanner::LabelField(TokenSequence &token, int outCol) {
if (*at_ != ' ' &&
!(*at_ == '0' && column_ == 6)) { // '0' in column 6 becomes space
EmitChar(token, *at_);
++outCol;
if (!bad && !IsDecimalDigit(*at_)) {
bad = at_;
}
++outCol;
}
++column_;
}
if (outCol > 1) {
if (outCol == 1) { // empty label field
// Emit a space so that, if the line is rescanned after preprocessing,
// a leading 'C' or 'D' won't be left-justified and then accidentally
// misinterpreted as a comment card.
EmitChar(token, ' ');
++outCol;
} else {
if (bad && !preprocessor_.IsNameDefined(token.CurrentOpenToken())) {
Say(GetProvenance(bad),
"Character in fixed-form label field must be a digit"_en_US);
}
token.CloseToken();
}
token.CloseToken();
SkipToNextSignificantCharacter();
if (IsDecimalDigit(*at_)) {
Say(GetProvenance(at_),
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Parser/prescan.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class Prescanner {
common::LanguageFeature::ClassicCComments)));
}

void LabelField(TokenSequence &, int outCol = 1);
void LabelField(TokenSequence &);
void SkipToEndOfLine();
bool MustSkipToEndOfLine() const;
void NextChar();
Expand Down
Loading

0 comments on commit 259ceb5

Please sign in to comment.