@@ -3231,14 +3231,10 @@ class OffloadingActionBuilder final {
3231
3231
if (auto *IA = dyn_cast<InputAction>(HostAction)) {
3232
3232
SYCLDeviceActions.clear ();
3233
3233
3234
+ std::string InputName = IA->getInputArg ().getValue ();
3234
3235
// Objects should already be consumed with -foffload-static-lib
3235
- const char * InputName = IA->getInputArg ().getValue ();
3236
3236
if (Args.hasArg (options::OPT_foffload_static_lib_EQ) &&
3237
- HostAction->getType () == types::TY_Object &&
3238
- llvm::sys::path::has_extension (InputName) &&
3239
- types::lookupTypeForExtension (
3240
- llvm::sys::path::extension (InputName).drop_front ()) ==
3241
- types::TY_Object)
3237
+ IA->getType () == types::TY_Object && isObjectFile (InputName))
3242
3238
return ABRT_Inactive;
3243
3239
3244
3240
for (unsigned I = 0 ; I < ToolChains.size (); ++I)
@@ -3255,11 +3251,7 @@ class OffloadingActionBuilder final {
3255
3251
// Check if the type of the file is the same as the action. Do not
3256
3252
// unbundle it if it is not. Do not unbundle .so files, for example,
3257
3253
// which are not object files.
3258
- if (IA->getType () == types::TY_Object &&
3259
- (!llvm::sys::path::has_extension (FileName) ||
3260
- types::lookupTypeForExtension (
3261
- llvm::sys::path::extension (FileName).drop_front ()) !=
3262
- types::TY_Object))
3254
+ if (IA->getType () == types::TY_Object && !isObjectFile (FileName))
3263
3255
return ABRT_Inactive;
3264
3256
// When creating FPGA device fat objects, all host objects are
3265
3257
// partially linked. Gather that list here.
@@ -3716,7 +3708,7 @@ class OffloadingActionBuilder final {
3716
3708
if (CanUseBundler && isa<InputAction>(HostAction) &&
3717
3709
InputArg->getOption ().getKind () == llvm::opt::Option::InputClass &&
3718
3710
!types::isSrcFile (HostAction->getType ())) {
3719
- const char * InputName = InputArg->getValue ();
3711
+ std::string InputName = InputArg->getValue ();
3720
3712
// Do not create an unbundling action for an object when we know a fat
3721
3713
// static library is being used. A separate unbundling action is created
3722
3714
// for all objects and the fat static library.
@@ -3728,10 +3720,7 @@ class OffloadingActionBuilder final {
3728
3720
// for objects is still needed.
3729
3721
if (C.getDefaultToolChain ().getTriple ().isWindowsMSVCEnvironment () ||
3730
3722
!(HostAction->getType () == types::TY_Object &&
3731
- llvm::sys::path::has_extension (InputName) &&
3732
- types::lookupTypeForExtension (
3733
- llvm::sys::path::extension (InputName).drop_front ()) ==
3734
- types::TY_Object &&
3723
+ isObjectFile (InputName) &&
3735
3724
Args.hasArg (options::OPT_foffload_static_lib_EQ))) {
3736
3725
ActionList HostActionList;
3737
3726
Action *A (HostAction);
@@ -3740,10 +3729,7 @@ class OffloadingActionBuilder final {
3740
3729
HostAction->getType () != types::TY_FPGA_AOCR &&
3741
3730
HostAction->getType () != types::TY_FPGA_AOCX &&
3742
3731
!(HostAction->getType () == types::TY_Object &&
3743
- llvm::sys::path::has_extension (InputName) &&
3744
- types::lookupTypeForExtension (
3745
- llvm::sys::path::extension (InputName).drop_front ()) ==
3746
- types::TY_Object)) {
3732
+ isObjectFile (InputName))) {
3747
3733
if (HasFPGADeviceBinary (C, InputArg->getAsString (Args), true ))
3748
3734
A = C.MakeAction <InputAction>(*InputArg, types::TY_FPGA_AOCX);
3749
3735
else if (HasFPGADeviceBinary (C, InputArg->getAsString (Args)))
@@ -4162,10 +4148,7 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
4162
4148
if (auto *IA = dyn_cast<InputAction>(LI)) {
4163
4149
std::string FileName = IA->getInputArg ().getAsString (Args);
4164
4150
if (IA->getType () == types::TY_Object &&
4165
- (!llvm::sys::path::has_extension (FileName) ||
4166
- types::lookupTypeForExtension (
4167
- llvm::sys::path::extension (FileName).drop_front ()) !=
4168
- types::TY_Object))
4151
+ !isObjectFile (FileName))
4169
4152
// Pass the Input along to linker.
4170
4153
TempLinkerInputs.push_back (LI);
4171
4154
else
@@ -5816,3 +5799,9 @@ bool clang::driver::isOptimizationLevelFast(const ArgList &Args) {
5816
5799
return Args.hasFlag (options::OPT_Ofast, options::OPT_O_Group, false );
5817
5800
}
5818
5801
5802
+ bool clang::driver::isObjectFile (std::string FileName) {
5803
+ return (llvm::sys::path::has_extension (FileName) &&
5804
+ types::lookupTypeForExtension (
5805
+ llvm::sys::path::extension (FileName).drop_front ()) ==
5806
+ types::TY_Object);
5807
+ }
0 commit comments