[llvm-bugs] [Bug 25505] New: [Polly] Loop invariant code motion, structures and non-power-of-two types cause miscompile
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Nov 12 03:35:26 PST 2015
https://llvm.org/bugs/show_bug.cgi?id=25505
Bug ID: 25505
Summary: [Polly] Loop invariant code motion, structures and
non-power-of-two types cause miscompile
Product: Projects
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Polly
Assignee: polly-dev at googlegroups.com
Reporter: tobias at grosser.es
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
With 252860 Polly currently miscompiles LNT MultiSource/Applications/obsequi.
The miscompilation is in hash.c:hashlookup at the last
LOOKUP_ENTRY(g_flipVH_hashkey) call.
Two issues I see:
1) We hoist loads from Non-Affine Region Statements. For such statements we
do not necessarily know that loads will be executed, hence hoisting them
may cause segfaults (may not be part of the issue here)
2) When creating access locations we generate incorrect code in case number of
bytes and actual allocation size of a type do not match. Below is a patch that
might fix this, but it has not yet been properly tested and is possibly
incomplete.
@@ -171,6 +171,18 @@ Value *IslExprBuilder::createAccessAddress(isl_ast_expr
*Expr) {
Builder.CreateMul(IndexOp, DimSize, "polly.access.mul." + BaseName);
}
+ auto &DL =
+ Builder.GetInsertBlock()->getParent()->getParent()->getDataLayout();
+ unsigned int StorageSize = DL.getTypeAllocSize(SAI->getElementType());
+ unsigned int ElementSize = SAI->getElemSizeInBytes();
+ if (!SAI->getElementType()->isPointerTy() && ElementSize != StorageSize) {
+ Value *ElementValue = Builder.getInt8(ElementSize);
+ Value *StorageValue = Builder.getInt8(StorageSize);
+ ElementValue = Builder.CreateSExt(ElementValue, IndexOp->getType());
+ StorageValue = Builder.CreateSExt(StorageValue, IndexOp->getType());
+ IndexOp = Builder.CreateMul(IndexOp, ElementValue);
+ IndexOp = Builder.CreateSDiv(IndexOp, StorageValue);
+ }
This patch prevents us from segfaulting for this test case.
3) Even with this patch applied, we still miscompile the test case. I have no
idea what is going on.
I need to move to other stuff know, but if someone could have a look that would
be appreciated.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20151112/a0f6131e/attachment.html>
More information about the llvm-bugs
mailing list