[llvm] Fix Endianess issue (PR #162881)

Thurston Dang via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 10 10:13:28 PDT 2025


================
@@ -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));
----------------
thurstond wrote:

Can this be rewritten in terms of WideShadowBitWidth?

(I think it's something like `(1 - (1 << (WideShadowBitWidth / 2))) << (WideShadowBitWidth / 2)`)

https://github.com/llvm/llvm-project/pull/162881


More information about the llvm-commits mailing list