Skip to content

[asan][x86] Abort instrumenting memintrinsics that target registers fs, gs #129284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 123 commits into from

Conversation

cheezeburglar
Copy link
Contributor

For #124238

Currently code such as

#include "stdint.h"
void test(uintptr_t addr) {
	__builtin_memcpy(( void __seg_fs*)addr, "x", 1);
}

and

...
call void @llvm.memcpy.p257.p0.i64(ptr addrspace(257) align 1 %4, ptr align 1 @.str, i64 1, i1 false)
...

are miscompiled by ASan. When any of mem{set, cpy, move} are intercepted, by ASan, the writes to fs and gs are effectively scrubbed from the calls to ASan's runtime. This commit just causes AddressSanitizer to bail when on instrumenting these sorts of memory intrinsics.

@llvmbot
Copy link
Member

llvmbot commented Feb 28, 2025

@llvm/pr-subscribers-llvm-transforms

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Thor Preimesberger (cheezeburglar)

Changes

For #124238

Currently code such as

#include "stdint.h"
void test(uintptr_t addr) {
	__builtin_memcpy(( void __seg_fs*)addr, "x", 1);
}

and

...
call void @<!-- -->llvm.memcpy.p257.p0.i64(ptr addrspace(257) align 1 %4, ptr align 1 @.str, i64 1, i1 false)
...

are miscompiled by ASan. When any of mem{set, cpy, move} are intercepted, by ASan, the writes to fs and gs are effectively scrubbed from the calls to ASan's runtime. This commit just causes AddressSanitizer to bail when on instrumenting these sorts of memory intrinsics.


Full diff: https://github.com/llvm/llvm-project/pull/129284.diff

2 Files Affected:

  • (modified) llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp (+12)
  • (added) llvm/test/Instrumentation/AddressSanitizer/X86/bug_124238.ll (+60)
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index 8d8d56035a48f..ea360a1e623d4 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -797,6 +797,7 @@ struct AddressSanitizer {
                                  bool IsWrite, size_t AccessSizeIndex,
                                  Value *SizeArgument, uint32_t Exp,
                                  RuntimeCallInserter &RTCI);
+  bool maybeIgnoreMemIntrinsic (MemIntrinsic *MI, const Triple &TargetTriple);
   void instrumentMemIntrinsic(MemIntrinsic *MI, RuntimeCallInserter &RTCI);
   Value *memToShadow(Value *Shadow, IRBuilder<> &IRB);
   bool suppressInstrumentationSiteForDebug(int &Instrumented);
@@ -1340,10 +1341,21 @@ Value *AddressSanitizer::memToShadow(Value *Shadow, IRBuilder<> &IRB) {
     return IRB.CreateAdd(Shadow, ShadowBase);
 }
 
+bool AddressSanitizer::maybeIgnoreMemIntrinsic (MemIntrinsic *MI, const Triple &TargetTriple)
+{
+  // Ignore FS and GS registers to prevent miscompilation
+  if (MI->getDestAddressSpace() >= 256
+      && TargetTriple.getArch() == Triple::x86_64)
+    return true;
+  return false;
+}
+
 // Instrument memset/memmove/memcpy
 void AddressSanitizer::instrumentMemIntrinsic(MemIntrinsic *MI,
                                               RuntimeCallInserter &RTCI) {
   InstrumentationIRBuilder IRB(MI);
+  if (maybeIgnoreMemIntrinsic(MI, TargetTriple))
+    return;
   if (isa<MemTransferInst>(MI)) {
     RTCI.createRuntimeCall(
         IRB, isa<MemMoveInst>(MI) ? AsanMemmove : AsanMemcpy,
diff --git a/llvm/test/Instrumentation/AddressSanitizer/X86/bug_124238.ll b/llvm/test/Instrumentation/AddressSanitizer/X86/bug_124238.ll
new file mode 100644
index 0000000000000..ce82bc48563a0
--- /dev/null
+++ b/llvm/test/Instrumentation/AddressSanitizer/X86/bug_124238.ll
@@ -0,0 +1,60 @@
+; RUN: opt -passes=asan %s -S | FileCheck %s
+
+;; Punt AddressSanitizer::instrumentMemIntrinsics out for MemIntrinsics
+;; that need write to unsupported registers on X86
+;; PR124238: https://www.github.com/llvm/llvm-project/issues/124238
+
+target triple = "x86_64-unknown-linux-gnu"
+
+$.str.658906a285b7a0f82dabd9915e07848c = comdat any
+@.str = internal constant { [2 x i8], [30 x i8] } { [2 x i8] c"x\00", [30 x i8] zeroinitializer }, comdat($.str.658906a285b7a0f82dabd9915e07848c), align 32
+@0 = private alias { [2 x i8], [30 x i8] }, ptr @.str
+
+define void @test_memcpy(i64 noundef %addr) sanitize_address #0 {
+entry:
+  %addr.addr = alloca i64, align 8
+  store i64 %addr, ptr %addr.addr, align 8
+  %0 = load i64, ptr %addr.addr, align 8
+  %1 = inttoptr i64 %0 to ptr addrspace(257)
+  call void @llvm.memcpy.p257.p0.i64(ptr addrspace(257) align 1 %1, ptr align 1 @.str, i64 1, i1 false)
+; CHECK: llvm.memcpy
+  %2 = load i64, ptr %addr.addr, align 8
+  %3 = inttoptr i64 %2 to ptr addrspace(256)
+  call void @llvm.memcpy.p256.p0.i64(ptr addrspace(256) align 1 %3, ptr align 1 @.str, i64 1, i1 false)
+; CHECK: llvm.memcpy
+  ret void
+}
+
+define void @test_memset(i64 noundef %addr) sanitize_address #0 {
+entry:
+  %addr.addr = alloca i64, align 8
+  store i64 %addr, ptr %addr.addr, align 8
+  %0 = load i64, ptr %addr.addr, align 8
+  %1 = inttoptr i64 %0 to ptr addrspace(257)
+  call void @llvm.memset.p257.i64(ptr addrspace(257) align 1 %1, i8 0, i64 1, i1 false)
+; CHECK: llvm.memset
+  %2 = load i64, ptr %addr.addr, align 8
+  %3 = inttoptr i64 %2 to ptr addrspace(256)
+  call void @llvm.memset.p256.i64(ptr addrspace(256) align 1 %3, i8 0, i64 1, i1 false)
+; CHECK: llvm.memset
+  ret void
+}
+
+define void @test_memmove(i64 noundef %addr) sanitize_address #0 {
+entry:
+  %addr.addr = alloca i64, align 8
+  store i64 %addr, ptr %addr.addr, align 8
+  %0 = load i64, ptr %addr.addr, align 8
+  %1 = inttoptr i64 %0 to ptr addrspace(257)
+  %2 = load i64, ptr %addr.addr, align 8
+  %3 = inttoptr i64 %2 to ptr
+  call void @llvm.memmove.p257.p0.i64(ptr addrspace(257) align 1 %1, ptr align 1 %3, i64 1, i1 false)
+; CHECK: llvm.memmove
+  %4 = load i64, ptr %addr.addr, align 8
+  %5 = inttoptr i64 %4 to ptr addrspace(256)
+  %6 = load i64, ptr %addr.addr, align 8
+  %7 = inttoptr i64 %6 to ptr
+  call void @llvm.memmove.p256.p0.i64(ptr addrspace(256) align 1 %5, ptr align 1 %7, i64 1, i1 false)
+; CHECK: llvm.memmove
+  ret void
+}

Copy link

github-actions bot commented Feb 28, 2025

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff db4dd333d045b2b4eeb08d2c28fceb31cf0d59ac 12941c5320ce430658eb249f1bcab436fcc61f16 --extensions cpp,cppm,h,c -- bolt/include/bolt/Passes/ProfileQualityStats.h bolt/lib/Passes/ProfileQualityStats.cpp bolt/test/avoid-wx-segment.c clang/lib/CIR/CodeGen/Address.h clang/lib/CIR/CodeGen/CIRGenDecl.cpp clang/lib/CIR/CodeGen/CIRGenExpr.cpp clang/lib/CIR/CodeGen/CIRGenValue.h clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp clang/test/Analysis/new-user-defined.cpp clang/test/CIR/CodeGen/basic.cpp clang/test/CodeGenCXX/wasm-em-eh.cpp clang/test/Modules/pr28744.cpp clang/test/OpenMP/metadirective_otherwise.cpp clang/test/SemaCXX/embed-init-list.cpp clang/unittests/Frontend/NoAlterCodeGenActionTest.cpp libc/include/llvm-libc-macros/EFIAPI-macros.h libc/include/llvm-libc-types/EFI_ALLOCATE_TYPE.h libc/include/llvm-libc-types/EFI_BOOT_SERVICES.h libc/include/llvm-libc-types/EFI_CAPSULE.h libc/include/llvm-libc-types/EFI_CONFIGURATION_TABLE.h libc/include/llvm-libc-types/EFI_DEVICE_PATH_PROTOCOL.h libc/include/llvm-libc-types/EFI_EVENT.h libc/include/llvm-libc-types/EFI_GUID.h libc/include/llvm-libc-types/EFI_HANDLE.h libc/include/llvm-libc-types/EFI_INTERFACE_TYPE.h libc/include/llvm-libc-types/EFI_LOCATE_SEARCH_TYPE.h libc/include/llvm-libc-types/EFI_MEMORY_DESCRIPTOR.h libc/include/llvm-libc-types/EFI_MEMORY_TYPE.h libc/include/llvm-libc-types/EFI_OPEN_PROTOCOL_INFORMATION_ENTRY.h libc/include/llvm-libc-types/EFI_PHYSICAL_ADDRESS.h libc/include/llvm-libc-types/EFI_RUNTIME_SERVICES.h libc/include/llvm-libc-types/EFI_SIMPLE_TEXT_INPUT_PROTOCOL.h libc/include/llvm-libc-types/EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.h libc/include/llvm-libc-types/EFI_STATUS.h libc/include/llvm-libc-types/EFI_SYSTEM_TABLE.h libc/include/llvm-libc-types/EFI_TABLE_HEADER.h libc/include/llvm-libc-types/EFI_TIME.h libc/include/llvm-libc-types/EFI_TIMER_DELAY.h libc/include/llvm-libc-types/EFI_TPL.h libc/include/llvm-libc-types/EFI_VIRTUAL_ADDRESS.h bolt/include/bolt/Rewrite/RewriteInstance.h bolt/lib/Passes/Instrumentation.cpp bolt/lib/Rewrite/BinaryPassManager.cpp bolt/lib/Rewrite/RewriteInstance.cpp clang/include/clang/AST/Expr.h clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h clang/include/clang/CIR/MissingFeatures.h clang/include/clang/Format/Format.h clang/include/clang/Sema/Sema.h clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp clang/lib/Analysis/UnsafeBufferUsage.cpp clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp clang/lib/CIR/CodeGen/CIRGenFunction.cpp clang/lib/CIR/CodeGen/CIRGenFunction.h clang/lib/CIR/CodeGen/CIRGenModule.h clang/lib/CIR/CodeGen/CIRGenStmt.cpp clang/lib/CIR/Dialect/IR/CIRDialect.cpp clang/lib/CodeGen/CGBuiltin.cpp clang/lib/CodeGen/CGCoroutine.cpp clang/lib/CodeGen/CodeGenTypes.cpp clang/lib/CodeGen/ItaniumCXXABI.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Format/ContinuationIndenter.cpp clang/lib/Format/Format.cpp clang/lib/Headers/avx10_2convertintrin.h clang/lib/Headers/vecintrin.h clang/lib/Parse/ParseOpenMP.cpp clang/lib/Sema/Sema.cpp clang/lib/Sema/SemaCUDA.cpp clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaHLSL.cpp clang/lib/Sema/SemaInit.cpp clang/lib/Sema/SemaOverload.cpp clang/lib/Sema/SemaTemplateDeduction.cpp clang/lib/StaticAnalyzer/Core/RegionStore.cpp clang/test/Analysis/initializer.cpp clang/test/Analysis/out-of-bounds.c clang/test/Analysis/region-store.cpp clang/test/CodeGen/AArch64/fp8-init-list.c clang/test/CodeGen/AArch64/fp8-intrinsics/acle_sve2_fp8_fdot.c clang/test/CodeGen/AArch64/fp8-intrinsics/acle_sve2_fp8_fmla.c clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_ld1.c clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_ld2.c clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_ld3.c clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_ld4.c clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_ldnt1.c clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_st1.c clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_st2.c clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_st3.c clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_st4.c clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_stnt1.c clang/test/CodeGen/AArch64/sve2p1-intrinsics/acle_sve2p1_ld1.c clang/test/CodeGen/AArch64/sve2p1-intrinsics/acle_sve2p1_ldnt1.c clang/test/CodeGen/AArch64/sve2p1-intrinsics/acle_sve2p1_loads.c clang/test/CodeGen/AArch64/sve2p1-intrinsics/acle_sve2p1_st1.c clang/test/CodeGen/AArch64/sve2p1-intrinsics/acle_sve2p1_stnt1.c clang/test/CodeGen/AArch64/sve2p1-intrinsics/acle_sve2p1_store.c clang/test/CodeGen/arm-mfp8.c clang/test/CodeGenCXX/wasm-eh.cpp clang/test/CodeGenCoroutines/coro-params.cpp clang/test/Driver/module-fgen-reduced-bmi.cppm clang/test/OpenMP/metadirective_ast_print.c clang/test/SemaCXX/unique_object_duplication.h clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp clang/unittests/Format/ConfigParseTest.cpp compiler-rt/lib/asan/asan_win.cpp compiler-rt/lib/tsan/rtl/tsan_platform.h compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp flang-rt/lib/runtime/unit.cpp flang-rt/lib/runtime/unit.h flang/include/flang/Evaluate/tools.h flang/include/flang/Optimizer/Dialect/FIROps.h flang/include/flang/Semantics/symbol.h flang/include/flang/Semantics/tools.h flang/include/flang/Support/Fortran-features.h flang/lib/Evaluate/intrinsics.cpp flang/lib/Evaluate/tools.cpp flang/lib/Lower/OpenMP/Utils.cpp flang/lib/Optimizer/CodeGen/BoxedProcedure.cpp flang/lib/Optimizer/CodeGen/CodeGen.cpp flang/lib/Optimizer/Dialect/FIROps.cpp flang/lib/Optimizer/OpenMP/GenericLoopConversion.cpp flang/lib/Optimizer/OpenMP/MapInfoFinalization.cpp flang/lib/Semantics/check-call.cpp flang/lib/Semantics/check-declarations.cpp flang/lib/Semantics/check-do-forall.cpp flang/lib/Semantics/expression.cpp flang/lib/Semantics/mod-file.cpp flang/lib/Semantics/resolve-names.cpp flang/lib/Semantics/symbol.cpp flang/lib/Semantics/tools.cpp flang/lib/Support/Fortran-features.cpp libcxx/include/__algorithm/simd_utils.h libcxx/include/__locale_dir/support/linux.h libcxx/test/std/input.output/iostream.format/std.manip/setfill_wchar_max.pass.cpp libcxx/test/std/re/re.alg/re.alg.match/awk.locale.pass.cpp libcxx/test/std/re/re.alg/re.alg.match/basic.locale.pass.cpp libcxx/test/std/re/re.alg/re.alg.match/ecma.locale.pass.cpp libcxx/test/std/re/re.alg/re.alg.match/extended.locale.pass.cpp libcxx/test/std/re/re.alg/re.alg.search/awk.locale.pass.cpp libcxx/test/std/re/re.alg/re.alg.search/basic.locale.pass.cpp libcxx/test/std/re/re.alg/re.alg.search/ecma.locale.pass.cpp libcxx/test/std/re/re.alg/re.alg.search/extended.locale.pass.cpp libcxx/test/std/re/re.traits/lookup_collatename.pass.cpp lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp lldb/source/Target/ThreadPlanCallFunction.cpp lldb/tools/lldb-dap/DAP.cpp lldb/tools/lldb-dap/DAP.h lldb/tools/lldb-dap/Handler/RequestHandler.cpp lldb/tools/lldb-dap/JSONUtils.cpp lldb/tools/lldb-dap/JSONUtils.h lldb/tools/lldb-dap/RunInTerminal.cpp lldb/tools/lldb-dap/RunInTerminal.h lldb/tools/lldb-dap/lldb-dap.cpp llvm/include/llvm/Analysis/VectorUtils.h llvm/include/llvm/CodeGen/BasicTTIImpl.h llvm/include/llvm/ExecutionEngine/Orc/Core.h llvm/include/llvm/Frontend/OpenMP/OMPContext.h llvm/include/llvm/Object/ELF.h llvm/include/llvm/Transforms/IPO/Attributor.h llvm/include/llvm/Transforms/Scalar/JumpThreading.h llvm/include/llvm/Transforms/Utils/ControlFlowUtils.h llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.h llvm/lib/Analysis/CaptureTracking.cpp llvm/lib/Analysis/VectorUtils.cpp llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp llvm/lib/CodeGen/MachineInstr.cpp llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp llvm/lib/ExecutionEngine/JITLink/aarch64.cpp llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp llvm/lib/IR/AsmWriter.cpp llvm/lib/MCA/InstrBuilder.cpp llvm/lib/ProfileData/InstrProfWriter.cpp llvm/lib/SandboxIR/Region.cpp llvm/lib/Target/AArch64/AArch64ISelLowering.cpp llvm/lib/Target/AMDGPU/AMDGPUAtomicOptimizer.cpp llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp llvm/lib/Target/AMDGPU/AMDGPURegBankLegalizeRules.cpp llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp llvm/lib/Target/AMDGPU/SIInstrInfo.cpp llvm/lib/Target/AMDGPU/SIInstrInfo.h llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.cpp llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.h llvm/lib/Target/NVPTX/NVPTXReplaceImageHandles.cpp llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFStreamer.cpp llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFStreamer.h llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp llvm/lib/Target/PowerPC/MCTargetDesc/PPCXCOFFStreamer.cpp llvm/lib/Target/PowerPC/MCTargetDesc/PPCXCOFFStreamer.h llvm/lib/Target/PowerPC/PPCISelLowering.cpp llvm/lib/Target/PowerPC/PPCISelLowering.h llvm/lib/Target/PowerPC/PPCInstrInfo.cpp llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp llvm/lib/Target/RISCV/MCA/RISCVCustomBehaviour.cpp llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.h llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp llvm/lib/Target/RISCV/RISCVISelDAGToDAG.h llvm/lib/Target/RISCV/RISCVISelLowering.cpp llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp llvm/lib/Target/SystemZ/SystemZPostRewrite.cpp llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp llvm/lib/Transforms/IPO/Attributor.cpp llvm/lib/Transforms/IPO/AttributorAttributes.cpp llvm/lib/Transforms/IPO/FunctionAttrs.cpp llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp llvm/lib/Transforms/Scalar/JumpThreading.cpp llvm/lib/Transforms/Utils/ControlFlowUtils.cpp llvm/lib/Transforms/Utils/UnifyLoopExits.cpp llvm/lib/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.cpp llvm/lib/Transforms/Vectorize/VPlanValue.h llvm/tools/llvm-objdump/ELFDump.cpp llvm/tools/llvm-objdump/llvm-objdump.cpp llvm/tools/llvm-objdump/llvm-objdump.h llvm/tools/llvm-readobj/ELFDumper.cpp mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamed.cpp mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp mlir/lib/Dialect/Math/Transforms/ExpandPatterns.cpp mlir/lib/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.cpp mlir/lib/Dialect/Tosa/IR/TosaOps.cpp mlir/lib/Target/Cpp/TranslateToCpp.cpp mlir/lib/Target/LLVMIR/ModuleImport.cpp mlir/lib/Target/LLVMIR/ModuleTranslation.cpp mlir/unittests/IR/ShapedTypeTest.cpp
View the diff from clang-format here.
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index 2b8818482a..86f5337219 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -5049,8 +5049,7 @@ void SelectionDAGLegalize::PromoteNode(SDNode *Node) {
   SmallVector<SDValue, 8> Results;
   MVT OVT = Node->getSimpleValueType(0);
   if (Node->getOpcode() == ISD::UINT_TO_FP ||
-      Node->getOpcode() == ISD::SINT_TO_FP ||
-      Node->getOpcode() == ISD::SETCC ||
+      Node->getOpcode() == ISD::SINT_TO_FP || Node->getOpcode() == ISD::SETCC ||
       Node->getOpcode() == ISD::EXTRACT_VECTOR_ELT ||
       Node->getOpcode() == ISD::INSERT_VECTOR_ELT ||
       Node->getOpcode() == ISD::VECREDUCE_FMAX ||

vporpo and others added 25 commits February 28, 2025 13:05
…vm#129127)

This new option lets you specify an allow-list of source files and
disables vectorization if the IR is not in the list. This can be used
for debugging miscompiles.
CSmith found a case where SROA produces bitcasts from scalar to vector.
This was previously asserted against in SystemZTTI, but now the BaseT
implementation takes care of it.
This change implements basic support in ClangIR for local variables
using the cir.alloca and cir.load operations.
llvm#116126)

…dummy

We presently allow a NULL() actual argument to associate with a
non-optional dummy allocatable argument only under INTENT(IN). This is
too strict, as it precludes the case of a dummy argument with default
intent. Continue to require that the actual argument be definable under
INTENT(OUT) and INTENT(IN OUT), and (contra XLF) interpret NULL() as
being an expression, not a definable variable, even when it is given an
allocatable MOLD.

Fixes llvm#115984.
Enable COSHAPE in the intrinsics table and enable its test.
Detect and report a bunch of uncaught semantic errors with coarray
declarations. Add more tests, and clean up bad usage in existing tests.
…lvm#125890)

As I read the standard, an unlimited polymorphic pointer or target
should be viewed as compatible with any data target or data pointer when
used in the two-argument form of the intrinsic function ASSOCIATED().

Fixes llvm#125774.
The check that "v_list" be deferred shape is just wrong; there are no
deferred shape non-pointer non-allocatable dummy arguments in Fortran.
Correct to check for an assumed shape dummy argument. And de-split the
error messages that were split across multiple source lines, making them
much harder to find with grep.

Fixes llvm#125878.
Modules read from module files must have their symbols tagged with the
ModFile flag to suppress all warnings messages that might be emitted for
their contents. (Actionable warnings will have been emitted when the
modules were originally compiled, so we don't want to repeat them later
when the modules are USE'd.) The module symbols of the additional
modules in hermetic module files were not being tagged with that flag;
fix.
A derived type with a component of the same name as the type is not
extensible... unless the extension occurs in another module where the
conflicting component is inaccessible.

Fixes llvm#126114.
llvm#128771)

…TENT

A dummy procedure pointer with no INTENT attribute may associate with an
actual argument that is the result of a reference to a function that
returns a procedure pointer, we think.

Fixes llvm#126950.
When checking for conflicts between type-bound generic defined I/O
procedures and non-type-bound defined I/O generic interfaces, don't
worry about conflicts where the type-bound generic interface is
inaccessible in the scope around the non-type-bound interface.

Fixes llvm#126797.
…#128935)

A few bits of semantic checking need a variant of the
ResolveAssociations utility function that stops when hitting a construct
entity for a type or class guard. This is necessary for cases like the
bug below where the analysis is concerned with the type of the name in
context, rather than its shape or storage or whatever. So add a flag to
ResolveAssociations and GetAssociationRoot to make this happen, and use
it at the appropriate call sites.

Fixes llvm#128608.
Enforce an obscure constraint from the standard: an abstract interface
is not allowed to have the same name as an intrinsic type keyword. I
suspect this is meant to prevent a declaration like "PROCEDURE(REAL),
POINTER :: P" from being ambiguous.

Fixes llvm#128744.
The definition of an array constructor doesn't preclude the use of
[character(:)::] or [character(*)::] directly, but there is language
elsewhere in the standard that restricts their use to specific contexts,
neither of which include explicitly typed array constructors.

Fixes llvm#128755.
llvm#128980)

…cific

When checking generic procedures for indistinguishable specific
procedures, don't neglect to include specific procedures from any
accessible instance of the generic procedure inherited from its parent
type..

Fixes llvm#128760.
This patch fixes:

  flang/lib/Semantics/check-declarations.cpp:2009:15: error: unused
  variable 'kind' [-Werror,-Wunused-variable]
…lvm#128954)

First thing to know is that the subtarget feature checks used to block
accessing a decoder table are only a performance optimization and not
required for functionality. The tables have their own predicate checks.
I've removed them from all the standard extension tables.

-RV32 Zacas decoder namespace has been renamed to RV32GPRPair, I think
Zilsd(rv32 load/store pair) can go in here too.
-The RV32 Zdinx table has been renamed to also use RV32GPRPair.
-The Zfinx table has been renamed to remove superflous "RV" prefix.
-Zcmp and Zcmt tables have been combined into a ZcOverlap table. I think
 Zclsd(rv32 compressed load/store pair) can go in here too.
-All the extra standard extension tables are checked after the main
 standard extension table. This makes the common case of the main table
 matching occur earlier.
-Zicfiss is the exception to this as it needs to be checked before
 the main table since it overrides some encodings from Zcmop. This
can't be handled by a predicate based priority as Zicfiss only overrides
 a subset of Zcmop encodings.
Inline the strings directly into the table instead of storing a pointer.
Similar to what was done for other searchable tables in the last couple
months.
Although an unreachable BB is skipped by processBlock, its successor can
still be handled by processBlock, and maybeMergeBasicBlockIntoOnlyPred
may merge the two BBs and delete the unreachable BB. Then the garbage
pointer is left in Unreachable set. This patch avoids merging a BB into 
unreachable predecessor.
… and debug locations.

As previously discussed [1], it is sometimes useful to be able to see
instruction addresses and debug locations as part of IR dumps. The
same applies to MachineInstrs which already dump debug locations but
not addresses. Therefore add some flags that can be used to enable
dumping of this information.

[1] https://discourse.llvm.org/t/small-improvement-to-llvm-debugging-experience/79914

Reviewers: rnk

Reviewed By: rnk

Pull Request: llvm#127944
This change fold together the _ari, _ari64, and _asi variants of these
instructions into a single instruction capable of holding any address.
This allows for the removal of a lot of unnecessary code and moves us
towards a standard way of representing an address in NVPTX.
…. NFC

This function is only used in the same file.
BOLT instrumented binary today has a readable (R), writeable (W) and also
executable (X) segment, which Android system won't load due to its WX
attribute. Such RWX segment was produced because BOLT has a two step linking,
first for everything in the updated or rewritten input binary and next for
runtime library. Each linking will layout sections in the order of RX sections
followed by RO sections and then followed by RW sections. So we could end up
having a RW section `.bolt.instr.counters` surrounded by a number of RO and RX
sections, and a new text segment was then formed by including all RX sections
which includes the RW section in the middle, and hence the RWX segment. One
way to fix this is to separate the RW `.bolt.instr.counters` section into its
own segment by a). assigning the starting addresses for section
`.bolt.instr.counters` and its following section with regular page aligned
addresses and b). creating two extra program headers accordingly.
topperc and others added 11 commits February 28, 2025 13:06
…lvm#129180)

Instead of referring the user to the spec, print the expected range.
and fix crash when vd_aux is invalid (llvm#86611).

vd_version, vd_flags, vd_ndx, and vd_cnt in Elf{32,64}_Verdef are
16-bit. Change VerDef to use uint16_t instead.

vda_name specifies a NUL-terminated string. Update getVersionDefinitions
to remove some `.c_str()`.

Pull Request: llvm#128434
…29274)

This renames the output of TOSA MatMul operator from `c` to `output`
to align to TOSA spec

Co-authored-by: TatWai Chong <[email protected]>
…#129179)

If the ControlFlowHub did not perform any change to the control flow,
there is no need to repair SSA, update the loop structure, and verify a
bunch of things. This is not completely NFC though, repairSSA introduced
PHI nodes with a single entry that are now missing.

My code went from 400+ seconds to 1 second, since no loop required the
exits to be unified, but there were many "complex" loops.
…cked-optional-access` (llvm#128437)

Fixes llvm#126283

Extending llvm#112605 to cache
const getters which return references.

Fixes false positives from const reference accessors to object
containing optional member
…#126334 (llvm#129169)

`MeasureTokenLength` may return an unsigned 0 representing failure in
obtaining length of a token. The analysis now gives up on such cases.
Otherwise, there might be issues caused by unsigned integer "overflow".
)

LLVM IR emitted in from C++ may contain `@llvm.global_ctors = appending
global [0 x { i32, ptr, ptr }] zeroinitializer`. Before this PR, if we
try to roundtrip code like this from the importer, we'll end up with
nothing in place.

Note that `llvm::appendToGlobalCtors` ignores empty lists and this PR
uses the same approach as `llvm-as`, which doesn't use the utilities
from `llvm/lib/Transforms/Utils/ModuleUtils.cpp` in order to build this
- it calls into creating a global variable from scratch.
…lvm#128957)

This adds support for launching lldb-dap in server mode. The extension
will start lldb-dap in server mode on-demand and retain the server until
the VSCode window is closed (when the extension context is disposed).
While running in server mode, launch performance for binaries is greatly
improved by improving caching between debug sessions.

For example, on my local M1 Max laptop it takes ~5s to attach for the
first attach to an iOS Simulator process and ~0.5s to attach each time
after the first.
…NFC (llvm#129134)

Not all fractional LMULs are required to be support for all SEWs. This
test previously printed a warning for these cases.
Copy link

⚠️ undef deprecator found issues in your code. ⚠️

You can test this locally with the following command:
git diff -U0 --pickaxe-regex -S '([^a-zA-Z0-9#_-]undef[^a-zA-Z0-9_-]|UndefValue::get)' db4dd333d045b2b4eeb08d2c28fceb31cf0d59ac 12941c5320ce430658eb249f1bcab436fcc61f16 bolt/include/bolt/Passes/ProfileQualityStats.h bolt/lib/Passes/ProfileQualityStats.cpp bolt/test/avoid-wx-segment.c clang/lib/CIR/CodeGen/Address.h clang/lib/CIR/CodeGen/CIRGenDecl.cpp clang/lib/CIR/CodeGen/CIRGenExpr.cpp clang/lib/CIR/CodeGen/CIRGenValue.h clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp clang/test/Analysis/new-user-defined.cpp clang/test/CIR/CodeGen/basic.cpp clang/test/CodeGenCXX/wasm-em-eh.cpp clang/test/Modules/pr28744.cpp clang/test/OpenMP/metadirective_otherwise.cpp clang/test/SemaCXX/embed-init-list.cpp clang/unittests/Frontend/NoAlterCodeGenActionTest.cpp libc/include/llvm-libc-macros/EFIAPI-macros.h libc/include/llvm-libc-types/EFI_ALLOCATE_TYPE.h libc/include/llvm-libc-types/EFI_BOOT_SERVICES.h libc/include/llvm-libc-types/EFI_CAPSULE.h libc/include/llvm-libc-types/EFI_CONFIGURATION_TABLE.h libc/include/llvm-libc-types/EFI_DEVICE_PATH_PROTOCOL.h libc/include/llvm-libc-types/EFI_EVENT.h libc/include/llvm-libc-types/EFI_GUID.h libc/include/llvm-libc-types/EFI_HANDLE.h libc/include/llvm-libc-types/EFI_INTERFACE_TYPE.h libc/include/llvm-libc-types/EFI_LOCATE_SEARCH_TYPE.h libc/include/llvm-libc-types/EFI_MEMORY_DESCRIPTOR.h libc/include/llvm-libc-types/EFI_MEMORY_TYPE.h libc/include/llvm-libc-types/EFI_OPEN_PROTOCOL_INFORMATION_ENTRY.h libc/include/llvm-libc-types/EFI_PHYSICAL_ADDRESS.h libc/include/llvm-libc-types/EFI_RUNTIME_SERVICES.h libc/include/llvm-libc-types/EFI_SIMPLE_TEXT_INPUT_PROTOCOL.h libc/include/llvm-libc-types/EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.h libc/include/llvm-libc-types/EFI_STATUS.h libc/include/llvm-libc-types/EFI_SYSTEM_TABLE.h libc/include/llvm-libc-types/EFI_TABLE_HEADER.h libc/include/llvm-libc-types/EFI_TIME.h libc/include/llvm-libc-types/EFI_TIMER_DELAY.h libc/include/llvm-libc-types/EFI_TPL.h libc/include/llvm-libc-types/EFI_VIRTUAL_ADDRESS.h llvm/test/Analysis/CostModel/SystemZ/bitcast.ll llvm/test/CodeGen/PowerPC/v1024ls.ll llvm/test/CodeGen/RISCV/rvv/vreductions-fp-sdnode-bf16.ll llvm/test/CodeGen/RISCV/rvv/vreductions-fp-sdnode-f16.ll llvm/test/CodeGen/RISCV/rvv/vreductions-fp-vp-bf16.ll llvm/test/CodeGen/RISCV/rvv/vreductions-fp-vp-f16.ll llvm/test/CodeGen/X86/stack-protector-phi.ll llvm/test/Instrumentation/AddressSanitizer/X86/bug_124238.ll llvm/test/Other/print-inst-addrs.ll llvm/test/Other/print-inst-debug-locs.ll llvm/test/Other/print-mi-addrs.ll llvm/test/Transforms/InstCombine/AMDGPU/simplify-demanded-vector-elts-lane-intrinsics.ll llvm/test/Transforms/LoopVectorize/AArch64/multiple-result-intrinsics.ll llvm/test/Transforms/LoopVectorize/multiple-result-intrinsics.ll llvm/test/Transforms/SandboxVectorizer/allow_files.ll bolt/include/bolt/Rewrite/RewriteInstance.h bolt/lib/Passes/Instrumentation.cpp bolt/lib/Rewrite/BinaryPassManager.cpp bolt/lib/Rewrite/RewriteInstance.cpp clang/include/clang/AST/Expr.h clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h clang/include/clang/CIR/MissingFeatures.h clang/include/clang/Format/Format.h clang/include/clang/Sema/Sema.h clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp clang/lib/Analysis/UnsafeBufferUsage.cpp clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp clang/lib/CIR/CodeGen/CIRGenFunction.cpp clang/lib/CIR/CodeGen/CIRGenFunction.h clang/lib/CIR/CodeGen/CIRGenModule.h clang/lib/CIR/CodeGen/CIRGenStmt.cpp clang/lib/CIR/Dialect/IR/CIRDialect.cpp clang/lib/CodeGen/CGBuiltin.cpp clang/lib/CodeGen/CGCoroutine.cpp clang/lib/CodeGen/CodeGenTypes.cpp clang/lib/CodeGen/ItaniumCXXABI.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Format/ContinuationIndenter.cpp clang/lib/Format/Format.cpp clang/lib/Headers/avx10_2convertintrin.h clang/lib/Headers/vecintrin.h clang/lib/Parse/ParseOpenMP.cpp clang/lib/Sema/Sema.cpp clang/lib/Sema/SemaCUDA.cpp clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaHLSL.cpp clang/lib/Sema/SemaInit.cpp clang/lib/Sema/SemaOverload.cpp clang/lib/Sema/SemaTemplateDeduction.cpp clang/lib/StaticAnalyzer/Core/RegionStore.cpp clang/test/Analysis/initializer.cpp clang/test/Analysis/out-of-bounds.c clang/test/Analysis/region-store.cpp clang/test/CodeGen/AArch64/fp8-init-list.c clang/test/CodeGen/AArch64/fp8-intrinsics/acle_sve2_fp8_fdot.c clang/test/CodeGen/AArch64/fp8-intrinsics/acle_sve2_fp8_fmla.c clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_ld1.c clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_ld2.c clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_ld3.c clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_ld4.c clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_ldnt1.c clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_st1.c clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_st2.c clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_st3.c clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_st4.c clang/test/CodeGen/AArch64/sve-intrinsics/acle_sve_stnt1.c clang/test/CodeGen/AArch64/sve2p1-intrinsics/acle_sve2p1_ld1.c clang/test/CodeGen/AArch64/sve2p1-intrinsics/acle_sve2p1_ldnt1.c clang/test/CodeGen/AArch64/sve2p1-intrinsics/acle_sve2p1_loads.c clang/test/CodeGen/AArch64/sve2p1-intrinsics/acle_sve2p1_st1.c clang/test/CodeGen/AArch64/sve2p1-intrinsics/acle_sve2p1_stnt1.c clang/test/CodeGen/AArch64/sve2p1-intrinsics/acle_sve2p1_store.c clang/test/CodeGen/arm-mfp8.c clang/test/CodeGenCXX/wasm-eh.cpp clang/test/CodeGenCoroutines/coro-params.cpp clang/test/Driver/module-fgen-reduced-bmi.cppm clang/test/OpenMP/metadirective_ast_print.c clang/test/SemaCXX/unique_object_duplication.h clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp clang/unittests/Format/ConfigParseTest.cpp compiler-rt/lib/asan/asan_win.cpp compiler-rt/lib/tsan/rtl/tsan_platform.h compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp flang-rt/lib/runtime/unit.cpp flang-rt/lib/runtime/unit.h flang/include/flang/Evaluate/tools.h flang/include/flang/Optimizer/Dialect/FIROps.h flang/include/flang/Semantics/symbol.h flang/include/flang/Semantics/tools.h flang/include/flang/Support/Fortran-features.h flang/lib/Evaluate/intrinsics.cpp flang/lib/Evaluate/tools.cpp flang/lib/Lower/OpenMP/Utils.cpp flang/lib/Optimizer/CodeGen/BoxedProcedure.cpp flang/lib/Optimizer/CodeGen/CodeGen.cpp flang/lib/Optimizer/Dialect/FIROps.cpp flang/lib/Optimizer/OpenMP/GenericLoopConversion.cpp flang/lib/Optimizer/OpenMP/MapInfoFinalization.cpp flang/lib/Semantics/check-call.cpp flang/lib/Semantics/check-declarations.cpp flang/lib/Semantics/check-do-forall.cpp flang/lib/Semantics/expression.cpp flang/lib/Semantics/mod-file.cpp flang/lib/Semantics/resolve-names.cpp flang/lib/Semantics/symbol.cpp flang/lib/Semantics/tools.cpp flang/lib/Support/Fortran-features.cpp libcxx/include/__algorithm/simd_utils.h libcxx/include/__locale_dir/support/linux.h libcxx/test/std/input.output/iostream.format/std.manip/setfill_wchar_max.pass.cpp libcxx/test/std/re/re.alg/re.alg.match/awk.locale.pass.cpp libcxx/test/std/re/re.alg/re.alg.match/basic.locale.pass.cpp libcxx/test/std/re/re.alg/re.alg.match/ecma.locale.pass.cpp libcxx/test/std/re/re.alg/re.alg.match/extended.locale.pass.cpp libcxx/test/std/re/re.alg/re.alg.search/awk.locale.pass.cpp libcxx/test/std/re/re.alg/re.alg.search/basic.locale.pass.cpp libcxx/test/std/re/re.alg/re.alg.search/ecma.locale.pass.cpp libcxx/test/std/re/re.alg/re.alg.search/extended.locale.pass.cpp libcxx/test/std/re/re.traits/lookup_collatename.pass.cpp lldb/source/Plugins/ABI/AArch64/ABISysV_arm64.cpp lldb/source/Target/ThreadPlanCallFunction.cpp lldb/tools/lldb-dap/DAP.cpp lldb/tools/lldb-dap/DAP.h lldb/tools/lldb-dap/Handler/RequestHandler.cpp lldb/tools/lldb-dap/JSONUtils.cpp lldb/tools/lldb-dap/JSONUtils.h lldb/tools/lldb-dap/RunInTerminal.cpp lldb/tools/lldb-dap/RunInTerminal.h lldb/tools/lldb-dap/lldb-dap.cpp llvm/include/llvm/Analysis/VectorUtils.h llvm/include/llvm/CodeGen/BasicTTIImpl.h llvm/include/llvm/ExecutionEngine/Orc/Core.h llvm/include/llvm/Frontend/OpenMP/OMPContext.h llvm/include/llvm/Object/ELF.h llvm/include/llvm/Transforms/IPO/Attributor.h llvm/include/llvm/Transforms/Scalar/JumpThreading.h llvm/include/llvm/Transforms/Utils/ControlFlowUtils.h llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.h llvm/lib/Analysis/CaptureTracking.cpp llvm/lib/Analysis/VectorUtils.cpp llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp llvm/lib/CodeGen/MachineInstr.cpp llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp llvm/lib/ExecutionEngine/JITLink/aarch64.cpp llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp llvm/lib/IR/AsmWriter.cpp llvm/lib/MCA/InstrBuilder.cpp llvm/lib/ProfileData/InstrProfWriter.cpp llvm/lib/SandboxIR/Region.cpp llvm/lib/Target/AArch64/AArch64ISelLowering.cpp llvm/lib/Target/AMDGPU/AMDGPUAtomicOptimizer.cpp llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp llvm/lib/Target/AMDGPU/AMDGPURegBankLegalizeRules.cpp llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp llvm/lib/Target/AMDGPU/SIInstrInfo.cpp llvm/lib/Target/AMDGPU/SIInstrInfo.h llvm/lib/Target/AMDGPU/SIOptimizeExecMasking.cpp llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.cpp llvm/lib/Target/NVPTX/NVPTXISelDAGToDAG.h llvm/lib/Target/NVPTX/NVPTXReplaceImageHandles.cpp llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFStreamer.cpp llvm/lib/Target/PowerPC/MCTargetDesc/PPCELFStreamer.h llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp llvm/lib/Target/PowerPC/MCTargetDesc/PPCXCOFFStreamer.cpp llvm/lib/Target/PowerPC/MCTargetDesc/PPCXCOFFStreamer.h llvm/lib/Target/PowerPC/PPCISelLowering.cpp llvm/lib/Target/PowerPC/PPCISelLowering.h llvm/lib/Target/PowerPC/PPCInstrInfo.cpp llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp llvm/lib/Target/RISCV/MCA/RISCVCustomBehaviour.cpp llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.h llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp llvm/lib/Target/RISCV/RISCVISelDAGToDAG.h llvm/lib/Target/RISCV/RISCVISelLowering.cpp llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp llvm/lib/Target/SystemZ/SystemZPostRewrite.cpp llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp llvm/lib/Transforms/IPO/Attributor.cpp llvm/lib/Transforms/IPO/AttributorAttributes.cpp llvm/lib/Transforms/IPO/FunctionAttrs.cpp llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp llvm/lib/Transforms/Scalar/JumpThreading.cpp llvm/lib/Transforms/Utils/ControlFlowUtils.cpp llvm/lib/Transforms/Utils/UnifyLoopExits.cpp llvm/lib/Transforms/Vectorize/SandboxVectorizer/SandboxVectorizer.cpp llvm/lib/Transforms/Vectorize/VPlanValue.h llvm/test/Analysis/CostModel/RISCV/shuffle-exact-vlen.ll llvm/test/Analysis/CostModel/RISCV/shuffle-extract_subvector.ll llvm/test/Analysis/CostModel/RISCV/shuffle-transpose.ll llvm/test/Analysis/TypeBasedAliasAnalysis/functionattrs.ll llvm/test/CodeGen/AArch64/sve-select.ll llvm/test/CodeGen/AMDGPU/GlobalISel/divergence-divergent-i1-used-outside-loop.ll llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.div.fmas.ll llvm/test/CodeGen/AMDGPU/local-atomicrmw-fadd.ll llvm/test/CodeGen/AMDGPU/no-fold-accvgpr-mov.ll llvm/test/Transforms/Attributor/nocapture-1.ll llvm/test/Transforms/FunctionAttrs/nocapture.ll llvm/test/Transforms/FunctionAttrs/nonnull.ll llvm/test/Transforms/FunctionAttrs/out-of-bounds-iterator-bug.ll llvm/test/Transforms/GVN/PRE/2009-06-17-InvalidPRE.ll llvm/test/Transforms/GVN/PRE/2011-06-01-NonLocalMemdepMiscompile.ll llvm/test/Transforms/GVN/PRE/2017-06-28-pre-load-dbgloc.ll llvm/test/Transforms/GVN/PRE/2017-10-16-LoadPRECrash.ll llvm/test/Transforms/GVN/PRE/2018-06-08-pre-load-dbgloc-no-null-opt.ll llvm/test/Transforms/GVN/PRE/atomic.ll llvm/test/Transforms/GVN/PRE/load-pre-licm.ll llvm/test/Transforms/GVN/PRE/lpre-call-wrap-2.ll llvm/test/Transforms/GVN/PRE/lpre-call-wrap.ll llvm/test/Transforms/GVN/PRE/nonintegral.ll llvm/test/Transforms/GVN/PRE/pre-gep-load.ll llvm/test/Transforms/GVN/PRE/pre-load-implicit-cf-updates.ll llvm/test/Transforms/GVN/PRE/rle-phi-translate.ll llvm/test/Transforms/JumpThreading/pr62908.ll llvm/test/Transforms/SLPVectorizer/RISCV/complex-loads.ll llvm/test/Transforms/SLPVectorizer/RISCV/reductions.ll llvm/tools/llvm-objdump/ELFDump.cpp llvm/tools/llvm-objdump/llvm-objdump.cpp llvm/tools/llvm-objdump/llvm-objdump.h llvm/tools/llvm-readobj/ELFDumper.cpp mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp mlir/lib/Conversion/TosaToLinalg/TosaToLinalgNamed.cpp mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp mlir/lib/Dialect/Math/Transforms/ExpandPatterns.cpp mlir/lib/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.cpp mlir/lib/Dialect/Tosa/IR/TosaOps.cpp mlir/lib/Target/Cpp/TranslateToCpp.cpp mlir/lib/Target/LLVMIR/ModuleImport.cpp mlir/lib/Target/LLVMIR/ModuleTranslation.cpp mlir/test/Target/LLVMIR/Import/global-variables.ll mlir/unittests/IR/ShapedTypeTest.cpp

The following files introduce new uses of undef:

  • llvm/lib/Analysis/VectorUtils.cpp

Undef is now deprecated and should only be used in the rare cases where no replacement is possible. For example, a load of uninitialized memory yields undef. You should use poison values for placeholders instead.

In tests, avoid using undef and having tests that trigger undefined behavior. If you need an operand with some unimportant value, you can add a new argument to the function and use that instead.

For example, this is considered a bad practice:

define void @fn() {
  ...
  br i1 undef, ...
}

Please use the following instead:

define void @fn(i1 %cond) {
  ...
  br i1 %cond, ...
}

Please refer to the Undefined Behavior Manual for more information.

@ldionne ldionne removed the request for review from a team March 19, 2025 04:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.