[llvm] 60a097e - Fix sanitizer test errors from commit 886629a8
Rong Xu via llvm-commits
llvm-commits at lists.llvm.org
Tue May 18 22:48:00 PDT 2021
Author: Rong Xu
Date: 2021-05-18T22:46:51-07:00
New Revision: 60a097e5112d81707ac65f943e970428b9a953dc
URL: https://github.com/llvm/llvm-project/commit/60a097e5112d81707ac65f943e970428b9a953dc
DIFF: https://github.com/llvm/llvm-project/commit/60a097e5112d81707ac65f943e970428b9a953dc.diff
LOG: Fix sanitizer test errors from commit 886629a8
Explictly handle the empty string in the Hash calculation.
Added:
Modified:
llvm/lib/CodeGen/MIRFSDiscriminator.cpp
llvm/test/CodeGen/X86/fsafdo_test1.ll
llvm/test/CodeGen/X86/fsafdo_test2.ll
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/MIRFSDiscriminator.cpp b/llvm/lib/CodeGen/MIRFSDiscriminator.cpp
index 181f2a20d610..d240def8124f 100644
--- a/llvm/lib/CodeGen/MIRFSDiscriminator.cpp
+++ b/llvm/lib/CodeGen/MIRFSDiscriminator.cpp
@@ -43,12 +43,17 @@ FunctionPass *llvm::createMIRAddFSDiscriminatorsPass(unsigned LowBit,
static uint64_t getCallStackHash(const MachineBasicBlock &BB,
const MachineInstr &MI,
const DILocation *DIL) {
- uint64_t Ret = MD5Hash(std::to_string(DIL->getLine()));
- Ret ^= MD5Hash(BB.getName());
- Ret ^= MD5Hash(DIL->getScope()->getSubprogram()->getLinkageName());
+ auto updateHash = [](const StringRef &Str) -> uint64_t {
+ if (Str.empty())
+ return 0;
+ return MD5Hash(Str);
+ };
+ uint64_t Ret = updateHash(std::to_string(DIL->getLine()));
+ Ret ^= updateHash(BB.getName());
+ Ret ^= updateHash(DIL->getScope()->getSubprogram()->getLinkageName());
for (DIL = DIL->getInlinedAt(); DIL; DIL = DIL->getInlinedAt()) {
- Ret ^= MD5Hash(std::to_string(DIL->getLine()));
- Ret ^= MD5Hash(DIL->getScope()->getSubprogram()->getLinkageName());
+ Ret ^= updateHash(std::to_string(DIL->getLine()));
+ Ret ^= updateHash(DIL->getScope()->getSubprogram()->getLinkageName());
}
return Ret;
}
diff --git a/llvm/test/CodeGen/X86/fsafdo_test1.ll b/llvm/test/CodeGen/X86/fsafdo_test1.ll
index db87d5f84aaf..99c65c917f69 100644
--- a/llvm/test/CodeGen/X86/fsafdo_test1.ll
+++ b/llvm/test/CodeGen/X86/fsafdo_test1.ll
@@ -3,8 +3,8 @@
; Check that fs-afdo discriminators are generated.
; CHECK: .loc 1 7 3 is_stmt 0 discriminator 2 # foo.c:7:3
; Check: .loc 1 9 5 is_stmt 1 discriminator 2 # foo.c:9:5
-; CHECK: .loc 1 9 5 is_stmt 0 discriminator 3623878658 # foo.c:9:5
-; CHECK: .loc 1 7 3 is_stmt 1 discriminator 805306370 # foo.c:7:3
+; CHECK: .loc 1 9 5 is_stmt 0 discriminator 268435458 # foo.c:9:5
+; CHECK: .loc 1 7 3 is_stmt 1 discriminator 3892314114 # foo.c:7:3
; Check that variable __llvm_fs_discriminator__ is generated.
; CHECK: .type __llvm_fs_discriminator__, at object # @__llvm_fs_discriminator__
; CHECK: .section .rodata,"a", at progbits
diff --git a/llvm/test/CodeGen/X86/fsafdo_test2.ll b/llvm/test/CodeGen/X86/fsafdo_test2.ll
index efffbd60f746..ca26f307b08b 100644
--- a/llvm/test/CodeGen/X86/fsafdo_test2.ll
+++ b/llvm/test/CodeGen/X86/fsafdo_test2.ll
@@ -38,9 +38,9 @@
;;
;; Check that fs-afdo discriminators are generated.
; CHECK: .loc 1 23 9 is_stmt 0 discriminator 1 # unroll.c:23:9
-; CHECK: .loc 1 23 9 is_stmt 0 discriminator 1073741825 # unroll.c:23:9
-; CHECK: .loc 1 23 9 is_stmt 0 discriminator 2147483649 # unroll.c:23:9
-; CHECK: .loc 1 23 9 is_stmt 0 discriminator 268435457 # unroll.c:23:9
+; CHECK: .loc 1 23 9 is_stmt 0 discriminator 3892314113 # unroll.c:23:9
+; CHECK: .loc 1 23 9 is_stmt 0 discriminator 2818572289 # unroll.c:23:9
+; CHECK: .loc 1 23 9 is_stmt 0 discriminator 3623878657 # unroll.c:23:9
;;
;; Check that variable __llvm_fs_discriminator__ is generated.
; CHECK: .type __llvm_fs_discriminator__, at object # @__llvm_fs_discriminator__
More information about the llvm-commits
mailing list