[Openmp-commits] [openmp] 9c08e76 - [Attributor] Introduce AAIndirectCallInfo
Johannes Doerfert via Openmp-commits
openmp-commits at lists.llvm.org
Fri Aug 18 16:44:53 PDT 2023
Author: Johannes Doerfert
Date: 2023-08-18T16:44:05-07:00
New Revision: 9c08e76f3e5f2f3e8cb1e3c9fd45827395c712cc
URL: https://github.com/llvm/llvm-project/commit/9c08e76f3e5f2f3e8cb1e3c9fd45827395c712cc
DIFF: https://github.com/llvm/llvm-project/commit/9c08e76f3e5f2f3e8cb1e3c9fd45827395c712cc.diff
LOG: [Attributor] Introduce AAIndirectCallInfo
AAIndirectCallInfo will collect information and specialize indirect call
sites. It is similar to our IndirectCallPromotion but runs as part of
the Attributor (so with assumed callee information). It also expands
more calls and let's the rest of the pipeline figure out what is UB, for
now. We use existing call promotion logic to improve the result,
otherwise we rely on the (implicit) function pointer cast.
This effectively "fixes" #60327 as it will undo the type punning early
enough for the inliner to work with the (now specialized, thus direct)
call.
Fixes: https://github.com/llvm/llvm-project/issues/60327
Added:
Modified:
llvm/include/llvm/Transforms/IPO/Attributor.h
llvm/lib/Transforms/IPO/Attributor.cpp
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
llvm/test/Transforms/Attributor/callgraph.ll
llvm/test/Transforms/Attributor/value-simplify.ll
openmp/libomptarget/test/jit/type_punning.c
Removed:
################################################################################
diff --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h
index 5793ca4f9b5359..71692eb3719a39 100644
--- a/llvm/include/llvm/Transforms/IPO/Attributor.h
+++ b/llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -6109,6 +6109,48 @@ struct AAAddressSpace : public StateWrapper<BooleanState, AbstractAttribute> {
static const char ID;
};
+/// An abstract interface for indirect call information interference.
+struct AAIndirectCallInfo
+ : public StateWrapper<BooleanState, AbstractAttribute> {
+ AAIndirectCallInfo(const IRPosition &IRP, Attributor &A)
+ : StateWrapper<BooleanState, AbstractAttribute>(IRP) {}
+
+ /// The point is to derive callees, after all.
+ static bool requiresCalleeForCallBase() { return false; }
+
+ /// See AbstractAttribute::isValidIRPositionForInit
+ static bool isValidIRPositionForInit(Attributor &A, const IRPosition &IRP) {
+ if (IRP.getPositionKind() != IRPosition::IRP_CALL_SITE)
+ return false;
+ auto *CB = cast<CallBase>(IRP.getCtxI());
+ return CB->getOpcode() == Instruction::Call && CB->isIndirectCall() &&
+ !CB->isMustTailCall();
+ }
+
+ /// Create an abstract attribute view for the position \p IRP.
+ static AAIndirectCallInfo &createForPosition(const IRPosition &IRP,
+ Attributor &A);
+
+ /// Call \CB on each potential callee value and return true if all were known
+ /// and \p CB returned true on all of them. Otherwise, return false.
+ virtual bool foreachCallee(function_ref<bool(Function *)> CB) const = 0;
+
+ /// See AbstractAttribute::getName()
+ const std::string getName() const override { return "AAIndirectCallInfo"; }
+
+ /// See AbstractAttribute::getIdAddr()
+ const char *getIdAddr() const override { return &ID; }
+
+ /// This function should return true if the type of the \p AA is
+ /// AAIndirectCallInfo
+ static bool classof(const AbstractAttribute *AA) {
+ return (AA->getIdAddr() == &ID);
+ }
+
+ /// Unique ID (due to the unique address)
+ static const char ID;
+};
+
raw_ostream &operator<<(raw_ostream &, const AAPointerInfo::Access &);
/// Run options, used by the pass manager.
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index a2ab36abb06689..892502ac034a52 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -3460,8 +3460,10 @@ void Attributor::identifyDefaultAbstractAttributes(Function &F) {
Function *Callee = dyn_cast_if_present<Function>(CB.getCalledOperand());
// TODO: Even if the callee is not known now we might be able to simplify
// the call/callee.
- if (!Callee)
+ if (!Callee) {
+ getOrCreateAAFor<AAIndirectCallInfo>(CBFnPos);
return true;
+ }
// Every call site can track active assumptions.
getOrCreateAAFor<AAAssumptionInfo>(CBFnPos);
diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index 987345b32feb05..07439ff39384c1 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -65,11 +65,14 @@
#include "llvm/Support/GraphWriter.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
+#include "llvm/Transforms/Utils/BasicBlockUtils.h"
+#include "llvm/Transforms/Utils/CallPromotionUtils.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Transforms/Utils/ValueMapper.h"
#include <cassert>
#include <numeric>
#include <optional>
+#include <string>
using namespace llvm;
@@ -188,6 +191,7 @@ PIPE_OPERATOR(AAPointerInfo)
PIPE_OPERATOR(AAAssumptionInfo)
PIPE_OPERATOR(AAUnderlyingObjects)
PIPE_OPERATOR(AAAddressSpace)
+PIPE_OPERATOR(AAIndirectCallInfo)
#undef PIPE_OPERATOR
@@ -10560,15 +10564,12 @@ struct AACallEdgesCallSite : public AACallEdgesImpl {
return Change;
}
- // Process callee metadata if available.
- if (auto *MD = getCtxI()->getMetadata(LLVMContext::MD_callees)) {
- for (const auto &Op : MD->operands()) {
- Function *Callee = mdconst::dyn_extract_or_null<Function>(Op);
- if (Callee)
- addCalledFunction(Callee, Change);
- }
- return Change;
- }
+ if (CB->isIndirectCall())
+ if (auto *IndirectCallAA = A.getAAFor<AAIndirectCallInfo>(
+ *this, getIRPosition(), DepClassTy::OPTIONAL))
+ if (IndirectCallAA->foreachCallee(
+ [&](Function *Fn) { return VisitValue(*Fn, CB); }))
+ return Change;
// The most simple case.
ProcessCalledOperand(CB->getCalledOperand(), CB);
@@ -12051,6 +12052,224 @@ struct AAUnderlyingObjectsFunction final : AAUnderlyingObjectsImpl {
};
} // namespace
+/// ------------------------ Indirect Call Info -------------------------------
+namespace {
+struct AAIndirectCallInfoCallSite : public AAIndirectCallInfo {
+ AAIndirectCallInfoCallSite(const IRPosition &IRP, Attributor &A)
+ : AAIndirectCallInfo(IRP, A) {}
+
+ /// See AbstractAttribute::initialize(...).
+ void initialize(Attributor &A) override {
+ auto *MD = getCtxI()->getMetadata(LLVMContext::MD_callees);
+ if (!MD)
+ return;
+ for (const auto &Op : MD->operands())
+ if (Function *Callee = mdconst::dyn_extract_or_null<Function>(Op))
+ PotentialCallees.insert(Callee);
+ }
+
+ ChangeStatus updateImpl(Attributor &A) override {
+ CallBase *CB = cast<CallBase>(getCtxI());
+ Value *FP = CB->getCalledOperand();
+
+ SmallSetVector<Function *, 4> AssumedCalleesNow;
+ bool AllCalleesKnownNow = AllCalleesKnown;
+
+ // Use simplification to find potential callees, if !callees was present,
+ // fallback to that set if necessary.
+ bool UsedAssumedInformation;
+ SmallVector<AA::ValueAndContext> Values;
+ if (!A.getAssumedSimplifiedValues(IRPosition::value(*FP), this, Values,
+ AA::ValueScope::AnyScope,
+ UsedAssumedInformation)) {
+ if (PotentialCallees.empty())
+ return indicatePessimisticFixpoint();
+ AssumedCalleesNow.set_union(PotentialCallees);
+ }
+
+ // Check simplification result, prune known UB callees, also restrict it to
+ // the !callees set, if present.
+ for (auto &VAC : Values) {
+ if (isa<UndefValue>(VAC.getValue()))
+ continue;
+ if (isa<ConstantPointerNull>(VAC.getValue()) &&
+ VAC.getValue()->getType()->getPointerAddressSpace() == 0)
+ continue;
+ // TODO: Check for known UB, e.g., poison + noundef.
+ if (auto *VACFn = dyn_cast<Function>(VAC.getValue())) {
+ if (PotentialCallees.empty() || PotentialCallees.count(VACFn))
+ AssumedCalleesNow.insert(VACFn);
+ continue;
+ }
+ if (!PotentialCallees.empty()) {
+ AssumedCalleesNow.set_union(PotentialCallees);
+ break;
+ }
+ AllCalleesKnownNow = false;
+ }
+
+ // If we can't specialize at all, give up now.
+ if (!AllCalleesKnownNow && AssumedCalleesNow.empty())
+ return indicatePessimisticFixpoint();
+
+ if (AssumedCalleesNow == AssumedCalles &&
+ AllCalleesKnown == AllCalleesKnownNow)
+ return ChangeStatus::UNCHANGED;
+
+ std::swap(AssumedCalles, AssumedCalleesNow);
+ AllCalleesKnown = AllCalleesKnownNow;
+ return ChangeStatus::CHANGED;
+ }
+
+ /// See AbstractAttribute::manifest(...).
+ ChangeStatus manifest(Attributor &A) override {
+
+ ChangeStatus Changed = ChangeStatus::UNCHANGED;
+ CallBase *CB = cast<CallBase>(getCtxI());
+ Value *FP = CB->getCalledOperand();
+
+ bool CBIsVoid = CB->getType()->isVoidTy();
+ Instruction *IP = CB;
+ FunctionType *CSFT = CB->getFunctionType();
+ SmallVector<Value *> CSArgs(CB->arg_begin(), CB->arg_end());
+
+ // If we know all callees and there are none, the call site is (effectively)
+ // dead (or UB).
+ if (AssumedCalles.empty()) {
+ assert(AllCalleesKnown &&
+ "Expected all callees to be known if there are none.");
+ A.changeToUnreachableAfterManifest(CB);
+ return ChangeStatus::CHANGED;
+ }
+
+ // Special handling for the single callee case.
+ if (AllCalleesKnown && AssumedCalles.size() == 1) {
+ auto *NewCallee = AssumedCalles.front();
+ if (isLegalToPromote(*CB, NewCallee)) {
+ promoteCall(*CB, NewCallee, nullptr);
+ return ChangeStatus::CHANGED;
+ }
+ Instruction *NewCall = CallInst::Create(FunctionCallee(CSFT, NewCallee),
+ CSArgs, CB->getName(), CB);
+ if (!CBIsVoid)
+ A.changeAfterManifest(IRPosition::callsite_returned(*CB), *NewCall);
+ A.deleteAfterManifest(*CB);
+ return ChangeStatus::CHANGED;
+ }
+
+ // For each potential value we create a conditional
+ //
+ // ```
+ // if (ptr == value) value(args);
+ // else ...
+ // ```
+ //
+ ICmpInst *LastCmp = nullptr;
+ SmallVector<std::pair<CallInst *, Instruction *>> NewCalls;
+ for (Function *NewCallee : AssumedCalles) {
+ LastCmp = new ICmpInst(IP, llvm::CmpInst::ICMP_EQ, FP, NewCallee);
+ Instruction *ThenTI =
+ SplitBlockAndInsertIfThen(LastCmp, IP, /* Unreachable */ false);
+ BasicBlock *CBBB = CB->getParent();
+ auto *SplitTI = cast<BranchInst>(LastCmp->getNextNode());
+ BasicBlock *ElseBB;
+ if (IP == CB) {
+ ElseBB = BasicBlock::Create(ThenTI->getContext(), "",
+ ThenTI->getFunction(), CBBB);
+ IP = BranchInst::Create(CBBB, ElseBB);
+ SplitTI->replaceUsesOfWith(CBBB, ElseBB);
+ } else {
+ ElseBB = IP->getParent();
+ ThenTI->replaceUsesOfWith(ElseBB, CBBB);
+ }
+ CastInst *RetBC = nullptr;
+ CallInst *NewCall = nullptr;
+ if (isLegalToPromote(*CB, NewCallee)) {
+ auto *CBClone = cast<CallBase>(CB->clone());
+ CBClone->insertBefore(ThenTI);
+ NewCall = &cast<CallInst>(promoteCall(*CBClone, NewCallee, &RetBC));
+ } else {
+ NewCall = CallInst::Create(FunctionCallee(CSFT, NewCallee), CSArgs,
+ CB->getName(), ThenTI);
+ }
+ NewCalls.push_back({NewCall, RetBC});
+ }
+
+ // Check if we need the fallback indirect call still.
+ if (AllCalleesKnown) {
+ LastCmp->replaceAllUsesWith(ConstantInt::getTrue(LastCmp->getContext()));
+ LastCmp->eraseFromParent();
+ new UnreachableInst(IP->getContext(), IP);
+ IP->eraseFromParent();
+ } else {
+ auto *CBClone = cast<CallInst>(CB->clone());
+ CBClone->setName(CB->getName());
+ CBClone->insertBefore(IP);
+ NewCalls.push_back({CBClone, nullptr});
+ }
+
+ // Check if we need a PHI to merge the results.
+ if (!CBIsVoid) {
+ auto *PHI = PHINode::Create(CB->getType(), NewCalls.size(),
+ CB->getName() + ".phi",
+ &*CB->getParent()->getFirstInsertionPt());
+ for (auto &It : NewCalls) {
+ CallBase *NewCall = It.first;
+ Instruction *CallRet = It.second ? It.second : It.first;
+ if (CallRet->getType() == CB->getType())
+ PHI->addIncoming(CallRet, CallRet->getParent());
+ else if (NewCall->getType()->isVoidTy())
+ PHI->addIncoming(PoisonValue::get(CB->getType()),
+ NewCall->getParent());
+ else
+ llvm_unreachable("Call return should match or be void!");
+ }
+ A.changeAfterManifest(IRPosition::callsite_returned(*CB), *PHI);
+ }
+
+ A.deleteAfterManifest(*CB);
+ Changed = ChangeStatus::CHANGED;
+
+ return Changed;
+ }
+
+ /// See AbstractAttribute::getAsStr().
+ const std::string getAsStr(Attributor *A) const override {
+ return std::string(AllCalleesKnown ? "eliminate" : "specialize") +
+ " indirect call site with " + std::to_string(AssumedCalles.size()) +
+ " functions";
+ }
+
+ void trackStatistics() const override {
+ if (AllCalleesKnown) {
+ STATS_DECLTRACK(
+ Eliminated, CallSites,
+ "Number of indirect call sites eliminated via specialization")
+ } else {
+ STATS_DECLTRACK(Specialized, CallSites,
+ "Number of indirect call sites specialized")
+ }
+ }
+
+ bool foreachCallee(function_ref<bool(Function *)> CB) const override {
+ return isValidState() && AllCalleesKnown && all_of(AssumedCalles, CB);
+ }
+
+private:
+ /// If the !callee metadata was present, this set will contain all potential
+ /// callees (superset).
+ SmallSetVector<Function *, 4> PotentialCallees;
+
+ /// This set contains all currently assumed calllees, which might grow over
+ /// time.
+ SmallSetVector<Function *, 4> AssumedCalles;
+
+ /// Flag to indicate if all possible callees are in the AssumedCalles set or
+ /// if there could be others.
+ bool AllCalleesKnown = true;
+};
+} // namespace
+
/// ------------------------ Address Space ------------------------------------
namespace {
struct AAAddressSpaceImpl : public AAAddressSpace {
@@ -12259,6 +12478,7 @@ const char AAPointerInfo::ID = 0;
const char AAAssumptionInfo::ID = 0;
const char AAUnderlyingObjects::ID = 0;
const char AAAddressSpace::ID = 0;
+const char AAIndirectCallInfo::ID = 0;
// Macro magic to create the static generator function for attributes that
// follow the naming scheme.
@@ -12305,6 +12525,18 @@ const char AAAddressSpace::ID = 0;
return *AA; \
}
+#define CREATE_ABSTRACT_ATTRIBUTE_FOR_ONE_POSITION(POS, SUFFIX, CLASS) \
+ CLASS &CLASS::createForPosition(const IRPosition &IRP, Attributor &A) { \
+ CLASS *AA = nullptr; \
+ switch (IRP.getPositionKind()) { \
+ SWITCH_PK_CREATE(CLASS, IRP, POS, SUFFIX) \
+ default: \
+ llvm_unreachable("Cannot create " #CLASS " for position otherthan " #POS \
+ " position!"); \
+ } \
+ return *AA; \
+ }
+
#define CREATE_ALL_ABSTRACT_ATTRIBUTE_FOR_POSITION(CLASS) \
CLASS &CLASS::createForPosition(const IRPosition &IRP, Attributor &A) { \
CLASS *AA = nullptr; \
@@ -12383,6 +12615,9 @@ CREATE_ALL_ABSTRACT_ATTRIBUTE_FOR_POSITION(AAIsDead)
CREATE_ALL_ABSTRACT_ATTRIBUTE_FOR_POSITION(AANoFree)
CREATE_ALL_ABSTRACT_ATTRIBUTE_FOR_POSITION(AAUnderlyingObjects)
+CREATE_ABSTRACT_ATTRIBUTE_FOR_ONE_POSITION(IRP_CALL_SITE, CallSite,
+ AAIndirectCallInfo)
+
CREATE_FUNCTION_ONLY_ABSTRACT_ATTRIBUTE_FOR_POSITION(AAHeapToStack)
CREATE_FUNCTION_ONLY_ABSTRACT_ATTRIBUTE_FOR_POSITION(AAUndefinedBehavior)
CREATE_FUNCTION_ONLY_ABSTRACT_ATTRIBUTE_FOR_POSITION(AANonConvergent)
@@ -12396,5 +12631,6 @@ CREATE_NON_RET_ABSTRACT_ATTRIBUTE_FOR_POSITION(AAMemoryBehavior)
#undef CREATE_NON_RET_ABSTRACT_ATTRIBUTE_FOR_POSITION
#undef CREATE_VALUE_ABSTRACT_ATTRIBUTE_FOR_POSITION
#undef CREATE_ALL_ABSTRACT_ATTRIBUTE_FOR_POSITION
+#undef CREATE_ABSTRACT_ATTRIBUTE_FOR_ONE_POSITION
#undef SWITCH_PK_CREATE
#undef SWITCH_PK_INV
diff --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
index 88d7d6a5c91e61..c19ce9000f9768 100644
--- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -5419,6 +5419,11 @@ void OpenMPOpt::registerAAsForFunction(Attributor &A, const Function &F) {
UsedAssumedInformation, AA::Interprocedural);
continue;
}
+ if (auto *CI = dyn_cast<CallBase>(&I)) {
+ if (CI->isIndirectCall())
+ A.getOrCreateAAFor<AAIndirectCallInfo>(
+ IRPosition::callsite_function(*CI));
+ }
if (auto *SI = dyn_cast<StoreInst>(&I)) {
A.getOrCreateAAFor<AAIsDead>(IRPosition::value(*SI));
continue;
diff --git a/llvm/test/Transforms/Attributor/callgraph.ll b/llvm/test/Transforms/Attributor/callgraph.ll
index 6dddd84452dabd..492c17a4aeb341 100644
--- a/llvm/test/Transforms/Attributor/callgraph.ll
+++ b/llvm/test/Transforms/Attributor/callgraph.ll
@@ -40,7 +40,19 @@ define void @func5(i32 %0) {
; CHECK-LABEL: @func5(
; CHECK-NEXT: [[TMP2:%.*]] = icmp ne i32 [[TMP0:%.*]], 0
; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP2]], ptr @func4, ptr @func3
-; CHECK-NEXT: call void [[TMP3]]()
+; CHECK-NEXT: [[TMP4:%.*]] = icmp eq ptr [[TMP3]], @func3
+; CHECK-NEXT: br i1 [[TMP4]], label [[TMP5:%.*]], label [[TMP6:%.*]]
+; CHECK: 5:
+; CHECK-NEXT: call void @func3()
+; CHECK-NEXT: br label [[TMP9:%.*]]
+; CHECK: 6:
+; CHECK-NEXT: br i1 true, label [[TMP7:%.*]], label [[TMP8:%.*]]
+; CHECK: 7:
+; CHECK-NEXT: call void @func4()
+; CHECK-NEXT: br label [[TMP9]]
+; CHECK: 8:
+; CHECK-NEXT: unreachable
+; CHECK: 9:
; CHECK-NEXT: ret void
;
%2 = icmp ne i32 %0, 0
@@ -72,8 +84,35 @@ define i32 @non_matching_fp1(i1 %c1, i1 %c2, i1 %c) {
; CHECK-NEXT: [[FP1:%.*]] = select i1 [[C1:%.*]], ptr @retI32, ptr @takeI32
; CHECK-NEXT: [[FP2:%.*]] = select i1 [[C2:%.*]], ptr @retFloatTakeFloat, ptr @void
; CHECK-NEXT: [[FP:%.*]] = select i1 [[C:%.*]], ptr [[FP1]], ptr [[FP2]]
-; CHECK-NEXT: [[CALL:%.*]] = call i32 [[FP]](i32 42)
-; CHECK-NEXT: ret i32 [[CALL]]
+; CHECK-NEXT: [[TMP1:%.*]] = icmp eq ptr [[FP]], @takeI32
+; CHECK-NEXT: br i1 [[TMP1]], label [[TMP2:%.*]], label [[TMP3:%.*]]
+; CHECK: 2:
+; CHECK-NEXT: [[CALL1:%.*]] = call i32 @takeI32(i32 42)
+; CHECK-NEXT: br label [[TMP15:%.*]]
+; CHECK: 3:
+; CHECK-NEXT: [[TMP4:%.*]] = icmp eq ptr [[FP]], @retI32
+; CHECK-NEXT: br i1 [[TMP4]], label [[TMP5:%.*]], label [[TMP6:%.*]]
+; CHECK: 5:
+; CHECK-NEXT: [[CALL2:%.*]] = call i32 @retI32(i32 42)
+; CHECK-NEXT: br label [[TMP15]]
+; CHECK: 6:
+; CHECK-NEXT: [[TMP7:%.*]] = icmp eq ptr [[FP]], @void
+; CHECK-NEXT: br i1 [[TMP7]], label [[TMP8:%.*]], label [[TMP9:%.*]]
+; CHECK: 8:
+; CHECK-NEXT: [[CALL3:%.*]] = call i32 @void(i32 42)
+; CHECK-NEXT: br label [[TMP15]]
+; CHECK: 9:
+; CHECK-NEXT: br i1 true, label [[TMP10:%.*]], label [[TMP14:%.*]]
+; CHECK: 10:
+; CHECK-NEXT: [[TMP11:%.*]] = bitcast i32 42 to float
+; CHECK-NEXT: [[TMP12:%.*]] = call float @retFloatTakeFloat(float [[TMP11]])
+; CHECK-NEXT: [[TMP13:%.*]] = bitcast float [[TMP12]] to i32
+; CHECK-NEXT: br label [[TMP15]]
+; CHECK: 14:
+; CHECK-NEXT: unreachable
+; CHECK: 15:
+; CHECK-NEXT: [[CALL_PHI:%.*]] = phi i32 [ [[CALL1]], [[TMP2]] ], [ [[CALL2]], [[TMP5]] ], [ [[CALL3]], [[TMP8]] ], [ [[TMP13]], [[TMP10]] ]
+; CHECK-NEXT: ret i32 [[CALL_PHI]]
;
%fp1 = select i1 %c1, ptr @retI32, ptr @takeI32
%fp2 = select i1 %c2, ptr @retFloatTakeFloat, ptr @void
@@ -87,7 +126,27 @@ define void @non_matching_fp2(i1 %c1, i1 %c2, i1 %c, ptr %unknown) {
; CHECK-NEXT: [[FP1:%.*]] = select i1 [[C1:%.*]], ptr @retI32, ptr @takeI32
; CHECK-NEXT: [[FP2:%.*]] = select i1 [[C2:%.*]], ptr @retFloatTakeFloat, ptr [[UNKNOWN:%.*]]
; CHECK-NEXT: [[FP:%.*]] = select i1 [[C:%.*]], ptr [[FP1]], ptr [[FP2]]
+; CHECK-NEXT: [[TMP1:%.*]] = icmp eq ptr [[FP]], @takeI32
+; CHECK-NEXT: br i1 [[TMP1]], label [[TMP2:%.*]], label [[TMP3:%.*]]
+; CHECK: 2:
+; CHECK-NEXT: call void @takeI32()
+; CHECK-NEXT: br label [[TMP10:%.*]]
+; CHECK: 3:
+; CHECK-NEXT: [[TMP4:%.*]] = icmp eq ptr [[FP]], @retI32
+; CHECK-NEXT: br i1 [[TMP4]], label [[TMP5:%.*]], label [[TMP6:%.*]]
+; CHECK: 5:
+; CHECK-NEXT: call void @retI32()
+; CHECK-NEXT: br label [[TMP10]]
+; CHECK: 6:
+; CHECK-NEXT: [[TMP7:%.*]] = icmp eq ptr [[FP]], @retFloatTakeFloat
+; CHECK-NEXT: br i1 [[TMP7]], label [[TMP8:%.*]], label [[TMP9:%.*]]
+; CHECK: 8:
+; CHECK-NEXT: call void @retFloatTakeFloat()
+; CHECK-NEXT: br label [[TMP10]]
+; CHECK: 9:
; CHECK-NEXT: call void [[FP]]()
+; CHECK-NEXT: br label [[TMP10]]
+; CHECK: 10:
; CHECK-NEXT: ret void
;
%fp1 = select i1 %c1, ptr @retI32, ptr @takeI32
@@ -100,8 +159,17 @@ define void @non_matching_fp2(i1 %c1, i1 %c2, i1 %c, ptr %unknown) {
define i32 @non_matching_unknown(i1 %c, ptr %fn) {
; CHECK-LABEL: @non_matching_unknown(
; CHECK-NEXT: [[FP:%.*]] = select i1 [[C:%.*]], ptr @retI32, ptr [[FN:%.*]]
-; CHECK-NEXT: [[CALL:%.*]] = call i32 [[FP]](i32 42)
-; CHECK-NEXT: ret i32 [[CALL]]
+; CHECK-NEXT: [[TMP1:%.*]] = icmp eq ptr [[FP]], @retI32
+; CHECK-NEXT: br i1 [[TMP1]], label [[TMP2:%.*]], label [[TMP3:%.*]]
+; CHECK: 2:
+; CHECK-NEXT: [[CALL1:%.*]] = call i32 @retI32(i32 42)
+; CHECK-NEXT: br label [[TMP4:%.*]]
+; CHECK: 3:
+; CHECK-NEXT: [[CALL2:%.*]] = call i32 [[FP]](i32 42)
+; CHECK-NEXT: br label [[TMP4]]
+; CHECK: 4:
+; CHECK-NEXT: [[CALL_PHI:%.*]] = phi i32 [ [[CALL1]], [[TMP2]] ], [ [[CALL2]], [[TMP3]] ]
+; CHECK-NEXT: ret i32 [[CALL_PHI]]
;
%fp = select i1 %c, ptr @retI32, ptr %fn
%call = call i32 %fp(i32 42)
@@ -128,7 +196,19 @@ define void @func6() {
define void @func7(ptr %unknown) {
; CHECK-LABEL: @func7(
-; CHECK-NEXT: call void [[UNKNOWN:%.*]](), !callees !2
+; CHECK-NEXT: [[TMP1:%.*]] = icmp eq ptr [[UNKNOWN:%.*]], @func3
+; CHECK-NEXT: br i1 [[TMP1]], label [[TMP2:%.*]], label [[TMP3:%.*]]
+; CHECK: 2:
+; CHECK-NEXT: call void @func3()
+; CHECK-NEXT: br label [[TMP6:%.*]]
+; CHECK: 3:
+; CHECK-NEXT: br i1 true, label [[TMP4:%.*]], label [[TMP5:%.*]]
+; CHECK: 4:
+; CHECK-NEXT: call void @func4()
+; CHECK-NEXT: br label [[TMP6]]
+; CHECK: 5:
+; CHECK-NEXT: unreachable
+; CHECK: 6:
; CHECK-NEXT: ret void
;
call void %unknown(), !callees !2
@@ -139,7 +219,7 @@ define void @func7(ptr %unknown) {
define void @undef_in_callees() {
; CHECK-LABEL: @undef_in_callees(
; CHECK-NEXT: cond.end.i:
-; CHECK-NEXT: call void undef(ptr undef, i32 undef, ptr undef), !callees !3
+; CHECK-NEXT: call void undef(ptr undef, i32 undef, ptr undef), !callees !2
; CHECK-NEXT: ret void
;
cond.end.i:
diff --git a/llvm/test/Transforms/Attributor/value-simplify.ll b/llvm/test/Transforms/Attributor/value-simplify.ll
index c3f0e6676e514c..415f39e7b292ca 100644
--- a/llvm/test/Transforms/Attributor/value-simplify.ll
+++ b/llvm/test/Transforms/Attributor/value-simplify.ll
@@ -109,11 +109,11 @@ define i32 @test2_1(i1 %c) {
; CGSCC-SAME: (i1 noundef [[C:%.*]]) #[[ATTR3:[0-9]+]] {
; CGSCC-NEXT: br i1 [[C]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
; CGSCC: if.true:
-; CGSCC-NEXT: [[CALL:%.*]] = tail call i32 @return0() #[[ATTR12:[0-9]+]]
+; CGSCC-NEXT: [[CALL:%.*]] = tail call i32 @return0() #[[ATTR13:[0-9]+]]
; CGSCC-NEXT: [[RET0:%.*]] = add i32 [[CALL]], 1
; CGSCC-NEXT: br label [[END:%.*]]
; CGSCC: if.false:
-; CGSCC-NEXT: [[RET1:%.*]] = tail call i32 @return1() #[[ATTR12]]
+; CGSCC-NEXT: [[RET1:%.*]] = tail call i32 @return1() #[[ATTR13]]
; CGSCC-NEXT: br label [[END]]
; CGSCC: end:
; CGSCC-NEXT: [[RET:%.*]] = phi i32 [ [[RET0]], [[IF_TRUE]] ], [ [[RET1]], [[IF_FALSE]] ]
@@ -145,7 +145,7 @@ define i32 @test2_2(i1 %c) {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@test2_2
; CGSCC-SAME: (i1 noundef [[C:%.*]]) #[[ATTR3]] {
-; CGSCC-NEXT: [[RET:%.*]] = tail call noundef i32 @test2_1(i1 noundef [[C]]) #[[ATTR12]]
+; CGSCC-NEXT: [[RET:%.*]] = tail call noundef i32 @test2_1(i1 noundef [[C]]) #[[ATTR13]]
; CGSCC-NEXT: ret i32 [[RET]]
;
%ret = tail call i32 @test2_1(i1 %c)
@@ -172,7 +172,7 @@ define void @test3(i1 %c) {
; CGSCC: if.true:
; CGSCC-NEXT: br label [[END:%.*]]
; CGSCC: if.false:
-; CGSCC-NEXT: [[RET1:%.*]] = tail call i32 @return1() #[[ATTR13:[0-9]+]]
+; CGSCC-NEXT: [[RET1:%.*]] = tail call i32 @return1() #[[ATTR14:[0-9]+]]
; CGSCC-NEXT: br label [[END]]
; CGSCC: end:
; CGSCC-NEXT: [[R:%.*]] = phi i32 [ 1, [[IF_TRUE]] ], [ [[RET1]], [[IF_FALSE]] ]
@@ -303,7 +303,7 @@ define i1 @ipccp2() {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@ipccp2
; CGSCC-SAME: () #[[ATTR3]] {
-; CGSCC-NEXT: [[R:%.*]] = call noundef i1 @ipccp2i() #[[ATTR12]]
+; CGSCC-NEXT: [[R:%.*]] = call noundef i1 @ipccp2i() #[[ATTR13]]
; CGSCC-NEXT: ret i1 [[R]]
;
%r = call i1 @ipccp2i(i1 true)
@@ -337,7 +337,7 @@ define i1 @ipccp2b() {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@ipccp2b
; CGSCC-SAME: () #[[ATTR3]] {
-; CGSCC-NEXT: [[R:%.*]] = call noundef i1 @ipccp2ib() #[[ATTR12]]
+; CGSCC-NEXT: [[R:%.*]] = call noundef i1 @ipccp2ib() #[[ATTR13]]
; CGSCC-NEXT: ret i1 [[R]]
;
%r = call i1 @ipccp2ib(i1 true)
@@ -372,7 +372,7 @@ define i32 @ipccp3() {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@ipccp3
; CGSCC-SAME: () #[[ATTR3]] {
-; CGSCC-NEXT: [[R:%.*]] = call noundef i32 @ipccp3i() #[[ATTR12]]
+; CGSCC-NEXT: [[R:%.*]] = call noundef i32 @ipccp3i() #[[ATTR13]]
; CGSCC-NEXT: ret i32 [[R]]
;
%r = call i32 @ipccp3i(i32 7)
@@ -401,7 +401,7 @@ define internal i32 @ipccp4ib(i32 %a) {
; CGSCC-SAME: () #[[ATTR3]] {
; CGSCC-NEXT: br label [[T:%.*]]
; CGSCC: t:
-; CGSCC-NEXT: [[R:%.*]] = call noundef i32 @ipccp4ia(i1 noundef true) #[[ATTR12]]
+; CGSCC-NEXT: [[R:%.*]] = call noundef i32 @ipccp4ia(i1 noundef true) #[[ATTR13]]
; CGSCC-NEXT: ret i32 [[R]]
; CGSCC: f:
; CGSCC-NEXT: unreachable
@@ -432,7 +432,7 @@ define i32 @ipccp4(i1 %c) {
; CGSCC: t:
; CGSCC-NEXT: br label [[F]]
; CGSCC: f:
-; CGSCC-NEXT: [[R:%.*]] = call noundef i32 @ipccp4ib() #[[ATTR12]]
+; CGSCC-NEXT: [[R:%.*]] = call noundef i32 @ipccp4ib() #[[ATTR13]]
; CGSCC-NEXT: ret i32 [[R]]
;
br i1 %c, label %t, label %f
@@ -469,7 +469,7 @@ define ptr @complicated_args_inalloca(ptr %arg) {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@complicated_args_inalloca
; CGSCC-SAME: (ptr nofree noundef nonnull readnone dereferenceable(4) [[ARG:%.*]]) #[[ATTR3]] {
-; CGSCC-NEXT: [[CALL:%.*]] = call noalias noundef nonnull dereferenceable(4) ptr @test_inalloca(ptr noalias nofree noundef nonnull writeonly inalloca(i32) dereferenceable(4) [[ARG]]) #[[ATTR12]]
+; CGSCC-NEXT: [[CALL:%.*]] = call noalias noundef nonnull dereferenceable(4) ptr @test_inalloca(ptr noalias nofree noundef nonnull writeonly inalloca(i32) dereferenceable(4) [[ARG]]) #[[ATTR13]]
; CGSCC-NEXT: ret ptr [[CALL]]
;
%call = call ptr @test_inalloca(ptr inalloca(i32) %arg)
@@ -500,8 +500,8 @@ define ptr @complicated_args_preallocated() {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn
; CGSCC-LABEL: define {{[^@]+}}@complicated_args_preallocated
; CGSCC-SAME: () #[[ATTR4:[0-9]+]] {
-; CGSCC-NEXT: [[C:%.*]] = call token @llvm.call.preallocated.setup(i32 noundef 1) #[[ATTR13]]
-; CGSCC-NEXT: [[CALL:%.*]] = call ptr @test_preallocated(ptr nofree noundef writeonly preallocated(i32) align 4294967296 null) #[[ATTR14:[0-9]+]] [ "preallocated"(token [[C]]) ]
+; CGSCC-NEXT: [[C:%.*]] = call token @llvm.call.preallocated.setup(i32 noundef 1) #[[ATTR14]]
+; CGSCC-NEXT: [[CALL:%.*]] = call ptr @test_preallocated(ptr nofree noundef writeonly preallocated(i32) align 4294967296 null) #[[ATTR15:[0-9]+]] [ "preallocated"(token [[C]]) ]
; CGSCC-NEXT: unreachable
;
%c = call token @llvm.call.preallocated.setup(i32 1)
@@ -539,7 +539,7 @@ define void @complicated_args_sret(ptr %b) {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(argmem: write)
; CGSCC-LABEL: define {{[^@]+}}@complicated_args_sret
; CGSCC-SAME: (ptr nocapture nofree noundef nonnull writeonly align 8 dereferenceable(8) [[B:%.*]]) #[[ATTR6:[0-9]+]] {
-; CGSCC-NEXT: call void @test_sret(ptr nofree noundef writeonly sret([[STRUCT_X:%.*]]) align 4294967296 dereferenceable_or_null(8) null, ptr nocapture nofree noundef nonnull writeonly align 8 dereferenceable(8) [[B]]) #[[ATTR15:[0-9]+]]
+; CGSCC-NEXT: call void @test_sret(ptr nofree noundef writeonly sret([[STRUCT_X:%.*]]) align 4294967296 dereferenceable_or_null(8) null, ptr nocapture nofree noundef nonnull writeonly align 8 dereferenceable(8) [[B]]) #[[ATTR16:[0-9]+]]
; CGSCC-NEXT: ret void
;
call void @test_sret(ptr sret(%struct.X) null, ptr %b)
@@ -563,7 +563,7 @@ define ptr @complicated_args_nest() {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@complicated_args_nest
; CGSCC-SAME: () #[[ATTR3]] {
-; CGSCC-NEXT: [[CALL:%.*]] = call noalias noundef align 4294967296 ptr @test_nest(ptr nofree noundef readnone align 4294967296 null) #[[ATTR12]]
+; CGSCC-NEXT: [[CALL:%.*]] = call noalias noundef align 4294967296 ptr @test_nest(ptr nofree noundef readnone align 4294967296 null) #[[ATTR13]]
; CGSCC-NEXT: ret ptr [[CALL]]
;
%call = call ptr @test_nest(ptr null)
@@ -603,7 +603,7 @@ define void @complicated_args_byval() {
; CGSCC-LABEL: define {{[^@]+}}@complicated_args_byval
; CGSCC-SAME: () #[[ATTR4]] {
; CGSCC-NEXT: [[TMP1:%.*]] = load ptr, ptr @S, align 8
-; CGSCC-NEXT: call void @test_byval(ptr nofree writeonly [[TMP1]]) #[[ATTR15]]
+; CGSCC-NEXT: call void @test_byval(ptr nofree writeonly [[TMP1]]) #[[ATTR16]]
; CGSCC-NEXT: ret void
;
call void @test_byval(ptr byval(%struct.X) @S)
@@ -719,7 +719,7 @@ define i8 @caller0() {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@caller0
; CGSCC-SAME: () #[[ATTR3]] {
-; CGSCC-NEXT: [[C:%.*]] = call noundef i8 @callee() #[[ATTR12]]
+; CGSCC-NEXT: [[C:%.*]] = call noundef i8 @callee() #[[ATTR13]]
; CGSCC-NEXT: ret i8 [[C]]
;
%c = call i8 @callee(i8 undef)
@@ -734,7 +734,7 @@ define i8 @caller1() {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@caller1
; CGSCC-SAME: () #[[ATTR3]] {
-; CGSCC-NEXT: [[C:%.*]] = call noundef i8 @callee() #[[ATTR12]]
+; CGSCC-NEXT: [[C:%.*]] = call noundef i8 @callee() #[[ATTR13]]
; CGSCC-NEXT: ret i8 [[C]]
;
%c = call i8 @callee(i8 undef)
@@ -749,7 +749,7 @@ define i8 @caller2() {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@caller2
; CGSCC-SAME: () #[[ATTR3]] {
-; CGSCC-NEXT: [[C:%.*]] = call noundef i8 @callee() #[[ATTR12]]
+; CGSCC-NEXT: [[C:%.*]] = call noundef i8 @callee() #[[ATTR13]]
; CGSCC-NEXT: ret i8 [[C]]
;
%c = call i8 @callee(i8 undef)
@@ -764,7 +764,7 @@ define i8 @caller_middle() {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@caller_middle
; CGSCC-SAME: () #[[ATTR3]] {
-; CGSCC-NEXT: [[C:%.*]] = call noundef i8 @callee() #[[ATTR12]]
+; CGSCC-NEXT: [[C:%.*]] = call noundef i8 @callee() #[[ATTR13]]
; CGSCC-NEXT: ret i8 [[C]]
;
%c = call i8 @callee(i8 42)
@@ -779,7 +779,7 @@ define i8 @caller3() {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@caller3
; CGSCC-SAME: () #[[ATTR3]] {
-; CGSCC-NEXT: [[C:%.*]] = call noundef i8 @callee() #[[ATTR12]]
+; CGSCC-NEXT: [[C:%.*]] = call noundef i8 @callee() #[[ATTR13]]
; CGSCC-NEXT: ret i8 [[C]]
;
%c = call i8 @callee(i8 undef)
@@ -794,7 +794,7 @@ define i8 @caller4() {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@caller4
; CGSCC-SAME: () #[[ATTR3]] {
-; CGSCC-NEXT: [[C:%.*]] = call noundef i8 @callee() #[[ATTR12]]
+; CGSCC-NEXT: [[C:%.*]] = call noundef i8 @callee() #[[ATTR13]]
; CGSCC-NEXT: ret i8 [[C]]
;
%c = call i8 @callee(i8 undef)
@@ -820,7 +820,7 @@ define void @user_as3() {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(write)
; CGSCC-LABEL: define {{[^@]+}}@user_as3
; CGSCC-SAME: () #[[ATTR7:[0-9]+]] {
-; CGSCC-NEXT: [[CALL:%.*]] = call fastcc align 4 ptr addrspace(3) @const_ptr_return_as3() #[[ATTR12]]
+; CGSCC-NEXT: [[CALL:%.*]] = call fastcc align 4 ptr addrspace(3) @const_ptr_return_as3() #[[ATTR13]]
; CGSCC-NEXT: store i32 0, ptr addrspace(3) [[CALL]], align 4
; CGSCC-NEXT: ret void
;
@@ -839,7 +839,7 @@ define void @user() {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(write)
; CGSCC-LABEL: define {{[^@]+}}@user
; CGSCC-SAME: () #[[ATTR7]] {
-; CGSCC-NEXT: [[CALL:%.*]] = call fastcc align 4 ptr @const_ptr_return() #[[ATTR12]]
+; CGSCC-NEXT: [[CALL:%.*]] = call fastcc align 4 ptr @const_ptr_return() #[[ATTR13]]
; CGSCC-NEXT: store i32 0, ptr [[CALL]], align 4
; CGSCC-NEXT: ret void
;
@@ -858,7 +858,7 @@ define i1 @test_merge_with_undef_values_ptr(i1 %c) {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@test_merge_with_undef_values_ptr
; CGSCC-SAME: (i1 [[C:%.*]]) #[[ATTR3]] {
-; CGSCC-NEXT: [[R1:%.*]] = call i1 @undef_then_null(i1 [[C]]) #[[ATTR12]]
+; CGSCC-NEXT: [[R1:%.*]] = call i1 @undef_then_null(i1 [[C]]) #[[ATTR13]]
; CGSCC-NEXT: ret i1 [[R1]]
;
%r1 = call i1 @undef_then_null(i1 %c, ptr undef, ptr undef)
@@ -895,7 +895,7 @@ define i1 @test_merge_with_undef_values(i1 %c) {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@test_merge_with_undef_values
; CGSCC-SAME: (i1 [[C:%.*]]) #[[ATTR3]] {
-; CGSCC-NEXT: [[R1:%.*]] = call i1 @undef_then_1(i1 [[C]]) #[[ATTR12]]
+; CGSCC-NEXT: [[R1:%.*]] = call i1 @undef_then_1(i1 [[C]]) #[[ATTR13]]
; CGSCC-NEXT: ret i1 [[R1]]
;
%r1 = call i1 @undef_then_1(i1 %c, i32 undef, i32 undef)
@@ -933,7 +933,7 @@ define i32 @test_select(i32 %c) {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@test_select
; CGSCC-SAME: (i32 [[C:%.*]]) #[[ATTR3]] {
-; CGSCC-NEXT: [[CALL:%.*]] = call noundef i32 @select() #[[ATTR12]]
+; CGSCC-NEXT: [[CALL:%.*]] = call noundef i32 @select() #[[ATTR13]]
; CGSCC-NEXT: ret i32 [[CALL]]
;
%call = call i32 @select(i1 1, i32 42, i32 %c)
@@ -982,11 +982,10 @@ define void @test_callee_is_undef(ptr %fn) {
}
define internal void @callee_is_undef(ptr %fn) {
;
-; CGSCC: Function Attrs: memory(readwrite, argmem: none)
+; CGSCC: Function Attrs: norecurse memory(readwrite, argmem: none)
; CGSCC-LABEL: define {{[^@]+}}@callee_is_undef
-; CGSCC-SAME: () #[[ATTR2]] {
-; CGSCC-NEXT: call void undef()
-; CGSCC-NEXT: ret void
+; CGSCC-SAME: () #[[ATTR8:[0-9]+]] {
+; CGSCC-NEXT: unreachable
;
call void %fn()
ret void
@@ -1084,7 +1083,7 @@ define i1 @test_cmp_null_after_cast() {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@test_cmp_null_after_cast
; CGSCC-SAME: () #[[ATTR3]] {
-; CGSCC-NEXT: [[C:%.*]] = call noundef i1 @cmp_null_after_cast() #[[ATTR12]]
+; CGSCC-NEXT: [[C:%.*]] = call noundef i1 @cmp_null_after_cast() #[[ATTR13]]
; CGSCC-NEXT: ret i1 [[C]]
;
%c = call i1 @cmp_null_after_cast(i32 0, i8 0)
@@ -1203,7 +1202,7 @@ define i1 @test_liveness(i1 %c) {
; CGSCC-NEXT: br label [[F]]
; CGSCC: f:
; CGSCC-NEXT: [[P:%.*]] = phi i1 [ true, [[ENTRY:%.*]] ], [ false, [[T]] ]
-; CGSCC-NEXT: [[RC1:%.*]] = call noundef i1 @ret(i1 noundef [[P]]) #[[ATTR12]]
+; CGSCC-NEXT: [[RC1:%.*]] = call noundef i1 @ret(i1 noundef [[P]]) #[[ATTR13]]
; CGSCC-NEXT: ret i1 [[RC1]]
;
entry:
@@ -1275,7 +1274,7 @@ define internal i8 @memcpy_uses_store(i8 %arg) {
; CGSCC-NEXT: [[SRC:%.*]] = alloca i8, align 1
; CGSCC-NEXT: [[DST:%.*]] = alloca i8, align 1
; CGSCC-NEXT: store i8 [[ARG]], ptr [[SRC]], align 1
-; CGSCC-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr noalias nocapture nofree noundef nonnull writeonly dereferenceable(1) [[DST]], ptr noalias nocapture nofree noundef nonnull readonly dereferenceable(1) [[SRC]], i32 noundef 1, i1 noundef false) #[[ATTR16:[0-9]+]]
+; CGSCC-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr noalias nocapture nofree noundef nonnull writeonly dereferenceable(1) [[DST]], ptr noalias nocapture nofree noundef nonnull readonly dereferenceable(1) [[SRC]], i32 noundef 1, i1 noundef false) #[[ATTR17:[0-9]+]]
; CGSCC-NEXT: [[L:%.*]] = load i8, ptr [[DST]], align 1
; CGSCC-NEXT: ret i8 [[L]]
;
@@ -1297,7 +1296,7 @@ define i8 @memcpy_uses_store_caller(i8 %arg) {
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
; CGSCC-LABEL: define {{[^@]+}}@memcpy_uses_store_caller
; CGSCC-SAME: (i8 [[ARG:%.*]]) #[[ATTR3]] {
-; CGSCC-NEXT: [[R:%.*]] = call i8 @memcpy_uses_store(i8 [[ARG]]) #[[ATTR12]]
+; CGSCC-NEXT: [[R:%.*]] = call i8 @memcpy_uses_store(i8 [[ARG]]) #[[ATTR13]]
; CGSCC-NEXT: ret i8 [[R]]
;
%r = call i8 @memcpy_uses_store(i8 %arg)
@@ -1321,12 +1320,12 @@ define i32 @test_speculatable_expr() norecurse {
;
; CGSCC: Function Attrs: norecurse nosync memory(none)
; CGSCC-LABEL: define {{[^@]+}}@test_speculatable_expr
-; CGSCC-SAME: () #[[ATTR9:[0-9]+]] {
+; CGSCC-SAME: () #[[ATTR10:[0-9]+]] {
; CGSCC-NEXT: [[STACK:%.*]] = alloca i32, align 4
-; CGSCC-NEXT: [[SPEC_RESULT:%.*]] = call i32 @speculatable() #[[ATTR17:[0-9]+]]
+; CGSCC-NEXT: [[SPEC_RESULT:%.*]] = call i32 @speculatable() #[[ATTR18:[0-9]+]]
; CGSCC-NEXT: [[PLUS1:%.*]] = add i32 [[SPEC_RESULT]], 1
; CGSCC-NEXT: store i32 [[PLUS1]], ptr [[STACK]], align 4
-; CGSCC-NEXT: [[RSPEC:%.*]] = call i32 @ret_speculatable_expr(i32 [[PLUS1]]) #[[ATTR17]]
+; CGSCC-NEXT: [[RSPEC:%.*]] = call i32 @ret_speculatable_expr(i32 [[PLUS1]]) #[[ATTR18]]
; CGSCC-NEXT: ret i32 [[RSPEC]]
;
%stack = alloca i32
@@ -1435,7 +1434,7 @@ define internal void @indirect() {
;
; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(write)
; CGSCC-LABEL: define {{[^@]+}}@indirect
-; CGSCC-SAME: () #[[ATTR10:[0-9]+]] {
+; CGSCC-SAME: () #[[ATTR11:[0-9]+]] {
; CGSCC-NEXT: store i32 0, ptr @x, align 4
; CGSCC-NEXT: ret void
;
@@ -1456,7 +1455,7 @@ define internal void @broker(ptr %ptr) {
; CGSCC-LABEL: define {{[^@]+}}@broker
; CGSCC-SAME: () #[[ATTR2]] {
; CGSCC-NEXT: entry:
-; CGSCC-NEXT: call void @indirect() #[[ATTR18:[0-9]+]]
+; CGSCC-NEXT: call void @indirect() #[[ATTR19:[0-9]+]]
; CGSCC-NEXT: call void @unknown()
; CGSCC-NEXT: ret void
;
@@ -1659,17 +1658,18 @@ dead5:
; CGSCC: attributes #[[ATTR5]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) }
; CGSCC: attributes #[[ATTR6]] = { mustprogress nofree nosync nounwind willreturn memory(argmem: write) }
; CGSCC: attributes #[[ATTR7]] = { mustprogress nofree nosync nounwind willreturn memory(write) }
-; CGSCC: attributes #[[ATTR8:[0-9]+]] = { speculatable memory(none) }
-; CGSCC: attributes #[[ATTR9]] = { norecurse nosync memory(none) }
-; CGSCC: attributes #[[ATTR10]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(write) }
-; CGSCC: attributes #[[ATTR11:[0-9]+]] = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
-; CGSCC: attributes #[[ATTR12]] = { nofree nosync willreturn }
-; CGSCC: attributes #[[ATTR13]] = { nofree willreturn }
-; CGSCC: attributes #[[ATTR14]] = { nofree nounwind willreturn }
-; CGSCC: attributes #[[ATTR15]] = { nofree nounwind willreturn memory(write) }
-; CGSCC: attributes #[[ATTR16]] = { nofree willreturn memory(readwrite) }
-; CGSCC: attributes #[[ATTR17]] = { nosync }
-; CGSCC: attributes #[[ATTR18]] = { nounwind }
+; CGSCC: attributes #[[ATTR8]] = { norecurse memory(readwrite, argmem: none) }
+; CGSCC: attributes #[[ATTR9:[0-9]+]] = { speculatable memory(none) }
+; CGSCC: attributes #[[ATTR10]] = { norecurse nosync memory(none) }
+; CGSCC: attributes #[[ATTR11]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(write) }
+; CGSCC: attributes #[[ATTR12:[0-9]+]] = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
+; CGSCC: attributes #[[ATTR13]] = { nofree nosync willreturn }
+; CGSCC: attributes #[[ATTR14]] = { nofree willreturn }
+; CGSCC: attributes #[[ATTR15]] = { nofree nounwind willreturn }
+; CGSCC: attributes #[[ATTR16]] = { nofree nounwind willreturn memory(write) }
+; CGSCC: attributes #[[ATTR17]] = { nofree willreturn memory(readwrite) }
+; CGSCC: attributes #[[ATTR18]] = { nosync }
+; CGSCC: attributes #[[ATTR19]] = { nounwind }
;.
; TUNIT: [[RNG0]] = !{i32 0, i32 -2147483648}
;.
diff --git a/openmp/libomptarget/test/jit/type_punning.c b/openmp/libomptarget/test/jit/type_punning.c
index 8531a84f74ec1a..c8af8eec502acd 100644
--- a/openmp/libomptarget/test/jit/type_punning.c
+++ b/openmp/libomptarget/test/jit/type_punning.c
@@ -13,12 +13,11 @@
// UNSUPPORTED: x86_64-pc-linux-gnu
// UNSUPPORTED: x86_64-pc-linux-gnu-LTO
-// FIXME: We want that there is only the kernel function left, not two outlined
+// Ensure that there is only the kernel function left, not any outlined
// parallel regions.
//
// CHECK: define
-// CHECK: define
-// CHECK: define
+// CHECK-NOT: define
#include <omp.h>
void f(long *A, int N) {
More information about the Openmp-commits
mailing list