UnstableChanges

Summary

  1. [PowerPC] Fix va_arg in C++, Objective-C on 32-bit ELF targets (details)
  2. [Analysis] Use llvm::append_range (NFC) (details)
  3. [llvm] Use isAlpha/isAlnum (NFC) (details)
  4. [llvm] Use static_assert instead of assert (NFC) (details)
  5. [ASan] Stop blocking child thread progress from parent thread in `pthread_create` interceptor. (details)
Commit 018984ae6833fae107aa9c502ab5536efceca88e by brad
[PowerPC] Fix va_arg in C++, Objective-C on 32-bit ELF targets

In the PPC32 SVR4 ABI, a va_list has copies of registers from the function call.
va_arg looked in the wrong registers for (the pointer representation of) an
object in Objective-C, and for some types in C++. Fix va_arg to look in the
general-purpose registers, not the floating-point registers. Also fix va_arg
for some C++ types, like a member function pointer, that are aggregates for
the ABI.

Anthony Richardby found the problem in Objective-C. Eli Friedman suggested
part of this fix.

Fixes https://bugs.llvm.org/show_bug.cgi?id=47921

Reviewed By: efriedma, nemanjai

Differential Revision: https://reviews.llvm.org/D90329
The file was modifiedclang/lib/CodeGen/TargetInfo.cpp
The file was addedclang/test/CodeGenCXX/ppc32-varargs-method.cpp
The file was addedclang/test/CodeGenObjC/ppc32-varargs-id.m
Commit a3254904b28cbc392baa8011f1da8172538ff077 by kazu
[Analysis] Use llvm::append_range (NFC)
The file was modifiedllvm/lib/Analysis/BasicAliasAnalysis.cpp
The file was modifiedllvm/lib/Analysis/DependenceGraphBuilder.cpp
The file was modifiedllvm/lib/Analysis/ValueTracking.cpp
The file was modifiedllvm/lib/Analysis/DDG.cpp
The file was modifiedllvm/lib/Analysis/DevelopmentModeInlineAdvisor.cpp
The file was modifiedllvm/lib/Analysis/LoopNestAnalysis.cpp
The file was modifiedllvm/lib/Analysis/LoopCacheAnalysis.cpp
The file was modifiedllvm/lib/Analysis/MustExecute.cpp
The file was modifiedllvm/lib/Analysis/MemoryDependenceAnalysis.cpp
Commit 5f843b2dd2ee1f36162a861ef02b2b4bc4dc79b7 by kazu
[llvm] Use isAlpha/isAlnum (NFC)
The file was modifiedllvm/lib/Support/YAMLParser.cpp
The file was modifiedllvm/utils/TableGen/AsmMatcherEmitter.cpp
The file was modifiedllvm/lib/MC/MCAsmInfo.cpp
The file was modifiedllvm/utils/TableGen/AsmWriterEmitter.cpp
The file was modifiedllvm/utils/TableGen/AsmWriterInst.cpp
The file was modifiedllvm/lib/IR/Mangler.cpp
The file was modifiedllvm/include/llvm/Bitstream/BitCodes.h
Commit 49231c1f80803ae0f15963cce708cedf6e44088f by kazu
[llvm] Use static_assert instead of assert (NFC)

Identified with misc-static-assert.
The file was modifiedllvm/utils/TableGen/X86DisassemblerTables.cpp
The file was modifiedllvm/include/llvm/IR/InstrTypes.h
The file was modifiedllvm/lib/Support/SHA1.cpp
The file was modifiedllvm/lib/Object/XCOFFObjectFile.cpp
The file was modifiedllvm/lib/Target/X86/X86InsertPrefetch.cpp
The file was modifiedllvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp
Commit 596d534ac3524052df210be8d3c01a33b2260a42 by Dan Liew
[ASan] Stop blocking child thread progress from parent thread in `pthread_create` interceptor.

Previously in ASan's `pthread_create` interceptor we would block in the
`pthread_create` interceptor waiting for the child thread to start.

Unfortunately this has bad performance characteristics because the OS
scheduler doesn't know the relationship between the parent and child
thread (i.e. the parent thread cannot make progress until the child
thread makes progress) and may make the wrong scheduling decision which
stalls progress.

It turns out that ASan didn't use to block in this interceptor but was
changed to do so to try to address
http://llvm.org/bugs/show_bug.cgi?id=21621/.

In that bug the problem being addressed was a LeakSanitizer false
positive. That bug concerns a heap object being passed
as `arg` to `pthread_create`. If:

* The calling thread loses a live reference to the object (e.g.
  `pthread_create` finishes and the thread no longer has a live
  reference to the object).
* Leak checking is triggered.
* The child thread has not yet started (once it starts it will have a
  live reference).

then the heap object will incorrectly appear to be leaked.

This bug is covered by the `lsan/TestCases/leak_check_before_thread_started.cpp` test case.

In b029c5101fb49b3577a1c322f42ef9fc616f25bf ASan was changed to block
in `pthread_create()` until the child thread starts so that `arg` is
kept alive for the purposes of leaking check.

While this change "works" its problematic due to the performance
problems it causes. The change is also completely unnecessary if leak
checking is disabled (via detect_leaks runtime option or
CAN_SANITIZE_LEAKS compile time config).

This patch does two things:

1. Takes a different approach to solving the leak false positive by
   making LSan's leak checking mechanism treat the `arg` pointer of
   created but not started threads as reachable.  This is done by
   implementing the `ForEachRegisteredThreadContextCb` callback for
   ASan.

2. Removes the blocking behaviour in the ASan `pthread_create`
   interceptor.

rdar://problem/63537240

Differential Revision: https://reviews.llvm.org/D95184
The file was modifiedcompiler-rt/lib/asan/asan_interceptors.cpp
The file was modifiedcompiler-rt/lib/asan/asan_thread.cpp
The file was modifiedcompiler-rt/lib/asan/asan_allocator.cpp
The file was modifiedcompiler-rt/lib/asan/asan_thread.h