mirror-llvm-project/clang/lib/CodeGen
Daniil Kovalev 2f8eb5b4be
[clang][llvm][AArch64] Set hardening fn attrs on synthetic functions (#211013)
Compiler-synthesized functions such as `__llvm_gcov_writeout`,
`__llvm_gcov_reset` and `__llvm_gcov_init` were previously never
receiving the AArch64 hardening function attributes (ptrauth-returns,
ptrauth-auth-traps, ptrauth-indirect-gotos and
aarch64-jump-table-hardening) since the attributes were only emitted by
Clang and gated by `PointerAuthOptions` structure's corresponding
fields. See `setPointerAuthFnAttributes` and
`initPointerAuthFnAttributes` member functions of `TargetCodeGenInfo`.

This patch resolves this in the same manner as #83153 does for several
other attributes. Particularly, Clang now emits corresponding 4 module
flags (conditionally on whether the related feature is enabled) with Max
behavior, and LLVM's `Function::createWithDefaultAttr` derives the
matching function attributes from them. Max behavior with conditional
emission is safe because none of these features affect ABI, so promoting
an absent flag on module merge cannot break compatibility.
2026-07-31 18:22:44 +00:00
..
TargetBuiltins [AMDGPU] Add ptr.s.buffer.load intrinsic, use it from Clang (#209243) 2026-07-30 09:27:28 -07:00
Targets IR: Use LongDoubleFormat enum for long-double-type module flag (#213056) 2026-07-30 19:26:07 +02:00
ABIInfo.cpp [SystemZ][Clang] Add support for the z/OS va_list type (#202397) 2026-07-09 14:12:34 -04:00
ABIInfo.h Reland "[clang][CodeGen][X86_64] Honor per-function AVX ABI in C/C++ call paths, maintain old psABI for PlayStation." (#210349) 2026-07-21 09:04:03 -07:00
ABIInfoImpl.cpp Reapply "[clang] remove lots of "innocuous" addrspacecasts" (#200427) 2026-06-03 10:41:23 -04:00
ABIInfoImpl.h
Address.h
BackendConsumer.h [RFC][CodeGen] Add generic target feature checks for intrinsics (#201470) 2026-06-29 22:41:15 -04:00
BackendUtil.cpp [Clang][LTO] Assign GUIDs after post-opt bitcode linking (#211155) 2026-07-22 09:12:48 -04:00
CGAtomic.cpp [clang] builtins for atomicrmw fminmax/_num (#187139) 2026-06-28 18:15:26 +02:00
CGBlocks.cpp Reapply "[clang] remove lots of "innocuous" addrspacecasts" (#200427) 2026-06-03 10:41:23 -04:00
CGBlocks.h
CGBuilder.h [HLSL] Handle logical pointer for array assign (#193227) 2026-04-27 13:51:29 +02:00
CGBuiltin.cpp [clang] fix __builtin_clear_padding not working with virtual base pointers on Windows (#211355) 2026-07-25 09:35:45 +01:00
CGBuiltin.h [CUDA] Use monotonic ordering for __nvvm_atom* builtins (#185822) 2026-03-12 09:48:09 -07:00
CGCall.cpp Reland "[clang][CodeGen][X86_64] Honor per-function AVX ABI in C/C++ call paths, maintain old psABI for PlayStation." (#210349) 2026-07-21 09:04:03 -07:00
CGCall.h [CMake][CodeGen] Add PCH for Clang CodeGen (#206018) 2026-06-26 12:52:40 +02:00
CGClass.cpp Reland "[clang][CodeGen][X86_64] Honor per-function AVX ABI in C/C++ call paths, maintain old psABI for PlayStation." (#210349) 2026-07-21 09:04:03 -07:00
CGCleanup.cpp [clang] use QualType addrspace when making an alloca (#181390) 2026-05-12 16:46:51 -04:00
CGCleanup.h [WinEH] Fix crash when deleting C++ objects inside SEH __try (#180144) 2026-04-30 00:43:04 +08:00
CGCoroutine.cpp [CodeGen] Set attributes on coroutine wrapper functions (#207961) 2026-07-08 09:09:45 +02:00
CGCUDANV.cpp [clang][cuda] Use the source filename for module ID (#209239) 2026-07-14 09:30:54 -07:00
CGCUDARuntime.cpp Reland "[clang][CodeGen][X86_64] Honor per-function AVX ABI in C/C++ call paths, maintain old psABI for PlayStation." (#210349) 2026-07-21 09:04:03 -07:00
CGCUDARuntime.h [CUDA] Add device-side kernel launch support (#165519) 2025-12-01 17:45:10 +00:00
CGCXX.cpp [CUDA][HIP] Defer device diagnostics in implicit H+D explicit instantiations (#197214) 2026-05-27 14:12:55 -04:00
CGCXXABI.cpp [clang][NFC][diagnostics] Remove most usage of getCustomDiagID() from CodeGen (#172557) 2025-12-21 08:17:19 -05:00
CGCXXABI.h Reland [MS][clang] Add support for vector deleting destructors (#170337) 2025-12-12 09:54:32 +01:00
CGDebugInfo.cpp [IR][NFC] Rename insertDbgValueIntrinsic -> insertDbgValue (#212151) 2026-07-27 12:42:46 +02:00
CGDebugInfo.h [Clang][BPF] Support btf_type_tag on typedef underlying types (#203089) 2026-06-15 10:51:02 -07:00
CGDecl.cpp [Clang] [C++26] Expansion Statements (P1306R5) (#169680) 2026-07-11 00:01:08 +02:00
CGDeclCXX.cpp Reland "[clang][CodeGen][X86_64] Honor per-function AVX ABI in C/C++ call paths, maintain old psABI for PlayStation." (#210349) 2026-07-21 09:04:03 -07:00
CGException.cpp [WebAssembly] Call EH personality function instead of Unwind_CallPersonality (#209282) 2026-07-28 20:05:45 -07:00
CGExpr.cpp Reland "[clang][CodeGen][X86_64] Honor per-function AVX ABI in C/C++ call paths, maintain old psABI for PlayStation." (#210349) 2026-07-21 09:04:03 -07:00
CGExprAgg.cpp [HLSL] Implement codegen for copying cbuffer structs with resources (#204232) 2026-06-29 14:23:29 -07:00
CGExprComplex.cpp Reland "[clang][CodeGen][X86_64] Honor per-function AVX ABI in C/C++ call paths, maintain old psABI for PlayStation." (#210349) 2026-07-21 09:04:03 -07:00
CGExprConstant.cpp [clang][ExprConst] Support virtual bases in C++26 (#204289) 2026-07-15 15:08:31 +02:00
CGExprCXX.cpp Reland "[clang][CodeGen][X86_64] Honor per-function AVX ABI in C/C++ call paths, maintain old psABI for PlayStation." (#210349) 2026-07-21 09:04:03 -07:00
CGExprScalar.cpp [clang] Add flag for making pointer subtraction defined (#196392) 2026-07-21 12:44:23 +02:00
CGGPUBuiltin.cpp [CodeGen] Use getAllOnesValue() for -1 constants 2025-12-16 09:48:38 +01:00
CGHLSLBuiltins.cpp [HLSL] Move cross implementation to header files (#211446) 2026-07-29 15:26:05 -07:00
CGHLSLRuntime.cpp [HLSL][SPIRV] Support Flat and Location decorators in the frontend (#210116) 2026-07-21 15:20:45 -04:00
CGHLSLRuntime.h [HLSL] Move cross implementation to header files (#211446) 2026-07-29 15:26:05 -07:00
CGLoopInfo.cpp Enforce single-operand form for llvm.loop.distribute metadata (#201077) 2026-07-21 12:55:09 +05:30
CGLoopInfo.h [clang] Pragma for llvm.loop.licm.disable (#188108) 2026-03-25 09:12:21 -07:00
CGNonTrivialStruct.cpp
CGObjC.cpp [clang] Implement -fstrict-bool (#160790) 2026-04-22 11:24:22 +00:00
CGObjCGNU.cpp [ObjC] Emit number, array, and dictionary literals as constants (#185130) 2026-03-25 15:03:14 -07:00
CGObjCMac.cpp Reapply [IR] Explicitly specify target feature for module asm (#204548) (#207677) 2026-07-06 11:57:38 +02:00
CGObjCMacConstantLiteralUtil.h [clang][clang-tools-extra] Remove unused DenseMapInfo::getEmptyKey (#201987) 2026-06-06 13:38:23 -07:00
CGObjCRuntime.cpp Reland "[clang][CodeGen][X86_64] Honor per-function AVX ABI in C/C++ call paths, maintain old psABI for PlayStation." (#210349) 2026-07-21 09:04:03 -07:00
CGObjCRuntime.h [ObjCDirectPreconditionThunk] precondition check thunk generation (#170618) 2026-03-30 10:32:09 -07:00
CGOpenCLRuntime.cpp [CGOpenCLRuntime] Remove dead code (#183093) 2026-02-25 12:46:11 +01:00
CGOpenCLRuntime.h [CGOpenCLRuntime] Remove dead code (#183093) 2026-02-25 12:46:11 +01:00
CGOpenMPRuntime.cpp [OpenMP] Split UPDATE clause into two: for ATOMIC and for DEPOBJ (#212270) 2026-07-29 07:30:31 -05:00
CGOpenMPRuntime.h [OpenMP] Split UPDATE clause into two: for ATOMIC and for DEPOBJ (#212270) 2026-07-29 07:30:31 -05:00
CGOpenMPRuntimeGPU.cpp clang: Use proper error for unified shared memory openmp error (#212750) 2026-07-30 19:53:25 +00:00
CGOpenMPRuntimeGPU.h
CGPointerAuth.cpp [lldb] Support arm64e C++ vtable pointer signing (#187611) 2026-03-25 12:08:02 -05:00
CGPointerAuthInfo.h
CGRecordLayout.h
CGRecordLayoutBuilder.cpp
CGStmt.cpp [Clang] [C++26] Expansion Statements (P1306R5) (#169680) 2026-07-11 00:01:08 +02:00
CGStmtOpenMP.cpp Revert "[OpenMP] Restore loop variable values after loop-transformation constructs. (#212853)" (#213127) 2026-07-30 20:49:00 +00:00
CGValue.h [Codegen] Initialize RValue IsVolatile field in constructor (#195556) 2026-05-04 13:27:07 -07:00
CGVTables.cpp Reland "[clang][CodeGen][X86_64] Honor per-function AVX ABI in C/C++ call paths, maintain old psABI for PlayStation." (#210349) 2026-07-21 09:04:03 -07:00
CGVTables.h [clang] Consolidate the relative vtable layout getters (#139315) 2026-04-02 10:33:05 -07:00
CGVTT.cpp
CMakeLists.txt [CMake][CodeGen] Add PCH for Clang CodeGen (#206018) 2026-06-26 12:52:40 +02:00
CodeGenABITypes.cpp Reland "[clang][CodeGen][X86_64] Honor per-function AVX ABI in C/C++ call paths, maintain old psABI for PlayStation." (#210349) 2026-07-21 09:04:03 -07:00
CodeGenAction.cpp [RFC][CodeGen] Add generic target feature checks for intrinsics (#201470) 2026-06-29 22:41:15 -04:00
CodeGenFunction.cpp [BoundsSafety] Introduce LateParsedAttrType AST placeholder type (#204125) 2026-07-23 11:44:49 -07:00
CodeGenFunction.h Reland "[clang][CodeGen][X86_64] Honor per-function AVX ABI in C/C++ call paths, maintain old psABI for PlayStation." (#210349) 2026-07-21 09:04:03 -07:00
CodeGenModule.cpp [clang][llvm][AArch64] Set hardening fn attrs on synthetic functions (#211013) 2026-07-31 18:22:44 +00:00
CodeGenModule.h [clang] Emit call graph type metadata for internal linkage symbols (#210194) 2026-07-18 08:59:20 -07:00
CodeGenPGO.cpp [clang] remove addrspace cast from CreateIRTemp (#179327) 2026-02-04 13:09:32 -05:00
CodeGenPGO.h [clang][coverage] Introduce hasSkipCounter instead of getIsCounterPair (#178397) 2026-01-29 07:45:47 +09:00
CodeGenSYCL.cpp [clang][SYCL] Emit "sycl-module-id" function attribute (#195965) 2026-05-06 15:37:30 -07:00
CodeGenTBAA.cpp [Matrix] Use matrix element type for TBAA nodes. (#190029) 2026-04-03 20:11:04 +00:00
CodeGenTBAA.h [Clang] Emit struct TBAA for llvm.errno.tbaa (#201375) 2026-06-30 08:39:54 +00:00
CodeGenTypeCache.h [clang] use QualType addrspace when making an alloca (#181390) 2026-05-12 16:46:51 -04:00
CodeGenTypes.cpp clang: Use getFloatingPointType instead of reinventing it (#207213) 2026-07-06 20:30:21 +00:00
CodeGenTypes.h Reland "[clang][CodeGen][X86_64] Honor per-function AVX ABI in C/C++ call paths, maintain old psABI for PlayStation." (#210349) 2026-07-21 09:04:03 -07:00
ConstantEmitter.h
ConstantInitBuilder.cpp
CoverageMappingGen.cpp [llvm,clang] Don't assume non-erased DenseMap entries remain valid after erase. NFC (#198982) 2026-05-24 10:25:38 -07:00
CoverageMappingGen.h
EHScopeStack.h [WinEH] Fix crash when deleting C++ objects inside SEH __try (#180144) 2026-04-30 00:43:04 +08:00
HLSLBufferLayoutBuilder.cpp [HLSL] Implement codegen for copying cbuffer structs with resources (#204232) 2026-06-29 14:23:29 -07:00
HLSLBufferLayoutBuilder.h [HLSL] Implement codegen for copying cbuffer structs with resources (#204232) 2026-06-29 14:23:29 -07:00
ItaniumCXXABI.cpp Reland "[clang][CodeGen][X86_64] Honor per-function AVX ABI in C/C++ call paths, maintain old psABI for PlayStation." (#210349) 2026-07-21 09:04:03 -07:00
LinkInModulesPass.cpp
LinkInModulesPass.h [PassManager] Make passes inherit from RequiredPassInfoMixin/OptionalPassInfoMixin (#192120) 2026-05-06 10:00:07 -07:00
MacroPPCallbacks.cpp
MacroPPCallbacks.h
MCDCState.h [MC/DC] Create dedicated MCDCCondBitmapAddr for each Decision (#125411) 2026-01-15 09:08:06 +09:00
MicrosoftCXXABI.cpp Reland "[clang][CodeGen][X86_64] Honor per-function AVX ABI in C/C++ call paths, maintain old psABI for PlayStation." (#210349) 2026-07-21 09:04:03 -07:00
ModuleBuilder.cpp Add limited vtable address querying to clang::CodeGenerator (#202807) 2026-06-23 10:16:59 -07:00
ModuleLinker.cpp [CIR] Add Support for linking bitcode modules on cc1 (#196245) 2026-05-22 13:54:39 -04:00
ObjectFilePCHContainerWriter.cpp
PatternInit.cpp [PatternInit] Explicitly allow implicit truncation 2025-12-17 12:48:50 +01:00
PatternInit.h
pch.h [CMake][CodeGen] Add PCH for Clang CodeGen (#206018) 2026-06-26 12:52:40 +02:00
QualTypeMapper.cpp [LLVMABI] Introduce the QualTypeMapper (#174634) 2026-03-08 20:18:49 +05:30
QualTypeMapper.h [clang] Integrate LLVMABI for function call ABI lowering (#194460) 2026-05-07 16:28:10 +05:30
README.txt [NFC] Fix "is is" typos (#206288) 2026-07-06 18:07:45 +00:00
SanitizerHandler.h [ubsan] Change "Type mismatch in operation" trap reason to "Alignment, null, or object-size error" (#169752) 2025-11-27 10:03:25 -08:00
SanitizerMetadata.cpp
SanitizerMetadata.h
SwiftCallingConv.cpp
TargetInfo.cpp [IR] Make semantics of strictfp consistent v2 (#211769) 2026-07-24 18:02:54 +00:00
TargetInfo.h [SystemZ][z/OS] Add XPLink ABI on z/OS (#188501) 2026-06-02 13:32:56 -04:00
TrapReasonBuilder.cpp
TrapReasonBuilder.h
VarBypassDetector.cpp
VarBypassDetector.h

IRgen optimization opportunities.

//===---------------------------------------------------------------------===//

The common pattern of
--
short x; // or char, etc
(x == 10)
--
generates an zext/sext of x which can easily be avoided.

//===---------------------------------------------------------------------===//

Bitfields accesses can be shifted to simplify masking and sign
extension. For example, if the bitfield width is 8 and it is
appropriately aligned then it is a lot shorter to just load the char
directly.

//===---------------------------------------------------------------------===//

It may be worth avoiding creation of alloca's for formal arguments
for the common situation where the argument is never written to or has
its address taken. The idea would be to begin generating code by using
the argument directly and if its address is taken or it is stored to
then generate the alloca and patch up the existing code.

In theory, the same optimization could be a win for block local
variables as long as the declaration dominates all statements in the
block.

NOTE: The main case we care about this for is for -O0 -g compile time
performance, and in that scenario we will need to emit the alloca
anyway currently to emit proper debug info. So this is blocked by
being able to emit debug information which refers to an LLVM
temporary, not an alloca.

//===---------------------------------------------------------------------===//

We should try and avoid generating basic blocks which only contain
jumps. At -O0, this penalizes us all the way from IRgen (malloc &
instruction overhead), all the way down through code generation and
assembly time.

On 176.gcc:expr.ll, it looks like over 12% of basic blocks are just
direct branches!

//===---------------------------------------------------------------------===//