-
Notifications
You must be signed in to change notification settings - Fork 14.8k
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)
)
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.
Right way of writing this expression. Thanks.
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) |
Dfsan tests passed, which include extensive custom library functions like memcpy, memmove ... etc.
Other sanitizers - asan,lsan, tsan, ubsan - have successfully been supported on SystemZ.
Tysan, rtsan have already been tested and are in the process of pr. If some issue crops up, it will be fixed.
…________________________________
From: Vitaly Buka ***@***.***>
Sent: Friday, October 10, 2025 3:05 PM
To: llvm/llvm-project ***@***.***>
Cc: Anoop Kumar ***@***.***>; Author ***@***.***>
Subject: [EXTERNAL] Re: [llvm/llvm-project] Fix Endianess issue (PR #162881)
vitalybuka left a comment (llvm/llvm-project#162881) 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). Is #162195 enough? I'd expect sanitizers
[https://avatars.githubusercontent.com/u/1531415?s=20&v=4%5Dvitalybuka left a comment (llvm/llvm-project#162881)<#162881 (comment) >
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<#162195 >).
Is #162195<#162195 > enough?
I'd expect sanitizers does a lot of assumptions on little-endianness.
—
Reply to this email directly, view it on GitHub<#162881 (comment) >, or unsubscribe<https://github.com/notifications/unsubscribe-auth/BM5K4GXOGNHB3NB43QBTZFL3XAGQBAVCNFSM6AAAAACI3L4A5CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTGOJSGE3DENZQGM >.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Fix Endianess issue with getting shadow 4 bytes corresponding to the first origin pointer.