Commit Graph

12 Commits

Author SHA1 Message Date
James Y Knight f5f1b0e59e [opaque pointer types] Cleanup CGBuilder's Create*GEP.
Some of these functions take some extraneous arguments, e.g. EltSize,
Offset, which are computable from the Type and DataLayout.

Add some asserts to ensure that the computed values are consistent
with the passed-in values, in preparation for eliminating the
extraneous arguments. This also asserts that the Type is an Array for
the calls named "Array" and a Struct for the calls named "Struct".

Then, correct a couple of errors:

1. Using CreateStructGEP on an array type. (this causes the majority
   of the test differences, as struct GEPs are created with i32
   indices, while array GEPs are created with i64 indices)

2. Passing the wrong Offset to CreateStructGEP in TargetInfo.cpp on
   x86-64 NACL (which uses 32-bit pointers).

Differential Revision: https://reviews.llvm.org/D57766

llvm-svn: 353529
2019-02-08 15:34:12 +00:00
Erich Keane cb54964f80 Fix __builtin_*_overflow when out-param isn't constexpr
As brought up on cfe-commits[1], r334650 causes the dependency of the
out parameter to the __builtin_*_overflow functions to be ignored. The result
was a usage that was otherwise constexpr (both operands to the operation were
constexpr) would be evaluated, but the out parameter wouldn't be modified, so
it would still be 'undef'.

This patch correctly handles the return value of handleAssignment to ensure that
this value is properly considered/evaluated.

[1] http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20180702/233667.html

llvm-svn: 336364
2018-07-05 15:52:58 +00:00
Richard Smith 5e29dd3fe0 P0426: Make the library implementation of constexpr char_traits a little easier
by providing a memchr builtin that returns char* instead of void*.

Also add a __has_feature flag to indicate the presence of constexpr forms of
the relevant <string> functions.

llvm-svn: 292555
2017-01-20 00:45:35 +00:00
NAKAMURA Takumi 9f6383c741 clang/test/CodeGenCXX/builtins.cpp: Fix for -Asserts.
- Don't seek "entry:" It dosen't appear with -Asserts.
  - Take care that Codegen'ed Instruction(s) wouldn't have name(s) in -Asserts.

llvm-svn: 193908
2013-11-02 02:58:42 +00:00
Warren Hunt 5d80bfa746 Adding triple to lit test fixed in r193901
llvm-svn: 193902
2013-11-02 00:34:45 +00:00
Warren Hunt 4349ec4e03 Fixes lit test that doesn't fail on windows
long in linux 64 is 64 bits but is always 32 bits on windows.  The lit test was modified 
to use long long instead of long and check for 64-bit mangling.

llvm-svn: 193901
2013-11-02 00:12:15 +00:00
Warren Hunt 445d83eb47 Wraps lazily generated builtins in an extern "C" context
Differential Revision: http://llvm-reviews.chandlerc.com/D2082

Adds a lang_c LinkageSpecDecl to lazily generated builtins. This enforces correct 
behavior for builtins in a variety of cases without special treatment elsewhere within 
the compiler (special treatment is removed by the patch). It also allows for C++ 
overloads of builtin functions, which Microsoft uses in their headers e.g. 
_InterlockedExchangeAdd is an extern C builtin for the long type but an inline wrapper 
for int type.

llvm-svn: 193896
2013-11-01 23:46:51 +00:00
Richard Smith 6cbd65d84d Add a __builtin_addressof that performs the same functionality as the built-in
& operator (ignoring any overloaded operator& for the type). The purpose of
this builtin is for use in std::addressof, to allow it to be made constexpr;
the existing implementation technique (reinterpret_cast to some reference type,
take address, reinterpert_cast back) does not permit this because
reinterpret_cast between reference types is not permitted in a constant
expression in C++11 onwards.

llvm-svn: 186053
2013-07-11 02:27:57 +00:00
Tim Northover dd9809dd72 Permit ABIs where the caller extends the result (test change).
This test was written to make sure *something* sane is generated, not
to test any ABI's signedness semantics.

This should allow the test to pass if AArch64 is the default target.

llvm-svn: 174618
2013-02-07 15:11:36 +00:00
Eli Friedman 34866c7719 Change the representation of builtin functions in the AST
(__builtin_* etc.) so that it isn't possible to take their address.
Specifically, introduce a new type to represent a reference to a builtin
function, and a new cast kind to convert it to a function pointer in the
operand of a call.  Fixes PR13195.

llvm-svn: 162962
2012-08-31 00:14:07 +00:00
Douglas Gregor e0e9630e07 When extracting the callee declaration from a call expression, be sure
to look through SubstNonTypeTemplateParmExprs. Then, update the IR
generation of CallExprs to actually use CallExpr::getCalleeDecl()
rather than attempting to mimick its behavior (badly).

Fixes <rdar://problem/10063539>.

llvm-svn: 139185
2011-09-06 21:41:04 +00:00
Douglas Gregor 9246b6830a In C++, if the user redeclares a builtin function with a type that is
inconsistent with the type that the builtin *should* have, forget
about the builtin altogether: we don't want subsequence analyses,
CodeGen, etc., to think that we have a proper builtin function.

C is protected from errors here because it allows one to use a
library builtin without having a declaration, and detects inconsistent
(re-)declarations of builtins during declaration merging. C++ was
unprotected, and therefore would crash.

Fixes PR8839.

llvm-svn: 122351
2010-12-21 19:47:46 +00:00