Skip to content

Commit e2d14f5

Browse files
choikwaDDEle
authored andcommitted
Reject noalias ptr argument case in SCCPSolver::mergeInValue
1 parent 212ca38 commit e2d14f5

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

llvm/lib/Transforms/Utils/InlineFunction.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,7 @@ static void AddAliasScopeMetadata(CallBase &CB, ValueToValueMapTy &VMap,
11181118
ClonedCodeInfo &InlinedFunctionInfo) {
11191119
if (!EnableNoAliasConversion)
11201120
return;
1121-
1121+
LLVM_DEBUG(dbgs() << __func__ << "\n");
11221122
const Function *CalledFunc = CB.getCalledFunction();
11231123
SmallVector<const Argument *, 4> NoAliasArgs;
11241124

@@ -1246,8 +1246,12 @@ static void AddAliasScopeMetadata(CallBase &CB, ValueToValueMapTy &VMap,
12461246

12471247
for (const Value *V : PtrArgs) {
12481248
SmallVector<const Value *, 4> Objects;
1249+
LLVM_DEBUG(dbgs() << "Getting objects for V: " << *V << "\n");
12491250
getUnderlyingObjects(V, Objects, /* LI = */ nullptr);
1250-
1251+
LLVM_DEBUG(
1252+
for (const auto *O : Objects) {
1253+
dbgs() << " Obj: " << *O << "\n";
1254+
});
12511255
ObjSet.insert_range(Objects);
12521256
}
12531257

@@ -2603,6 +2607,12 @@ void llvm::InlineFunctionImpl(CallBase &CB, InlineFunctionInfo &IFI,
26032607
assert(CalledFunc && !CalledFunc->isDeclaration() &&
26042608
"CanInlineCallSite should have verified direct call to definition");
26052609

2610+
LLVM_DEBUG(
2611+
dbgs() << "Caller: " << Caller->getName() << "\n";
2612+
dbgs() << "<-- Callee: " << CalledFunc->getName() << "\n";
2613+
dbgs() << "Callee body:\n" << *CalledFunc << "\n";
2614+
);
2615+
26062616
// Determine if we are dealing with a call in an EHPad which does not unwind
26072617
// to caller.
26082618
bool EHPadForCallUnwindsLocally = false;

llvm/lib/Transforms/Utils/SCCPSolver.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,6 +1168,11 @@ void SCCPInstVisitor::visitInstruction(Instruction &I) {
11681168
bool SCCPInstVisitor::mergeInValue(ValueLatticeElement &IV, Value *V,
11691169
ValueLatticeElement MergeWithV,
11701170
ValueLatticeElement::MergeOptions Opts) {
1171+
if (const auto *Arg = dyn_cast<Argument>(V)) {
1172+
if (isa<PointerType>(Arg->getType()) &&
1173+
Arg->hasNoAliasAttr())
1174+
return false; // do not merge w/ noalias ptr.
1175+
}
11711176
if (IV.mergeIn(MergeWithV, Opts)) {
11721177
pushUsersToWorkList(V);
11731178
LLVM_DEBUG(dbgs() << "Merged " << MergeWithV << " into " << *V << " : "

0 commit comments

Comments
 (0)