r185544 - Fix PR16454: Don't #include altivec.h when preprocessing assembly.

Bill Schmidt wschmidt at linux.vnet.ibm.com
Wed Jul 3 08:36:02 PDT 2013


Author: wschmidt
Date: Wed Jul  3 10:36:02 2013
New Revision: 185544

URL: http://llvm.org/viewvc/llvm-project?rev=185544&view=rev
Log:
Fix PR16454: Don't #include altivec.h when preprocessing assembly.

When the -maltivec flag is present, altivec.h is auto-included for the
compilation.  This is not appropriate when the job action is to
preprocess a file containing assembly code.  So don't do that.

I was unable to convert the test in the bug report into a regression
test.  The original symptom was exposed with:

  % touch x.S
  % ./bin/clang -target powerpc64-unknown-linux-gnu -maltivec -S -o - x.S

I tried this test (and numerous variants) on a PPC64 system:

----------------------------------------------------------------------------
// RUN: touch %t
// RUN: %clang -maltivec -S %t -o - | FileCheck %s

// Verify that assembling an empty file does not auto-include altivec.h.

// CHECK-NOT: static vector
----------------------------------------------------------------------------

However, this test passes for some reason even on a clang built
without the fix.  I'd be happy to add a test case but at this point
I'm not able to figure one out, and I don't want to hold up the patch
unnecessarily.  Please let me know if you have ideas.

Thanks,
Bill

Modified:
    cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=185544&r1=185543&r2=185544&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Jul  3 10:36:02 2013
@@ -2858,7 +2858,10 @@ void Clang::ConstructJob(Compilation &C,
   Args.AddLastArg(CmdArgs, options::OPT_flimit_debug_info);
   Args.AddLastArg(CmdArgs, options::OPT_fno_limit_debug_info);
   Args.AddLastArg(CmdArgs, options::OPT_fno_operator_names);
-  Args.AddLastArg(CmdArgs, options::OPT_faltivec);
+  // AltiVec language extensions aren't relevant for assembling.
+  if (!isa<PreprocessJobAction>(JA) || 
+      Output.getType() != types::TY_PP_Asm)
+    Args.AddLastArg(CmdArgs, options::OPT_faltivec);
   Args.AddLastArg(CmdArgs, options::OPT_fdiagnostics_show_template_tree);
   Args.AddLastArg(CmdArgs, options::OPT_fno_elide_type);
 





More information about the cfe-commits mailing list