Renato Golin [Mon, 19 May 2014 18:15:42 +0000 (18:15 +0000)]
Non-allocatable Global Named Register
This patch implements global named registers in Clang, lowering to the just
created intrinsics in LLVM (@llvm.read/write_register). A new type of LValue
had to be created (Register), which just adds support to carry the metadata
node containing the name of the register. Two new methods to emit loads and
stores interoperate with another to emit the named metadata node.
No guarantees are being made and only non-allocatable global variable named
registers are being supported. Local named register support is unchanged.
Aaron Ballman [Mon, 19 May 2014 17:58:28 +0000 (17:58 +0000)]
Removing an XFAIL which shouldn't apply. We no longer care about MSVC 9, and this test probably should not have been XFAILed everywhere regardless. The test passes on Windows with MSVC 12.
Ben Langmuir [Mon, 19 May 2014 17:04:28 +0000 (17:04 +0000)]
Don't refresh stat() info for pcm files
Follow-up fix for 209138. Actually, since we already have this file
open, we don't want to refresh the stat() info, since that might be
newer than what we have open (bad!).
Ben Langmuir [Mon, 19 May 2014 16:13:45 +0000 (16:13 +0000)]
Fix use-after-free and spurious error during module load
FileManager::invalidateCache is not safe to call when there may be
existing references to the file. What module load failure needs is
to refresh so stale stat() info isn't stored.
This may be the last user of invalidateCache; I'll take a look and
remove it if possible in a future commit.
This caused a use-after-free error as well as a spurious error message
that a module was "found in both 'X.pcm' and 'X.pcm'" in some cases.
Aaron Ballman [Mon, 19 May 2014 15:02:10 +0000 (15:02 +0000)]
This test is XFAILed on Windows, but I cannot see a reason as to why it should be failing. The original commit which XFAILed this was r111581, which suggested something was wrong with file remapping, but that may have been subsequently fixed.
Removing the XFAIL, but will watch the build bots to see if any go red because of this. Local testing on Windows succeeds.
Oliver Stannard [Mon, 19 May 2014 13:10:05 +0000 (13:10 +0000)]
ARM: PCS non-compliance when struct is padded to avoid register/stack split, and requires internal padding
When we were padding a struct to avoid splitting it between registers and
the stack, we were throwing away the type which the argument should be coerced
to.
Alp Toker [Sun, 18 May 2014 18:38:28 +0000 (18:38 +0000)]
Ongoing RAV reunification
* Shuffle around code to reduce delta between the two RAVs.
* Merge r189185 that was applied only to one of the RAVs and became apparent during the unification work.
* Fix Enqueue data recursion typo.
Alp Toker [Sun, 18 May 2014 18:38:19 +0000 (18:38 +0000)]
Format the two RecursiveASTVisitors
Apply current ToT clang-format on the two RAVs to reduce delta and help
identify differences between the two.
We lose a little pretty formatting in the headers but that's the price to pay
so we can diff these two files effectively and look to a future where we don't
have to maintain two copies of this code.
Alp Toker [Sun, 18 May 2014 18:38:08 +0000 (18:38 +0000)]
Begin RAV reunification: s/DataRecursiveASTVisitor/RecursiveASTVisitor/
Define a macro to reduce the delta between RecursiveASTVisitor and
DataRecursiveASTVisitor.
Some years ago, someone thought it was a good idea to copy the entire RAV to
support cursor visitation in libclang.
Since then the two have diverged needlessly and the rest is history.
This series of commits aims to reduce delta between the two so that we can
reason about their differences, apply bugfixes that were only made to one but
not the other, and ultimately find a way to unify two two chunks of code.
Driver: force restricted IT blocks for Windows on ARM
Windows on ARM expects ARMv8 (restricted IT) conditional instructions only.
Force enable the restricted IT mode via the backend option when targeting WoA.
These are now treated as environments. Remove references to these enumeration
values in order to clean up the unused enumeration entries in LLVM. The target
normalisation prior to tool invocation should ensure that the old values
continue to function properly.
Richard Smith [Sat, 17 May 2014 04:36:39 +0000 (04:36 +0000)]
More fixes for isBetterOverloadCandidate not being a strict weak ordering. The
bug was obvious from inspection, figuring out a way to test it was... less so.
Richard Smith [Sat, 17 May 2014 01:58:45 +0000 (01:58 +0000)]
Correct incoherent function versus function template partial ordering for conversion operators (the comparison could claim that two conversion operators are both better than each other). Actually implement DR495, rather than passing its test by chance because the declarations happened to be in the "lucky" order.
Richard Smith [Fri, 16 May 2014 23:01:30 +0000 (23:01 +0000)]
If a declaration is loaded, and then a module import adds a redeclaration, then
ensure that querying the first declaration for its most recent declaration
checks for redeclarations from the imported module.
This works as follows:
* The 'most recent' pointer on a canonical declaration grows a pointer to the
external AST source and a generation number (space- and time-optimized for
the case where there is no external source).
* Each time the 'most recent' pointer is queried, if it has an external source,
we check whether it's up to date, and update it if not.
* The ancillary data stored on the canonical declaration is allocated lazily
to avoid filling it in for declarations that end up being non-canonical.
We'll still perform a redundant (ASTContext) allocation if someone asks for
the most recent declaration from a decl before setPreviousDecl is called,
but such cases are probably all bugs, and are now easy to find.
Some finessing is still in order here -- in particular, we use a very general
mechanism for handling the DefinitionData pointer on CXXRecordData, and a more
targeted approach would be more compact.
Also, the MayHaveOutOfDateDef mechanism should now be expunged, since it was
addressing only a corner of the full problem space here. That's not covered
by this patch.
Early performance benchmarks show that this makes no measurable difference to
Clang performance without modules enabled (and fixes a major correctness issue
with modules enabled). I'll revert if a full performance comparison shows any
problems.
Rafael Espindola [Fri, 16 May 2014 19:35:48 +0000 (19:35 +0000)]
Update for llvm api change.
Now that llvm cannot represent alias cycles, we have to diagnose erros just
before trying to close the cycle. This degrades the errors a bit. The real
solution is what it was before: if we want to provide good errors for these
cases, we have to be able to find a clang level decl given a mangled name
and produce the error from Sema.
InstrProf: Look for the PIC-version of the profile runtime
If `-shared` is specified, pull in a PIC-version of the profile runtime,
which was added to compiler-rt in r208947. I'm hoping this will get the
bots on my side.
Richard Smith [Fri, 16 May 2014 02:14:42 +0000 (02:14 +0000)]
Push implicitly-declared allocation functions into the IdResolver. Otherwise,
declaration merging in modules is unable to find them and we get bogus errors
and even crashes.
Shared objects are fairly broken for InstrProf right now -- a follow-up
commit in compiler-rt will fix the rest of this.
The main problem here is that at link time, profile data symbols in the
shared object might get used instead of symbols from the main
executable, creating invalid profile data sections.
Hans Wennborg [Fri, 16 May 2014 00:09:31 +0000 (00:09 +0000)]
test/CodeGenCXX/dllexport.cpp: we already correctly emit b() even when
it's not used, because CodeGenModule::EmitGlobal consults
ASTContext::DeclMustBeEmitted via CodeGenModule::MayDeferGeneration.
Reid Kleckner [Thu, 15 May 2014 23:01:46 +0000 (23:01 +0000)]
MS ABI: Use musttail for thunk IR generation
This allows us to perfectly forward non-trivial arguments that use
inalloca.
We still can't forward non-trivial arguments through thunks when we have
a covariant return type with a non-trivial adjustment. This would
require emitting an extra copy, which is non-conforming anyway.
Ben Langmuir [Thu, 15 May 2014 16:20:33 +0000 (16:20 +0000)]
Use the virtual name of headers when searching for a module
When using the VFS, we want the virtual header location when searching
for a framework module, since that will be the one in the correct
directory structure for the module.
I'll add a regression test once I finish reducing the larger one I have.
Reid Kleckner [Thu, 15 May 2014 01:26:32 +0000 (01:26 +0000)]
Revert Itanium parts of "Don't copy objects with trivial, deleted copy ctors"
This undoes half of r208786.
It had problems with lazily declared special members in cases like this:
struct A {
A();
A &operator=(A &&o);
void *p;
};
void foo(A);
void bar() {
foo({});
}
In this case, the copy and move constructors are implicitly deleted.
However, Clang doesn't eagerly declare the copy ctor in the AST, so we
pass the struct in registers. Furthermore, GCC passes this in registers
even though this class should be uncopyable.
Richard Smith [Wed, 14 May 2014 23:23:27 +0000 (23:23 +0000)]
PR19742: cv-qualifiers and ref-qualifiers aren't allowed on functions within
pointer and reference types, even if those types are produced by template
instantiation.
Reid Kleckner [Wed, 14 May 2014 16:02:09 +0000 (16:02 +0000)]
Don't copy objects with trivial, deleted copy ctors
This affects both the Itanium and Microsoft C++ ABIs.
This is in anticipation of a change to the Itanium C++ ABI, and should
match GCC's current behavior. The new text will likely be:
"""
Pass an object of class type by value if every copy constructor and
move constructor is deleted or trivial and at least one of them is not
deleted, and the destructor is trivial.
"""
http://sourcerytools.com/pipermail/cxx-abi-dev/2014-May/002728.html
On x86 Windows, we can mostly use the same logic, where we use inalloca
instead of passing by address. However, on Win64, there are register
parameters, and we have to do what MSVC does. MSVC ignores the presence
of non-trivial move constructors and only considers the presence of
non-trivial or deleted copy constructors. If a non-trivial or deleted
copy ctor is present, it passes the argument indirectly.
This change fixes bugs and makes us more ABI compatible with both GCC
and MSVC.
David Blaikie [Wed, 14 May 2014 00:29:00 +0000 (00:29 +0000)]
DebugInfo: Avoid creating DILexicalScopeFiles when the filename in the current scope has not changed.
This looks like the right way for this check to work, but there is
another semi-obvious bug, I would think: why is CurLoc not zero'd out
between functions? The possibility for it to bleed between them seems
problematic. (& indeed I caused tests to fail when I fixed this a
different way, by setting CurLoc to SourceLocation() and the end of
EmitFunctionEnd... )
The changes to debug-info-blocks.m are due to a mismatch between the
source manager's file naming and CGDebugInfo's default handling when no
-main-file-name is specified. This actually reveals somewhat of a bug in
the debug info when using source files from standard in, too. See the
comment in CGDebugInfo::CreateCompileUnit for more details.
Reid Kleckner [Tue, 13 May 2014 22:05:45 +0000 (22:05 +0000)]
Push record return type classification into CGCXXABI
In the Microsoft C++ ABI, instance methods always return records
indirectly via the second hidden parameter. This was implemented in
X86_32ABIInfo, but not WinX86_64ABIInfo.
Rather than exposing a handful of boolean methods in the CGCXXABI
interface, we can expose a single method that applies C++ ABI return
value classification rules.
Richard Smith [Tue, 13 May 2014 19:56:21 +0000 (19:56 +0000)]
PR19729: Delete a bunch of bogus code in Sema::FindAllocationOverload. This
caused us to perform copy-initialization for the parameters of an allocation
function called by a new-expression multiple times, resulting in us rejecting
allocations that passed non-copyable parameters (and much worse things in
MSVC compat mode, where we potentially called this function multiple times).
Aaron Ballman [Tue, 13 May 2014 16:12:14 +0000 (16:12 +0000)]
Fix the AST printer for attributed statements so that it does not print duplicate attribute introducers. Eg) [[clang::fallthrough]] instead of [[[[clang::fallthrough]]]]