Commit Graph

8939 Commits

Author SHA1 Message Date
Akira Hatanaka 85365cd72a Attach attribute "trap-func-name" to call sites of llvm.trap and llvm.debugtrap.
This is needed to use clang's command line option "-ftrap-function" for LTO and
enable changing the trap function name on a per-call-site basis.

rdar://problem/21225723

Differential Revision: http://reviews.llvm.org/D10831

llvm-svn: 241306
2015-07-02 22:15:41 +00:00
Benjamin Kramer 642f173ae9 Switch users of the 'for (StmtRange range = stmt->children(); range; ++range)‘ pattern to range for loops.
The pattern was born out of the lack of range-based for loops in C++98
and is somewhat obscure. No functionality change intended.

llvm-svn: 241300
2015-07-02 21:03:14 +00:00
Benjamin Kramer 9c218592c8 [CodeGen] Use llvm::join to simplify string joining.
While there replace stable_sort of std::string with just sort, stability
is not necessary for "simple" value types. No functional change intended.

llvm-svn: 241299
2015-07-02 21:02:39 +00:00
Justin Bogner 4dc5adc731 InstrProf: Add a comment to clarify an argument
llvm-svn: 241296
2015-07-02 20:47:25 +00:00
Yaron Keren 07d4496ab7 Remove whitespace from start of line, NFC.
llvm-svn: 241272
2015-07-02 14:44:35 +00:00
Alexey Bataev 80909878ad [OPENMP 4.0] Initial support for 'omp cancel' construct.
Implemented parsing/sema analysis + (de)serialization.

llvm-svn: 241253
2015-07-02 11:25:17 +00:00
Nico Weber e4f974c6fb Revert 241171, 241187, 241199 (32-bit SEH).
It still doesn't produce quite the right code, test binaries built with this
enabled fail some tests.

llvm-svn: 241244
2015-07-02 06:10:53 +00:00
Alexey Bataev 0f34da12e4 [OPENMP 4.0] Codegen for 'cancellation point' directive.
The next code is generated for this construct:
```
if (__kmpc_cancellationpoint(ident_t *loc, kmp_int32 global_tid, kmp_int32 cncl_kind) != 0)
  <exit from outer innermost construct>;
```

llvm-svn: 241239
2015-07-02 04:17:07 +00:00
Alexey Bataev 0039651304 [OPENMP] Introduced type trait "__builtin_omp_required_simd_align" for default simd alignment.
Adds type trait "__builtin_omp_required_simd_align" after discussions here http://reviews.llvm.org/D9894
Differential Revision: http://reviews.llvm.org/D10597

llvm-svn: 241237
2015-07-02 03:40:19 +00:00
Justin Bogner b05a43f59b InstrProf: Pack the coverage mapping structs that we write out
When we read this data we treat it as unaligned and packed, so we
should really be explicit about that when we write it.

llvm-svn: 241218
2015-07-02 00:42:32 +00:00
Reid Kleckner 698310b004 [SEH] Update EmitCapturedLocals to match r241187
It was still using frameaddress(1) to get the parent FP, even though it
had the value it wanted as a parameter.

llvm-svn: 241199
2015-07-01 22:33:45 +00:00
Reid Kleckner eb11c41900 [SEH] Delete the 32-bit IR lowering for __finally blocks and use x64
32-bit finally funclets are intended to be called both directly from the
parent function and indirectly from the EH runtime. Because we aren't
contorting LLVM's X86 prologue to match MSVC's, calling the finally
block directly passes in a different value of EBP than the one that the
runtime provides. We need an adapter thunk to adjust EBP to the expected
value. However, WinEHPrepare already has to solve this problem when
cleanups are not pre-outlined, so we can go ahead and rely on it rather
than duplicating work.

Now we only do the llvm.x86.seh.recoverfp dance for 32-bit SEH filter
functions.

llvm-svn: 241187
2015-07-01 21:00:00 +00:00
David Blaikie be822edf03 Revert "[DebugInfo] Fix debug info generation for function static variables, typedefs, and records"
Caused PR24008.

This reverts commit r241154.

llvm-svn: 241177
2015-07-01 18:07:22 +00:00
Reid Kleckner d0d9a1f63f [SEH] Add 32-bit lowering for SEH __try
This re-lands r236052 and adds support for __exception_code().

In 32-bit SEH, the exception code is not available in eax. It is only
available in the filter function, and now we arrange to load it and
store it into an escaped variable in the parent frame.

As a consequence, we have to disable the "catch i8* null" optimization
on 32-bit and always generate a filter function. We can re-enable the
optimization if we detect an __except block that doesn't use the
exception code, but this probably isn't worth optimizing.

Reviewers: majnemer

Differential Revision: http://reviews.llvm.org/D10852

llvm-svn: 241171
2015-07-01 17:10:10 +00:00
Michael Kuperstein def554db45 [DebugInfo] Fix debug info generation for function static variables, typedefs, and records
Function static variables, typedefs and records (class, struct or union) declared inside
a lexical scope were associated with the function as their parent scope, rather than the
lexical scope they are defined or declared in.

This fixes PR19238

Patch by: amjad.aboud@intel.com
Differential Revision: http://reviews.llvm.org/D9760

llvm-svn: 241154
2015-07-01 12:34:39 +00:00
Alexey Bataev 6d4ed05830 [OPENMP 4.0] Initial support for 'omp cancellation point' construct.
Add parsing and sema analysis for 'omp cancellation point' directive.

llvm-svn: 241145
2015-07-01 06:57:41 +00:00
Peter Collingbourne 8fabc1b47d CodeGen: Do not give local-linkage functions externally available linkage, even temporarily.
When an internal-linkage thunk is code gen'd, CodeGenVTables::emitThunk
will first be called with ForVTable=true (which incorrectly set the
thunk's linkage to available_externally under the Itanium ABI) and later
with ForVTable=false (which reset it to internal). Because we will always
see a call with ForVTable=false, this incorrect linkage never ended up in
the final IR. However, the temporary presence of this linkage caused us
to give such functions a comdat as a result of code introduced in r241102.
To avoid this, check that the thunk is externally visible before giving it
available_externally linkage.

llvm-svn: 241136
2015-07-01 02:10:26 +00:00
Eric Christopher 2374a7cba8 Use a stable sort to guarantee target feature ordering in the IR
in order to make testing somewhat more feasible. Has the advantage
of making it easier to find target features as well.

llvm-svn: 241134
2015-07-01 01:07:12 +00:00
Justin Bogner bdff219439 CodeGen: Resize LifetimeExtendedCleanupHeader to avoid alignment issues
The LifetimeExtendedCleanupHeader is carefully fit into 32 bytes,
meaning that cleanups on the LifetimeExtendedCleanupStack are *always*
allocated at a misaligned address and cause undefined behaviour.

There are two ways to solve this - add padding after the header when
we allocated our cleanups, or just simplify the header and let it use
64 bits in the first place. I've opted for the latter, and added a
static assert to avoid the issue in the future.

llvm-svn: 241133
2015-07-01 00:59:27 +00:00
Eric Christopher 2249b81697 Fix a TODO dealing with canonicalizing attributes on functions by
using a string map to canonicalize. Fix up a couple of testcases
that needed changing since we are no longer simply appending features
to the list, but all of their mask dependencies as well.

llvm-svn: 241129
2015-07-01 00:08:29 +00:00
Peter Collingbourne e286b0e1f2 Fix use-after-free.
llvm-svn: 241121
2015-06-30 22:08:44 +00:00
David Majnemer 63aa2fbec6 [MS ABI] Stick constructor closures in an IR COMDAT group
We no-longer stick linkonce_odr entities in COMDATs in the backend.
Instead, we rely on the IR COMDAT mechanism.

llvm-svn: 241117
2015-06-30 21:23:51 +00:00
Peter Collingbourne 45a2401c04 CodeGen: Assign an appropriate comdat to thunks.
Previously we were not assigning a comdat to thunks in the Microsoft ABI,
which would have required us to emit these functions outside of a comdat.
(Due to an inconsistency in how we were emitting objects, we were getting this
right most of the time, but only when compiling with function sections.) This
code generator change causes us to create a comdat for each thunk.

Differential Revision: http://reviews.llvm.org/D10829

llvm-svn: 241102
2015-06-30 19:07:26 +00:00
Adrian Prantl 2388eadbd8 Use an early exit to improve readability. (NFC)
llvm-svn: 241088
2015-06-30 18:01:05 +00:00
Adrian Prantl c4bb47e301 Debug Info: Emit debug info for @import declarations.
This allows a module-aware debugger such as LLDB to import the currently
visible modules before dropping into the expression evaluator.

rdar://problem/20965932

llvm-svn: 241084
2015-06-30 17:39:51 +00:00
David Majnemer 64b0bdf88a [CodeGen] Tweak isTriviallyRecursive further
isTriviallyRecursive is a hack used to bridge a gap between the
expectations that source code assumes and the semantics that LLVM IR can
provide.  Specifically, asm labels on functions are treated as an
explicit name for a GlobalObject in Clang but treated like an
output-processing step in GCC.  Tweak this hack a little further to emit
calls to library functions instead of emitting an incorrect definition.
The definition in question would have available_externally linkage (this
is OK) but result in a call to itself which will either result in an
infinite loop or stack overflow.

This fixes PR23964.

llvm-svn: 241043
2015-06-30 04:41:18 +00:00
David Majnemer 149e603132 [MS ABI] Workaround corner-case bug in the ABI for operator delete
MSVC only genreates array cookies if the class has a destructor.  This
is problematic when having to call T::operator delete[](void *, size_t)
because the second argument's argument is impossible to synthesize
correctly if the class has no destructor (because there will be no array
cookie).

Instead, MSVC passes the size of the class.  Do the same, for
compatibility, instead of crashing.

This fixes PR23990.

llvm-svn: 241038
2015-06-30 03:30:26 +00:00
Adrian Prantl e74f525bc9 Pass HeaderSearchOptions and PreprocessorOptions into CodeGenModule.
In order to produce debug info for clang modules CGDebugInfo it needs
access to macros passed on the command line and the isysroot.

llvm-svn: 241035
2015-06-30 02:26:03 +00:00
Eric Christopher d983270976 Add support for the x86 builtin __builtin_cpu_supports.
This matches the implementation of the gcc support for the same
feature, including checking the values set up by libgcc at runtime.
The structure looks like this:

  unsigned int __cpu_vendor;
  unsigned int __cpu_type;
  unsigned int __cpu_subtype;
  unsigned int __cpu_features[1];

with a set of enums to match various fields that are field out after
parsing the output of the cpuid instruction.
This also adds a set of errors checking for valid input (and cpu).

compiler-rt support for this and the other builtins in this family
(__builtin_cpu_init and __builtin_cpu_is) are forthcoming.

llvm-svn: 240994
2015-06-29 21:00:05 +00:00
David Majnemer 5682efd28c [CodeGen] Remove atomic sugar from record types in isSafeToConvert
We failed to see that we should have deferred the creation of a type
which references a type currently under construction because of atomic
sugar.

This fixes PR23985.

llvm-svn: 240989
2015-06-29 20:13:23 +00:00
Frederic Riss 275a38688e Delete unused variables.
llvm-svn: 240923
2015-06-29 04:41:58 +00:00
David Majnemer 0d9ad687c7 [MS ABI] Unify constant and non-constant member pointer conversion
We had two separate paths for member pointer conversion: one which
takes a constant and another which takes an arbitrary value.  In the
latter case, we are permitted to construct arbitrary instructions.

It turns out that the bulk of the member pointer conversion is sharable
if we construct an artificial IRBuilder.

llvm-svn: 240921
2015-06-29 00:06:50 +00:00
Nemanja Ivanovic 2f1f926e34 Add missing builtins to altivec.h for ABI compliance (vol. 1)
This patch corresponds to review:
http://reviews.llvm.org/D10637

This is the first round of additions of missing builtins listed in the ABI document. More to come (this builds onto what seurer already addes). This patch adds:
vector signed long long vec_abs(vector signed long long)
vector double vec_abs(vector double)
vector signed long long vec_add(vector signed long long, vector signed long long)
vector unsigned long long vec_add(vector unsigned long long, vector unsigned long long)
vector double vec_add(vector double, vector double)
vector double vec_and(vector bool long long, vector double)
vector double vec_and(vector double, vector bool long long)
vector double vec_and(vector double, vector double)
vector signed long long vec_and(vector signed long long, vector signed long long)
vector double vec_andc(vector bool long long, vector double)
vector double vec_andc(vector double, vector bool long long)
vector double vec_andc(vector double, vector double)
vector signed long long vec_andc(vector signed long long, vector signed long long)
vector double vec_ceil(vector double)
vector bool long long vec_cmpeq(vector double, vector double)
vector bool long long vec_cmpge(vector double, vector double)
vector bool long long vec_cmpge(vector signed long long, vector signed long long)
vector bool long long vec_cmpge(vector unsigned long long, vector unsigned long long)
vector bool long long vec_cmpgt(vector double, vector double)
vector bool long long vec_cmple(vector double, vector double)
vector bool long long vec_cmple(vector signed long long, vector signed long long)
vector bool long long vec_cmple(vector unsigned long long, vector unsigned long long)
vector bool long long vec_cmplt(vector double, vector double)
vector bool long long vec_cmplt(vector signed long long, vector signed long long)
vector bool long long vec_cmplt(vector unsigned long long, vector unsigned long long)

llvm-svn: 240821
2015-06-26 19:27:20 +00:00
Alex Denisov fde64956f9 [ObjC] Add NSValue support for objc_boxed_expressions
Patch extends ObjCBoxedExpr to accept records (structs and unions):

typedef struct __attribute__((objc_boxable)) _Color {
  int r, g, b;
} Color;

Color color;
NSValue *boxedColor = @(color); // [NSValue valueWithBytes:&color objCType:@encode(Color)];

llvm-svn: 240761
2015-06-26 05:28:36 +00:00
Davide Italiano 982bbf404e [Sema] Commit a better fix for r240242
Skip calls to HasTrivialDestructorBody() in the case where the
destructor is never invoked. Alternatively, Richard proposed to change
Sema to declare a trivial destructor for anonymous union member, which
seems too wasteful.

Differential Revision:	http://reviews.llvm.org/D10508

llvm-svn: 240742
2015-06-26 00:18:35 +00:00
David Majnemer 41011f6706 [CodeGen] Restrict isTriviallyRecursive to predefined lib functions forwarding to lib functions
isTriviallyRecursive is only supposed to guard functions part of the
implementation.

This fixes PR23953.

llvm-svn: 240735
2015-06-25 23:50:40 +00:00
Diego Novillo 5aecacb275 Display profile file name when emitting a file not found diagnostic.
When a profile file cannot be opened, we used to display just the error
message but not the name of the profile the compiler was trying to open.
This will become useful in the next set of patches that introduce
GCC-compatible flags to specify profiles.

llvm-svn: 240715
2015-06-25 22:56:00 +00:00
Artem Belevich d21e5c6684 [CUDA] Implemented __nvvm_atom_*_gen_* builtins.
Integer variants are implemented as atomicrmw or cmpxchg instructions.
Atomic add for floating point (__nvvm_atom_add_gen_f()) is implemented
as a call to an overloaded @llvm.nvvm.atomic.load.add.f32.* LVVM
intrinsic.

Differential Revision: http://reviews.llvm.org/D10666

llvm-svn: 240669
2015-06-25 18:29:42 +00:00
Paul Robinson 6a7511bea9 Omit 'nodebug' methods from the class description.
llvm-svn: 240664
2015-06-25 17:50:43 +00:00
Derek Schuff 5ec5128f64 update comment
llvm-svn: 240601
2015-06-24 22:36:38 +00:00
Derek Schuff 3c6a48d119 Relax assertion in x86_64 byval argument handling for 32-bit pointers
Summary:
Byval argument pair formation assumes that if a type is less than 8 bytes
it must be an integer and not a pointer, which is not true for x32 and NaCl.

Relax the assertion and add a test for a codegen case that triggered it.

Reviewers: jvoung

Subscribers: jfb, cfe-commits

Differential Revision: http://reviews.llvm.org/D10701

llvm-svn: 240600
2015-06-24 22:36:36 +00:00
Alexey Bataev 1d2353d4f3 [OPENMP] Codegen for 'depend' clause (OpenMP 4.0).
If task directive has associated 'depend' clause then function kmp_int32 __kmpc_omp_task_with_deps ( ident_t *loc_ref, kmp_int32 gtid, kmp_task_t * new_task, kmp_int32 ndeps, kmp_depend_info_t *dep_list,kmp_int32 ndeps_noalias, kmp_depend_info_t *noalias_dep_list) must be called instead of __kmpc_omp_task().
If this directive has associated 'if' clause then also before a call of kmpc_omp_task_begin_if0() a function void __kmpc_omp_wait_deps ( ident_t *loc_ref, kmp_int32 gtid, kmp_int32 ndeps, kmp_depend_info_t *dep_list, kmp_int32 ndeps_noalias, kmp_depend_info_t *noalias_dep_list) must be called.
Array sections are not supported yet.

llvm-svn: 240532
2015-06-24 11:01:36 +00:00
Bob Wilson 63c931443d Move the special-case check from r240462 into ARM-specific code.
This fixes a serious bug in r240462: checking the BuiltinID for
ARM::BI_MoveToCoprocessor* in EmitBuiltinExpr() ignores the fact that
each target has an overlapping range of the BuiltinID values. That check
can trigger for builtins from other targets, leading to very bad
behavior.

Part of the reason I did not implement r240462 this way to begin with is
the special handling of the last argument for Neon builtins. In this
change, I have factored out the check to see which builtins have that
extra argument into a new HasExtraNeonArgument() function. There is still
some awkwardness in having to check for those builtins in two separate
places, i.e., once to see if the extra argument is present and once to
generate the appropriate IR, but this seems much cleaner than my previous
patch.

llvm-svn: 240522
2015-06-24 06:05:20 +00:00
Alexey Bataev d157d47062 Proper changing/restoring for CapturedStmtInfo, NFC.
Added special RAII class for proper values changing/restoring in CodeGenFunction::CapturedStmtInfo.

llvm-svn: 240517
2015-06-24 03:35:38 +00:00
Bob Wilson 09aa90bbe1 PR22560: Fix argument order for ARM _MoveToCoprocessor builtins.
The Microsoft-extension _MoveToCoprocessor and _MoveToCoprocessor2
builtins take the register value to be moved as the first argument,
but the corresponding mcr and mcr2 LLVM intrinsics expect that value
to be the third argument. Handle this as a special case, while still
leaving those intrinsics as generic MSBuiltins. I considered the
alternative of handling these in EmitARMBuiltinExpr, but that does
not work well for the follow-up change that I'm going to make to improve
the error handling for PR22560 -- we need the GetBuiltinType() checks
for ICEArguments, and the ARM version of that code is only used for
Neon intrinsics where the last argument is special and not
checked in the normal way.

llvm-svn: 240462
2015-06-23 21:10:15 +00:00
David Majnemer 08ef2ba113 [MS ABI] Account for the virtual inheritance quirk when mangling
Virtual inheritance member pointers are always relative to the vbindex,
even when the member pointer doesn't point into a virtual base.  This is
corrected by adjusting the non-virtual offset backwards from the vbptr
back to the top of the most derived class.  While we performed this
adjustment when manifesting member pointers as constants or when
performing conversions, we didn't perform the adjustment when mangling
them.

llvm-svn: 240453
2015-06-23 20:34:18 +00:00
Justin Bogner e44dd6dbd0 InstrProf: Fix a crash when an implicit def appears in a macro
llvm-svn: 240452
2015-06-23 20:29:09 +00:00
Alexey Bataev 1c2cfbc3ea [OPENMP] Initial support for 'depend' clause (4.0).
Parsing and sema analysis (without support for array sections in arguments) for 'depend' clause (used in 'task' directive, OpenMP 4.0).

llvm-svn: 240409
2015-06-23 14:25:19 +00:00
Rafael Espindola b633d20d36 Update for LLVM api change.
llvm-svn: 240406
2015-06-23 13:59:36 +00:00
Yaron Keren b76cb044f1 Silence VC warning C4715: '`anonymous namespace'::getNativeVectorSizeForA VXABI' :
not all control paths return a value.

llvm-svn: 240389
2015-06-23 09:45:42 +00:00