https://llvm.org/bugs/show_bug.cgi?id=24065
Bug ID: 24065
Summary: CloneFunction ovewrites requested replacements - PATCH
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Transformation Utilities
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Classification: Unclassified
The utility "CloneFunction" provides a ValueMap to describe requested
replacements of the cloned function's Values. When the cloning process goes
through the functions, it unconditionally adds the cloned instruction as a
replacement to the original.
The attached patch checks that a Value has not yet specified to replace and
instruction before adding such entry to the map.
We are not sure if this was the originally intended behaviour though and
therefore don't know if this is indeed a bug:
$ svn diff lib/Transforms/Utils/CloneFunction.cpp
Index: lib/Transforms/Utils/CloneFunction.cpp
===================================================================
--- lib/Transforms/Utils/CloneFunction.cpp (revision 241669)
+++ lib/Transforms/Utils/CloneFunction.cpp (working copy)
@@ -51,7 +51,8 @@
if (II->hasName())
NewInst->setName(II->getName()+NameSuffix);
NewBB->getInstList().push_back(NewInst);
- VMap[II] = NewInst; // Add instruction map to value.
+ if (VMap.find(II) == VMap.end())
+ VMap[II] = NewInst; // Add instruction map to value.
hasCalls |= (isa<CallInst>(II) && !isa<DbgInfoIntrinsic>(II));
if (const AllocaInst *AI = dyn_cast<AllocaInst>(II)) {
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs