[SanitizerCoverage] Simplify pc-table and improve test. NFC
authorFangrui Song <i@maskray.me>
Sat, 3 Sep 2022 21:29:21 +0000 (14:29 -0700)
committerFangrui Song <i@maskray.me>
Sat, 3 Sep 2022 21:29:21 +0000 (14:29 -0700)
llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
llvm/test/Instrumentation/SanitizerCoverage/pc-table.ll

index 05b48fb..095e319 100644 (file)
@@ -726,8 +726,7 @@ ModuleSanitizerCoverage::CreatePCArray(Function &F,
     } else {
       PCs.push_back((Constant *)IRB.CreatePointerCast(
           BlockAddress::get(AllBlocks[i]), IntptrPtrTy));
-      PCs.push_back((Constant *)IRB.CreateIntToPtr(
-          ConstantInt::get(IntptrTy, 0), IntptrPtrTy));
+      PCs.push_back(Constant::getNullValue(IntptrPtrTy));
     }
   }
   auto *PCArray = CreateFunctionLocalArrayInSection(N * 2, F, IntptrPtrTy,
index f5bef6d..dc7c81e 100644 (file)
@@ -18,7 +18,7 @@ entry:
   ret void
 }
 
-; CHECK: private constant [6 x i64*] [{{.*}}@foo{{.*}}blockaddress{{.*}}blockaddress{{.*}}], section "__sancov_pcs", comdat($foo), align 8
+; CHECK: private constant [6 x i64*] [i64* bitcast (void (i32*)* @foo to i64*), i64* inttoptr (i64 1 to i64*), i64* bitcast (i8* blockaddress(@foo, %entry.if.end_crit_edge) to i64*), i64* null, i64* bitcast (i8* blockaddress(@foo, %if.then) to i64*), i64* null], section "__sancov_pcs", comdat($foo), align 8
 ; CHECK:      @__start___sancov_pcs = extern_weak hidden global i64
 ; CHECK-NEXT: @__stop___sancov_pcs = extern_weak hidden global i64
 ; CHECK: define internal void @sancov.module_ctor