Skip to content

Commit

Permalink
Merged master:d0ba6c4002e4 into amd-gfx:5b170e5ef9e4
Browse files Browse the repository at this point in the history
Local branch amd-gfx 5b170e5 Merged master:3a7b57b7cad3 into amd-gfx:d2c3df5bcfc0
Remote branch master d0ba6c4 [AArch64][GlobalISel] Select CSINC and CSINV for G_SELECT with constants
  • Loading branch information
Sw authored and Sw committed Nov 12, 2020
2 parents 5b170e5 + d0ba6c4 commit cf10a01
Show file tree
Hide file tree
Showing 50 changed files with 2,347 additions and 738 deletions.
9 changes: 4 additions & 5 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6365,11 +6365,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
if (Args.hasFlag(options::OPT_faddrsig, options::OPT_fno_addrsig,
(TC.getTriple().isOSBinFormatELF() ||
TC.getTriple().isOSBinFormatCOFF()) &&
!TC.getTriple().isPS4() &&
!TC.getTriple().isOSNetBSD() &&
!Distro(D.getVFS(), TC.getTriple()).IsGentoo() &&
!TC.getTriple().isAndroid() &&
TC.useIntegratedAs()))
!TC.getTriple().isPS4() && !TC.getTriple().isVE() &&
!TC.getTriple().isOSNetBSD() &&
!Distro(D.getVFS(), TC.getTriple()).IsGentoo() &&
!TC.getTriple().isAndroid() && TC.useIntegratedAs()))
CmdArgs.push_back("-faddrsig");

if (Arg *A = Args.getLastArg(options::OPT_fsymbol_partition_EQ)) {
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14598,7 +14598,7 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body,
DiscardCleanupsInEvaluationContext();
}

if (LangOpts.OpenMP || LangOpts.CUDA || LangOpts.SYCLIsDevice) {
if (FD && (LangOpts.OpenMP || LangOpts.CUDA || LangOpts.SYCLIsDevice)) {
auto ES = getEmissionStatus(FD);
if (ES == Sema::FunctionEmissionStatus::Emitted ||
ES == Sema::FunctionEmissionStatus::Unknown)
Expand Down
17 changes: 17 additions & 0 deletions clang/test/Driver/ve-toolchain.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,23 @@
// NOTINITARRAY: clang{{.*}} "-cc1"
// NOTINITARRAY: "-fno-use-init-array"

///-----------------------------------------------------------------------------
/// Checking -faddrsig

// RUN: %clang -### -target ve %s 2>&1 | FileCheck -check-prefix=DEFADDESIG %s
// DEFADDESIG: clang{{.*}} "-cc1"
// DEFADDESIG-NOT: "-faddrsig"

// RUN: %clang -### -target ve %s -faddrsig 2>&1 | \
// RUN: FileCheck -check-prefix=ADDRSIG %s
// ADDRSIG: clang{{.*}} "-cc1"
// ADDRSIG: "-faddrsig"

// RUN: %clang -### -target ve %s -fno-addrsig 2>&1 | \
// RUN: FileCheck -check-prefix=NOADDRSIG %s
// NOADDRSIG: clang{{.*}} "-cc1"
// NOADDRSIG-NOT: "-faddrsig"

///-----------------------------------------------------------------------------
/// Checking exceptions

Expand Down
22 changes: 22 additions & 0 deletions clang/test/SemaObjCXX/objcxx_openmp.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// RUN: %clang_cc1 -fopenmp -fsyntax-only -verify %s
// expected-no-diagnostics

class Foo {
int a;
};

@interface NSObject
@end

@interface Bar : NSObject {
Foo *foo;
}
- (void)setSystemAndWindowCocoa:(class Foo *)foo_1;

@end

@implementation Bar : NSObject
- (void)setSystemAndWindowCocoa:(Foo *)foo_1 {
foo = foo_1;
}
@end
53 changes: 27 additions & 26 deletions clang/utils/creduce-clang-crash.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
verbose = False
creduce_cmd = None
clang_cmd = None
not_cmd = None

def verbose_print(*args, **kwargs):
if verbose:
Expand Down Expand Up @@ -77,7 +76,7 @@ def __init__(self, crash_script, file_to_reduce):
self.clang = clang_cmd
self.clang_args = []
self.expected_output = []
self.is_crash = True
self.needs_stack_trace = False
self.creduce_flags = ["--tidy"]

self.read_clang_args(crash_script, file_to_reduce)
Expand Down Expand Up @@ -128,36 +127,36 @@ def read_expected_output(self):
crash_output = re.sub(ansi_escape, '', crash_output.decode('utf-8'))

# Look for specific error messages
regexes = [r"Assertion `(.+)' failed", # Linux assert()
r"Assertion failed: (.+),", # FreeBSD/Mac assert()
r"fatal error: error in backend: (.+)",
r"LLVM ERROR: (.+)",
r"UNREACHABLE executed (at .+)?!",
r"LLVM IR generation of declaration '(.+)'",
r"Generating code for declaration '(.+)'",
r"\*\*\* Bad machine code: (.+) \*\*\*"]
regexes = [r"Assertion .+ failed", # Linux assert()
r"Assertion failed: .+,", # FreeBSD/Mac assert()
r"fatal error: error in backend: .+",
r"LLVM ERROR: .+",
r"UNREACHABLE executed at .+?!",
r"LLVM IR generation of declaration '.+'",
r"Generating code for declaration '.+'",
r"\*\*\* Bad machine code: .+ \*\*\*"]
for msg_re in regexes:
match = re.search(msg_re, crash_output)
if match:
msg = match.group(1)
msg = match.group(0)
result = [msg]
print("Found message:", msg)

if "fatal error:" in msg_re:
self.is_crash = False
break

# If no message was found, use the top five stack trace functions,
# ignoring some common functions
# Five is a somewhat arbitrary number; the goal is to get a small number
# of identifying functions with some leeway for common functions
if not result:
self.needs_stack_trace = True
stacktrace_re = r'[0-9]+\s+0[xX][0-9a-fA-F]+\s*([^(]+)\('
filters = ["PrintStackTraceSignalHandler",
"llvm::sys::RunSignalHandlers",
"SignalHandler", "__restore_rt", "gsignal", "abort"]
filters = ["PrintStackTrace", "RunSignalHandlers", "CleanupOnSignal",
"HandleCrash", "SignalHandler", "__restore_rt", "gsignal", "abort"]
def skip_function(func_name):
return any(name in func_name for name in filters)

matches = re.findall(stacktrace_re, crash_output)
result = [x for x in matches if x and x.strip() not in filters][:5]
result = [x for x in matches if x and not skip_function(x)][:5]
for msg in result:
print("Found stack trace function:", msg)

Expand All @@ -184,10 +183,17 @@ def check_expected_output(self, args=None, filename=None):
def write_interestingness_test(self):
print("\nCreating the interestingness test...")

crash_flag = "--crash" if self.is_crash else ""
# Disable symbolization if it's not required to avoid slow symbolization.
disable_symbolization = ''
if not self.needs_stack_trace:
disable_symbolization = 'export LLVM_DISABLE_SYMBOLIZATION=1'

output = "#!/bin/bash\n%s %s %s >& t.log || exit 1\n" % \
(pipes.quote(not_cmd), crash_flag, quote_cmd(self.get_crash_cmd()))
output = """#!/bin/bash
%s
if %s >& t.log ; then
exit 1
fi
""" % (disable_symbolization, quote_cmd(self.get_crash_cmd()))

for msg in self.expected_output:
output += 'grep -F %s t.log || exit 1\n' % pipes.quote(msg)
Expand Down Expand Up @@ -372,7 +378,6 @@ def main():
global verbose
global creduce_cmd
global clang_cmd
global not_cmd

parser = ArgumentParser(description=__doc__,
formatter_class=RawTextHelpFormatter)
Expand All @@ -382,9 +387,6 @@ def main():
help="Name of the file to be reduced.")
parser.add_argument('--llvm-bin', dest='llvm_bin', type=str,
help="Path to the LLVM bin directory.")
parser.add_argument('--llvm-not', dest='llvm_not', type=str,
help="The path to the `not` executable. "
"By default uses the llvm-bin directory.")
parser.add_argument('--clang', dest='clang', type=str,
help="The path to the `clang` executable. "
"By default uses the llvm-bin directory.")
Expand All @@ -398,7 +400,6 @@ def main():
llvm_bin = os.path.abspath(args.llvm_bin) if args.llvm_bin else None
creduce_cmd = check_cmd('creduce', None, args.creduce)
clang_cmd = check_cmd('clang', llvm_bin, args.clang)
not_cmd = check_cmd('not', llvm_bin, args.llvm_not)

crash_script = check_file(args.crash_script[0])
file_to_reduce = check_file(args.file_to_reduce[0])
Expand Down
2 changes: 2 additions & 0 deletions compiler-rt/lib/fuzzer/FuzzerDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,8 @@ int FuzzerDriver(int *argc, char ***argv, UserCallback Callback) {
Options.HandleXfsz = Flags.handle_xfsz;
Options.HandleUsr1 = Flags.handle_usr1;
Options.HandleUsr2 = Flags.handle_usr2;
Options.HandleWinExcept = Flags.handle_winexcept;

SetSignalHandler(Options);

std::atexit(Fuzzer::StaticExitCallback);
Expand Down
2 changes: 2 additions & 0 deletions compiler-rt/lib/fuzzer/FuzzerFlags.def
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ FUZZER_FLAG_INT(handle_term, 1, "If 1, try to intercept SIGTERM.")
FUZZER_FLAG_INT(handle_xfsz, 1, "If 1, try to intercept SIGXFSZ.")
FUZZER_FLAG_INT(handle_usr1, 1, "If 1, try to intercept SIGUSR1.")
FUZZER_FLAG_INT(handle_usr2, 1, "If 1, try to intercept SIGUSR2.")
FUZZER_FLAG_INT(handle_winexcept, 1, "If 1, try to intercept uncaught Windows "
"Visual C++ Exceptions.")
FUZZER_FLAG_INT(close_fd_mask, 0, "If 1, close stdout at startup; "
"if 2, close stderr; if 3, close both. "
"Be careful, this will also close e.g. stderr of asan.")
Expand Down
1 change: 1 addition & 0 deletions compiler-rt/lib/fuzzer/FuzzerOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ struct FuzzingOptions {
bool HandleXfsz = false;
bool HandleUsr1 = false;
bool HandleUsr2 = false;
bool HandleWinExcept = false;
};

} // namespace fuzzer
Expand Down
12 changes: 10 additions & 2 deletions compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,15 @@ static LONG CALLBACK ExceptionHandler(PEXCEPTION_POINTERS ExceptionInfo) {
if (HandlerOpt->HandleFpe)
Fuzzer::StaticCrashSignalCallback();
break;
// TODO: handle (Options.HandleXfsz)
// This is an undocumented exception code corresponding to a Visual C++
// Exception.
//
// See: https://devblogs.microsoft.com/oldnewthing/20100730-00/?p=13273
case 0xE06D7363:
if (HandlerOpt->HandleWinExcept)
Fuzzer::StaticCrashSignalCallback();
break;
// TODO: Handle (Options.HandleXfsz)
}
return EXCEPTION_CONTINUE_SEARCH;
}
Expand Down Expand Up @@ -127,7 +135,7 @@ void SetSignalHandler(const FuzzingOptions& Options) {
}

if (Options.HandleSegv || Options.HandleBus || Options.HandleIll ||
Options.HandleFpe)
Options.HandleFpe || Options.HandleWinExcept)
SetUnhandledExceptionFilter(ExceptionHandler);

if (Options.HandleAbrt)
Expand Down
10 changes: 10 additions & 0 deletions compiler-rt/test/fuzzer/UncaughtException.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <cstdint>
#include <vector>

extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t *data, size_t size) {
std::vector<uint8_t> v;
// Intentionally throw std::length_error
v.reserve(static_cast<uint64_t>(-1));

return 0;
}
8 changes: 8 additions & 0 deletions compiler-rt/test/fuzzer/uncaught-exception.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Test that throws a C++ exception and doesn't catch it. Should result in a
# crash
RUN: %cpp_compiler %S/UncaughtException.cpp -o %t-UncaughtException

RUN: not %run %t-UncaughtException 2>&1 | FileCheck %s

CHECK: ERROR: libFuzzer: deadly signal
CHECK: Test unit written to ./crash
2 changes: 1 addition & 1 deletion flang/lib/Parser/io-parsers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ TYPE_CONTEXT_PARSER("BACKSPACE statement"_en_US,
// R1225 endfile-stmt ->
// ENDFILE file-unit-number | ENDFILE ( position-spec-list )
TYPE_CONTEXT_PARSER("ENDFILE statement"_en_US,
construct<EndfileStmt>("ENDFILE" >> positionOrFlushSpecList))
construct<EndfileStmt>("END FILE" >> positionOrFlushSpecList))

// R1226 rewind-stmt -> REWIND file-unit-number | REWIND ( position-spec-list )
TYPE_CONTEXT_PARSER("REWIND statement"_en_US,
Expand Down
4 changes: 4 additions & 0 deletions flang/lib/Semantics/rewrite-parse-tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ bool RewriteMutator::Pre(parser::ExecutionPart &x) {
return true;
}

// Convert a syntactically ambiguous io-unit internal-file-variable to a
// file-unit-number.
void RewriteMutator::Post(parser::IoUnit &x) {
if (auto *var{std::get_if<parser::Variable>(&x.u)}) {
const parser::Name &last{parser::GetLastName(*var)};
Expand All @@ -118,11 +120,13 @@ void RewriteMutator::Post(parser::IoUnit &x) {
// If the Variable is not known to be character (any kind), transform
// the I/O unit in situ to a FileUnitNumber so that automatic expression
// constraint checking will be applied.
auto source{var->GetSource()};
auto expr{std::visit(
[](auto &&indirection) {
return parser::Expr{std::move(indirection)};
},
std::move(var->u))};
expr.source = source;
x.u = parser::FileUnitNumber{
parser::ScalarIntExpr{parser::IntExpr{std::move(expr)}}};
}
Expand Down
3 changes: 2 additions & 1 deletion flang/test/Semantics/call10.f90
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,9 @@ pure subroutine s12
close(1) ! C1597
!ERROR: External I/O is not allowed in a pure subprogram
backspace(1) ! C1597
!Also checks parsing of variant END FILE spelling
!ERROR: External I/O is not allowed in a pure subprogram
endfile(1) ! C1597
end file(1) ! C1597
!ERROR: External I/O is not allowed in a pure subprogram
rewind(1) ! C1597
!ERROR: External I/O is not allowed in a pure subprogram
Expand Down
3 changes: 3 additions & 0 deletions flang/test/Semantics/io04.f90
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@
!ERROR: If UNIT=* appears, REC must not appear
write(*, rec=13) 'Ok'

!ERROR: Must have INTEGER type, but is REAL(4)
write(unit, *) 'Ok'

!ERROR: If ADVANCE appears, UNIT=internal-file must not appear
write(internal_file, advance='yes', fmt=1) 'Ok'

Expand Down
4 changes: 4 additions & 0 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2581,7 +2581,11 @@ void DWARFASTParserClang::ParseSingleMember(
// The ObjC runtime knows the byte offset but we still need to provide
// the bit-offset in the layout. It just means something different then
// what it does in C and C++. So we skip this check for ObjC types.
//
// We also skip this for fields of a union since they will all have a
// zero offset.
if (!TypeSystemClang::IsObjCObjectOrInterfaceType(class_clang_type) &&
!(parent_die.Tag() == DW_TAG_union_type && this_field_info.bit_offset == 0) &&
((this_field_info.bit_offset >= parent_bit_size) ||
(last_field_info.IsBitfield() &&
!last_field_info.NextBitfieldOffsetIsValid(
Expand Down
10 changes: 10 additions & 0 deletions lldb/test/API/lang/cpp/bitfields/TestCppBitfields.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ def test_and_run_command(self):
self.expect("expr (clang_example.f.a)", VARIABLES_DISPLAYED_CORRECTLY,
substrs=['uint64_t', '1'])

self.expect("expr uwbf",
substrs=['a = 255',
'b = 65535',
'c = 4294967295',
'x = 4294967295'] )

self.expect("expr uwubf",
substrs=['a = 16777215',
'x = 4294967295'] )

self.expect(
"frame variable --show-types lba",
VARIABLES_DISPLAYED_CORRECTLY,
Expand Down
17 changes: 16 additions & 1 deletion lldb/test/API/lang/cpp/bitfields/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ int main(int argc, char const *argv[]) {
f.i = 1;
f.j = 0;
f.k = 1;
}
}
} clang_example;

class B {
Expand All @@ -70,6 +70,18 @@ int main(int argc, char const *argv[]) {
uint32_t d_a : 1;
} derived;

union union_with_bitfields {
unsigned int a : 8;
unsigned int b : 16;
unsigned int c : 32;
unsigned int x;
} uwbf;

union union_with_unnamed_bitfield {
unsigned int : 16, a : 24;
unsigned int x;
} uwubf;

lba.a = 2;

lbb.a = 1;
Expand All @@ -89,5 +101,8 @@ int main(int argc, char const *argv[]) {
derived.b_a = 2;
derived.d_a = 1;

uwbf.x = 0xFFFFFFFF;
uwubf.x = 0xFFFFFFFF;

return 0; // Set break point at this line.
}
1 change: 1 addition & 0 deletions llvm/include/llvm/IR/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ tablegen(LLVM IntrinsicsS390.h -gen-intrinsic-enums -intrinsic-prefix=s390)
tablegen(LLVM IntrinsicsWebAssembly.h -gen-intrinsic-enums -intrinsic-prefix=wasm)
tablegen(LLVM IntrinsicsX86.h -gen-intrinsic-enums -intrinsic-prefix=x86)
tablegen(LLVM IntrinsicsXCore.h -gen-intrinsic-enums -intrinsic-prefix=xcore)
tablegen(LLVM IntrinsicsVE.h -gen-intrinsic-enums -intrinsic-prefix=ve)
add_public_tablegen_target(intrinsics_gen)
1 change: 1 addition & 0 deletions llvm/include/llvm/IR/Intrinsics.td
Original file line number Diff line number Diff line change
Expand Up @@ -1649,3 +1649,4 @@ include "llvm/IR/IntrinsicsBPF.td"
include "llvm/IR/IntrinsicsSystemZ.td"
include "llvm/IR/IntrinsicsWebAssembly.td"
include "llvm/IR/IntrinsicsRISCV.td"
include "llvm/IR/IntrinsicsVE.td"
4 changes: 4 additions & 0 deletions llvm/include/llvm/IR/IntrinsicsVE.td
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Define intrinsics written by hand

// Define intrinsics automatically generated
include "llvm/IR/IntrinsicsVEVL.gen.td"
Loading

0 comments on commit cf10a01

Please sign in to comment.