[llvm] Fix Endianess issue (PR #162881)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 10 15:16:39 PDT 2025
https://github.com/anoopkg6 updated https://github.com/llvm/llvm-project/pull/162881
>From 552bdae22fee776603ee62362daf2f6d6e6193ea Mon Sep 17 00:00:00 2001
From: anoopkg6 <anoopkg6 at github.com>
Date: Fri, 10 Oct 2025 18:22:29 +0200
Subject: [PATCH] Resolve Endianess issue with getting shadow 4 bytes
corresponding to the first origin pointer
---
.../Transforms/Instrumentation/DataFlowSanitizer.cpp | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
index 5ba2167859490..b4f88779b00c0 100644
--- a/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -2187,8 +2187,14 @@ std::pair<Value *, Value *> DFSanFunction::loadShadowFast(
// and then the entire shadow for the second origin pointer (which will be
// chosen by combineOrigins() iff the least-significant half of the wide
// shadow was empty but the other half was not).
- Value *WideShadowLo = IRB.CreateShl(
- WideShadow, ConstantInt::get(WideShadowTy, WideShadowBitWidth / 2));
+ Value *WideShadowLo =
+ F->getParent()->getDataLayout().isLittleEndian()
+ ? IRB.CreateShl(
+ WideShadow,
+ ConstantInt::get(WideShadowTy, WideShadowBitWidth / 2))
+ : IRB.CreateAnd(
+ WideShadow,
+ ConstantInt::get(WideShadowTy, 0xFFFFFFFF00000000ULL));
Shadows.push_back(WideShadow);
Origins.push_back(DFS.loadNextOrigin(Pos, OriginAlign, &OriginAddr));
More information about the llvm-commits
mailing list