gchatelet created this revision.
gchatelet added a reviewer: courbet.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya.
Herald added projects: clang, LLVM.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D60719
Files:
clang/lib/CodeGen/CodeGenModule.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -5464,6 +5464,14 @@
}
}
+static bool IsForceInlineLibc(const SelectionDAG &DAG) {
+ const Module *M = DAG.getMachineFunction().getFunction().getParent();
+ if (auto *MD = mdconst::extract_or_null<ConstantInt>(
+ M->getModuleFlag("force-inline-libc")))
+ return MD->getZExtValue();
+ return false;
+}
+
/// Lower the call to the specified intrinsic function. If we want to emit this
/// as a call to a named external function, return the name. Otherwise, lower
it
/// and return null.
@@ -5537,10 +5545,11 @@
unsigned Align = MinAlign(DstAlign, SrcAlign);
bool isVol = MCI.isVolatile();
bool isTC = I.isTailCall() && isInTailCallPosition(&I, DAG.getTarget());
+ bool IsAlwaysInline = IsForceInlineLibc(DAG);
// FIXME: Support passing different dest/src alignments to the memcpy DAG
// node.
SDValue MC = DAG.getMemcpy(getRoot(), sdl, Op1, Op2, Op3, Align, isVol,
- false, isTC,
+ IsAlwaysInline, isTC,
MachinePointerInfo(I.getArgOperand(0)),
MachinePointerInfo(I.getArgOperand(1)));
updateDAGForMaybeTailCall(MC);
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -6090,6 +6090,9 @@
// beyond the given memory regions. But fixing this isn't easy, and most
// people don't care.
+ assert(MF->getFunction().getParent()->getModuleFlag("force-inline-libc") ==
+ nullptr);
+
// Emit a library call.
TargetLowering::ArgListTy Args;
TargetLowering::ArgListEntry Entry;
Index: clang/lib/CodeGen/CodeGenModule.cpp
===================================================================
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -596,6 +596,10 @@
if (!getCodeGenOpts().RecordCommandLine.empty())
EmitCommandLineMetadata();
+ if (LangOpts.Freestanding) {
+ getModule().addModuleFlag(llvm::Module::Override, "force-inline-libc", 1);
+ }
+
EmitTargetMetadata();
}
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -5464,6 +5464,14 @@
}
}
+static bool IsForceInlineLibc(const SelectionDAG &DAG) {
+ const Module *M = DAG.getMachineFunction().getFunction().getParent();
+ if (auto *MD = mdconst::extract_or_null<ConstantInt>(
+ M->getModuleFlag("force-inline-libc")))
+ return MD->getZExtValue();
+ return false;
+}
+
/// Lower the call to the specified intrinsic function. If we want to emit this
/// as a call to a named external function, return the name. Otherwise, lower it
/// and return null.
@@ -5537,10 +5545,11 @@
unsigned Align = MinAlign(DstAlign, SrcAlign);
bool isVol = MCI.isVolatile();
bool isTC = I.isTailCall() && isInTailCallPosition(&I, DAG.getTarget());
+ bool IsAlwaysInline = IsForceInlineLibc(DAG);
// FIXME: Support passing different dest/src alignments to the memcpy DAG
// node.
SDValue MC = DAG.getMemcpy(getRoot(), sdl, Op1, Op2, Op3, Align, isVol,
- false, isTC,
+ IsAlwaysInline, isTC,
MachinePointerInfo(I.getArgOperand(0)),
MachinePointerInfo(I.getArgOperand(1)));
updateDAGForMaybeTailCall(MC);
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -6090,6 +6090,9 @@
// beyond the given memory regions. But fixing this isn't easy, and most
// people don't care.
+ assert(MF->getFunction().getParent()->getModuleFlag("force-inline-libc") ==
+ nullptr);
+
// Emit a library call.
TargetLowering::ArgListTy Args;
TargetLowering::ArgListEntry Entry;
Index: clang/lib/CodeGen/CodeGenModule.cpp
===================================================================
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -596,6 +596,10 @@
if (!getCodeGenOpts().RecordCommandLine.empty())
EmitCommandLineMetadata();
+ if (LangOpts.Freestanding) {
+ getModule().addModuleFlag(llvm::Module::Override, "force-inline-libc", 1);
+ }
+
EmitTargetMetadata();
}
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits