-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Fix Endianess issue #162881
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix Endianess issue #162881
Conversation
…the first origin pointer
@llvm/pr-subscribers-llvm-transforms @llvm/pr-subscribers-compiler-rt-sanitizer Author: None (anoopkg6) ChangesFix Endianess issue with getting shadow 4 bytes corresponding to the first origin pointer. Full diff: https://github.com/llvm/llvm-project/pull/162881.diff 1 Files Affected:
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));
|
Please add "[dfsan]" to the title |
ConstantInt::get(WideShadowTy, WideShadowBitWidth / 2)) | ||
: IRB.CreateAnd( | ||
WideShadow, | ||
ConstantInt::get(WideShadowTy, 0xFFFFFFFF00000000ULL)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be rewritten in terms of WideShadowBitWidth?
(I think it's something like (1 - (1 << (WideShadowBitWidth / 2))) << (WideShadowBitWidth / 2)
)
I don't believe we support other that little endian. So there is no point to complicate code for that. |
They are adding support for SystemZ (#162195). |
Also, RISC-V has an exciting big-endian extension (/cc @fmayer) |
Fix Endianess issue with getting shadow 4 bytes corresponding to the first origin pointer.