[Local] Preserve noundef metadata in copyMetadataForLoad()
authorNikita Popov <npopov@redhat.com>
Thu, 19 Jan 2023 15:55:23 +0000 (16:55 +0100)
committerNikita Popov <npopov@redhat.com>
Thu, 19 Jan 2023 15:56:09 +0000 (16:56 +0100)
If we're only changing the type of the load, preserve the noundef
metadata.

llvm/lib/Transforms/Utils/Local.cpp
llvm/test/Transforms/InstCombine/loadstore-metadata.ll

index 00cbee9..a57035d 100644 (file)
@@ -2752,6 +2752,7 @@ void llvm::copyMetadataForLoad(LoadInst &Dest, const LoadInst &Source) {
     case LLVMContext::MD_nontemporal:
     case LLVMContext::MD_mem_parallel_loop_access:
     case LLVMContext::MD_access_group:
+    case LLVMContext::MD_noundef:
       // All of these directly apply.
       Dest.setMetadata(ID, N);
       break;
index 5205b7d..1ee3c3a 100644 (file)
@@ -165,7 +165,7 @@ entry:
 
 define i32 @test_load_cast_combine_noundef(ptr %ptr) {
 ; CHECK-LABEL: @test_load_cast_combine_noundef(
-; CHECK-NEXT:    [[L1:%.*]] = load i32, ptr [[PTR:%.*]], align 4
+; CHECK-NEXT:    [[L1:%.*]] = load i32, ptr [[PTR:%.*]], align 4, !noundef !6
 ; CHECK-NEXT:    ret i32 [[L1]]
 ;
   %l = load float, ptr %ptr, !noundef !{}