History log of /llvm-project/clang/lib/CodeGen/CGExprConstant.cpp (Results 26 – 50 of 538)
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 8bd1f911 26-Mar-2024 Akira Hatanaka <ahatanak@gmail.com>

[CodeGen][arm64e] Add methods and data members to Address, which are needed to authenticate signed pointers (#67454)

To authenticate pointers, CodeGen needs access to the key and
discriminators tha

[CodeGen][arm64e] Add methods and data members to Address, which are needed to authenticate signed pointers (#67454)

To authenticate pointers, CodeGen needs access to the key and
discriminators that were used to sign the pointer. That information is
sometimes known from the context, but not always, which is why `Address`
needs to hold that information.

This patch adds methods and data members to `Address`, which will be
needed in subsequent patches to authenticate signed pointers, and uses
the newly added methods throughout CodeGen. Although this patch isn't
strictly NFC as it causes CodeGen to use different code paths in some
cases (e.g., `mergeAddressesInConditionalExpr`), it doesn't cause any
changes in functionality as it doesn't add any information needed for
authentication.

In addition to the changes mentioned above, this patch introduces class
`RawAddress`, which contains a pointer that we know is unsigned, and
adds several new functions for creating `Address` and `LValue` objects.

show more ...


Revision tags: llvmorg-18.1.2, llvmorg-18.1.1, llvmorg-18.1.0, llvmorg-18.1.0-rc4, llvmorg-18.1.0-rc3
# 5c57fd71 15-Feb-2024 Chris B <chris.bieneman@me.com>

[HLSL] Vector standard conversions (#71098)

HLSL supports vector truncation and element conversions as part of
standard conversion sequences. The vector truncation conversion is a C++
second conve

[HLSL] Vector standard conversions (#71098)

HLSL supports vector truncation and element conversions as part of
standard conversion sequences. The vector truncation conversion is a C++
second conversion in the conversion sequence. If a vector truncation is
in a conversion sequence an element conversion may occur after it before
the standard C++ third conversion.

Vector element conversions can be boolean conversions, floating point or
integral conversions or promotions.

[HLSL Draft
Specification](https://microsoft.github.io/hlsl-specs/specs/hlsl.pdf)

---------

Co-authored-by: Aaron Ballman <aaron@aaronballman.com>

show more ...


Revision tags: llvmorg-18.1.0-rc2
# c61686e8 30-Jan-2024 Timm Bäder <tbaeder@redhat.com>

[clang][NFC] Use no-param version of skipRValueSubobjectAdjustments

when possible.


Revision tags: llvmorg-18.1.0-rc1
# ad1a65fc 27-Jan-2024 cor3ntin <corentinjabot@gmail.com>

[Clang][C++26] Implement Pack Indexing (P2662R3). (#72644)

Implements https://isocpp.org/files/papers/P2662R3.pdf

The feature is exposed as an extension in older language modes.
Mangling is not

[Clang][C++26] Implement Pack Indexing (P2662R3). (#72644)

Implements https://isocpp.org/files/papers/P2662R3.pdf

The feature is exposed as an extension in older language modes.
Mangling is not yet supported and that is something we will have to do before release.

show more ...


Revision tags: llvmorg-19-init, llvmorg-17.0.6
# d8c40800 23-Nov-2023 Youngsuk Kim <joseph942010@gmail.com>

[clang][CGExprConstant] Remove no-op ptr-to-ptr bitcast (NFC)

Remove a call to `getPointerCast` which is effectively does a no-op ptr-to-ptr
bitcast.

Opaque ptr clean-up effort.


Revision tags: llvmorg-17.0.5
# 5532d67a 02-Nov-2023 Youngsuk Kim <youngsuk.kim@hpe.com>

[clang] Remove no-op ptr-to-ptr bitcasts (NFC)

Opaque ptr cleanup effort (NFC)


# 50848916 01-Nov-2023 Nikita Popov <npopov@redhat.com>

[CGExprConstant] Avoid use of ConstantExpr::getIntegerCast() (NFC)

We're working on a ConstantInt here, so folding cannot fail. Only
avoid the API use.


Revision tags: llvmorg-17.0.4
# b45236f1 30-Oct-2023 DaPorkchop_ <daporkchop@daporkchop.net>

[clang] Implement constexpr bit_cast for vectors (#66894)

This makes __builtin_bit_cast support converting to and from vector
types in a constexpr context.


# d9b15b06 30-Oct-2023 Nick Desaulniers <nickdesaulniers@users.noreply.github.com>

[CGExprConstant] stop calling into ConstExprEmitter for Reference type destinations (#70366)

Fixes a bug introduced by
commit b54294e2c959 ("[clang][ConstantEmitter] have
tryEmitPrivate[ForVarInit]

[CGExprConstant] stop calling into ConstExprEmitter for Reference type destinations (#70366)

Fixes a bug introduced by
commit b54294e2c959 ("[clang][ConstantEmitter] have
tryEmitPrivate[ForVarInit] try ConstExprEmitter fast-path first")

In the added test case, the QualType is a LValueReferenceType.

LValueReferenceType 0x558412998d90 'const char (&)[41]'
`-ParenType 0x558412998d30 'const char[41]' sugar
`-ConstantArrayType 0x558412998cf0 'const char[41]' 41
`-QualType 0x55841294c271 'const char' const
`-BuiltinType 0x55841294c270 'char'

Fixes: #69979

show more ...


Revision tags: llvmorg-17.0.3, llvmorg-17.0.2
# fb2bdbb8 28-Sep-2023 Nikita Popov <npopov@redhat.com>

[CodeGen] Avoid use of ConstantExpr::getZExt() (NFC)

Use the constant folding API instead. In preparation for dropping
zext constant expressions.


Revision tags: llvmorg-17.0.1, llvmorg-17.0.0, llvmorg-17.0.0-rc4
# 89bf39b0 23-Aug-2023 Bjorn Pettersson <bjorn.a.pettersson@ericsson.com>

[clang][CGExprConstant] Resolve unused variable 'C' warning


Revision tags: llvmorg-17.0.0-rc3, llvmorg-17.0.0-rc2
# 2f3fe3ed 02-Aug-2023 Jonas Hahnfeld <jonas.hahnfeld@cern.ch>

[CodeGen] Remove Constant arguments from linkage functions, NFCI.

This was unused since commit dd2362a8ba last year.

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


Revision tags: llvmorg-17.0.0-rc1
# 19f2b680 29-Jul-2023 David Blaikie <dblaikie@gmail.com>

Make globals with mutable members non-constant, even in custom sections

Turned out we were making overly simple assumptions about which sections (& section flags) would be used when emitting a globa

Make globals with mutable members non-constant, even in custom sections

Turned out we were making overly simple assumptions about which sections (& section flags) would be used when emitting a global into a custom section. This lead to sections with read-only flags being used for globals of struct types with mutable members.

Fixed by porting the codegen function with the more nuanced handling/checking for mutable members out of codegen for use in the sema code that does this initial checking/mapping to section flags.

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

show more ...


# f6267d3b 07-Aug-2023 Nick Desaulniers <ndesaulniers@google.com>

[clang][CGExprConstant] handle implicit widening/narrowing Int-to-Int casts

Consider the following statements:
long x = 1;
short y = 1;

With the following AST:
|-VarDecl 0x55d289973730

[clang][CGExprConstant] handle implicit widening/narrowing Int-to-Int casts

Consider the following statements:
long x = 1;
short y = 1;

With the following AST:
|-VarDecl 0x55d289973730 <x.c:1:1, col:10> col:6 x 'long' cinit
| `-ImplicitCastExpr 0x55d289973800 <col:10> 'long' <IntegralCast>
| `-IntegerLiteral 0x55d2899737e0 <col:10> 'int' 1
`-VarDecl 0x55d289973830 <line:2:1, col:11> col:7 y 'short' cinit
`-ImplicitCastExpr 0x55d2899738b8 <col:11> 'short' <IntegralCast>
`-IntegerLiteral 0x55d289973898 <col:11> 'int' 1

Sign or Zero extend or truncate based on the source signedness and
destination width.

Reviewed By: efriedma

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

show more ...


# 769333ae 07-Aug-2023 Nick Desaulniers <ndesaulniers@google.com>

[clang][CGExprConstant] handle unary negation on integrals

Consider the statement:
int x = -1;
And the following AST:
`-VarDecl 0x55c4823a7670 <x.c:2:1, col:10> col:5 x 'int' cinit
`-U

[clang][CGExprConstant] handle unary negation on integrals

Consider the statement:
int x = -1;
And the following AST:
`-VarDecl 0x55c4823a7670 <x.c:2:1, col:10> col:5 x 'int' cinit
`-UnaryOperator 0x55c4823a7740 <col:9, col:10> 'int' prefix '-'
`-IntegerLiteral 0x55c4823a7720 <col:10> 'int' 1

Return the evaluation of the subexpression negated.

Reviewed By: efriedma

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

show more ...


# 2c26397f 26-Jul-2023 Nick Desaulniers <ndesaulniers@google.com>

[clang][ConstExprEmitter] handle NullToPointer ImplicitCastExpr

Consider the following statement:
void* foo = ((void *)0);

For the sub-AST:
| `-ImplicitCastExpr 'const void *' <NullToPointe

[clang][ConstExprEmitter] handle NullToPointer ImplicitCastExpr

Consider the following statement:
void* foo = ((void *)0);

For the sub-AST:
| `-ImplicitCastExpr 'const void *' <NullToPointer>
| `-CStyleCastExpr 'void *' <NullToPointer>
| `-IntegerLiteral 'int' 0

If the subexpression of the cast is itself the NULL constant, then
ImplicitCastExpr should emit the NULL pointer constant.

Reviewed By: efriedma

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

show more ...


# d1199808 25-Jul-2023 Nick Desaulniers <ndesaulniers@google.com>

[clang][ConstExprEmitter] handle ArrayToPointerDecay ImplicitCastExpr of StringLiterals

Consider the following statement:
const char* foo = "foo";

For the sub-AST:
`-ImplicitCastExpr <col:1

[clang][ConstExprEmitter] handle ArrayToPointerDecay ImplicitCastExpr of StringLiterals

Consider the following statement:
const char* foo = "foo";

For the sub-AST:
`-ImplicitCastExpr <col:19> 'const char *' <NoOp>
`-ImplicitCastExpr <col:19> 'char *' <ArrayToPointerDecay>
`-StringLiteral <col:19> 'char[4]' lvalue "foo"

The address of the StringLiteral can be emitted as the Constant.

Reviewed By: efriedma

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

show more ...


# 15a484bf 25-Jul-2023 Nick Desaulniers <ndesaulniers@google.com>

[clang][ConstExprEmitter] handle IntegerLiterals

Improves the ability of ConstExprEmitter to evaluate constants.

Found by adding asserts to ConstantEmitter::tryEmitPrivate to find cases
where Const

[clang][ConstExprEmitter] handle IntegerLiterals

Improves the ability of ConstExprEmitter to evaluate constants.

Found by adding asserts to ConstantEmitter::tryEmitPrivate to find cases
where ConstExprEmitter::Visit() fails to resolve (obvious) constants.

Reviewed By: efriedma

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

show more ...


Revision tags: llvmorg-18-init
# b54294e2 24-Jul-2023 Nick Desaulniers <ndesaulniers@google.com>

[clang][ConstantEmitter] have tryEmitPrivate[ForVarInit] try ConstExprEmitter fast-path first

As suggested by @efriedma in:
https://reviews.llvm.org/D76096#4370369

This should speed up evaluating w

[clang][ConstantEmitter] have tryEmitPrivate[ForVarInit] try ConstExprEmitter fast-path first

As suggested by @efriedma in:
https://reviews.llvm.org/D76096#4370369

This should speed up evaluating whether an expression is constant or
not, but due to the complexity of these two different implementations,
we may start getting different answers for edge cases for which we do
not yet have test cases in-tree (or perhaps even performance regressions
for some cases). As such, contributors have carte blanche to revert if
necessary.

For additional historical context about ExprConstant vs CGExprConstant,
here's snippets from a private conversation on discord:

ndesaulniers:
why do we have clang/lib/AST/ExprConstant.cpp and
clang/lib/CodeGen/CGExprConstant.cpp? Does clang constant fold during
ast walking/creation AND during LLVM codegen?
efriedma:
originally, clang needed to handle two things: integer constant
expressions (the "5" in "int x[5];"), and constant global initializers
(the "5" in "int x = 5;"). pre-C++11, the two could be handled mostly
separately; so we had the code for integer constants in AST/, and the
code for globals in CodeGen/. C++11 constexpr sort of destroyed that
separation, though. so now we do both kinds of constant evaluation on
the AST, then CGExprConstant translates the result of that evaluation
to LLVM IR. but we kept around some bits of the old cgexprconstant to
avoid performance/memory usage regressions on large arrays.

Reviewed By: efriedma

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

show more ...


# 0f4d48d7 16-Jun-2023 Youngsuk Kim <youngsuk.kim@hpe.com>

[clang] Replace use of Type::getPointerTo() (NFC)

Partial progress towards replacing in-tree uses of `Type::getPointerTo()`.
This needs to be done before deprecating the API.

Reviewed By: nikic, ba

[clang] Replace use of Type::getPointerTo() (NFC)

Partial progress towards replacing in-tree uses of `Type::getPointerTo()`.
This needs to be done before deprecating the API.

Reviewed By: nikic, barannikov88

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

show more ...


# 0211a75e 14-Jun-2023 Nikita Popov <npopov@redhat.com>

[Clang] Rename getElementBitCast() -> withElementType() (NFC)

This no longer creates a bitcast, just changes the element type
of the ConstantAddress.


Revision tags: llvmorg-16.0.6, llvmorg-16.0.5
# c3e7c6e9 26-May-2023 Manna, Soumi <soumi.manna@intel.com>

[NFC][CLANG] Fix static code analyzer concerns

Reported by Static Code Analyzer Tool:

Inside "CGExprConstant.cpp" file, VisitObjCEncodeExpr() returns null value which is dereferenced without checki

[NFC][CLANG] Fix static code analyzer concerns

Reported by Static Code Analyzer Tool:

Inside "CGExprConstant.cpp" file, VisitObjCEncodeExpr() returns null value which is dereferenced without checking.

This patch adds an assert.

Reviewed By: erichkeane

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

show more ...


# 67960537 23-May-2023 Akira Hatanaka <ahatanaka@apple.com>

[CodeGen] Fix the type of the constant that is used to zero-initialize a
flexible array member

A zero-element array type was incorrectly being used when an incomplete
array was being initialized wit

[CodeGen] Fix the type of the constant that is used to zero-initialize a
flexible array member

A zero-element array type was incorrectly being used when an incomplete
array was being initialized with a non-empty initializer.

This fixes an assertion failure in AddInitializerToStaticVarDecl. See
the discussion here: https://reviews.llvm.org/D123649#4362210

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

show more ...


Revision tags: llvmorg-16.0.4, llvmorg-16.0.3
# 71332838 02-May-2023 Mariya Podchishchaeva <mariya.podchishchaeva@intel.com>

[clang] Do not attempt to zero-extend _BitInt(1) when not required

`ConvertTypeForMem` doesn't return wider type for _BitInt unless it is
used in a bitfield, so no need to extend when trying to init

[clang] Do not attempt to zero-extend _BitInt(1) when not required

`ConvertTypeForMem` doesn't return wider type for _BitInt unless it is
used in a bitfield, so no need to extend when trying to initialize a
global variable.

Fixes https://github.com/llvm/llvm-project/issues/62207

Reviewed By: erichkeane, shafik

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

show more ...


Revision tags: llvmorg-16.0.2, llvmorg-16.0.1, llvmorg-16.0.0, llvmorg-16.0.0-rc4
# 7a85aa91 06-Mar-2023 Hans Wennborg <hans@chromium.org>

Emit const globals with constexpr destructor as constant LLVM values

This follows 2b4fa53 which made Clang not emit destructor calls for such
objects. However, they would still not get emitted as co

Emit const globals with constexpr destructor as constant LLVM values

This follows 2b4fa53 which made Clang not emit destructor calls for such
objects. However, they would still not get emitted as constants since
CodeGenModule::isTypeConstant() returns false if the destructor is
constexpr. This change adds a param to make isTypeConstant() ignore the
dtor, allowing the caller to check it instead.

Fixes Issue #61212

Differential revision: https://reviews.llvm.org/D145369

show more ...


12345678910>>...22